Monday, December 31, 2007

Try Git

I'm not cutting edge. I was a long time ago but today, I prefer mature stuff. That's why I cultivate the luxury to ignore brand new, cool software until it's not only cool but most of the wrinkles have been ironed out by those guys who like to bleed (it's not called "cutting edge" for nothing).

So when Subversion came out, I stayed with CVS until version 1.2. I installed it and liked it immediately. Now, some years later, even the Eclipse plugins (Subclipse and Subversive) work so well that using them becomes uninterruptive.

The same is true for GIT. When Linus (of Linux fame) announced it, I knew that this guy was probably smart enough to know when to start a new version control system and when to stay with the flock. Alas, I never had the pressure to try it.

Actually, I had the pressure but I didn't notice because I didn't know enough about GIT, specifically what it does different than, say, Subversion (a.k.a "the worlds largest patch for CVS"). In nutshell, GIT is a set of commands to manage one or more repositories with the same or different versioned objects.

Confused? An example: You work at a paranoid company that won't allow you to connect to some OSS CVS/SVN server to update the files of a project which you're using in your daily work. Sad but quite common. Let's ignore for a minute the relative dangers of using CVS (which you aren't allowed to use) and using HTTP (which you can use). What options do you have?

You can download the files at home, put them on a USB drive and take them to work. That works pretty well. Now, one day, you make a change to the sources at home and at work. Only, you forget to commit one of them. So you keep updating the sources and eventually, you will run into problems merging the files because of that one uncommitted change.

This happens because neither CVS nor SVN allow you to "clone" the source repository. GIT works differently: When you start, you either create an empty repository or you copy an existing one. When you do that, you get everything. If that other repository gets corrupted, it could be restored completely from your copy. (Remember? "Backups are for wimps; real man put their software on public FTP servers and let the world mirror them!")

Also, GIT will track the work in each clone repository in an individual branch (unlike SVN where everyone usually works on the same branch). When you checkout the latest version in your working directory, you don't work on the same branch as any other developer. If you commit something, that's in your local branch only. If you break something, no one but you will notice.

Only when you're satisfied with your work, you "push" your changes over to other people. You needn't even push it to everyone at once. You can send your changes to a few colleagues first, before pushing them to the main project repository for everyone to see. Or you can keep it. GIT will happily download all the branches from the main repository without disturbing yours unless you say "Hey, I want to merge to main development into my code."

At that time, you will notice something: GIT will ask you to commit all your work first if you have uncommitted files in your working directory. In SVN this isn't possible or at least not that simple; you'd have to setup a SVN branch for each merge you do. For GIT, it's simple because from its point of view, the changes are not related in the first place. True, the do have a common ancestor somewhere but after that, they are as independent as they can be.

So you have the great luxury to be able to commit all changes you made, saving all your work before you do the actual merge. You can even save stuff away that you don't want to merge, so every modified file after that is actually part of the merge. This also means if something goes wrong, you can simply roll back all changes by checking out the head of your local development branch. Even better, you can create better diffs. It's simple to create a diff for a) everything you changed (diff common-ancestor local-branch-head), b) everything everyone else changed (common-ancestor global-branch-head) and c) everything you changed to do the merge (diff local-branch-head working-copy). In SVN, you usually see a mix of a) and c), at least.

So, if you usually work from several places and can't keep a network connection to the central server all the time, give GIT a try when you start your next project. It's worth it.

A Quiet Computer

Does your computer sound like a F-15 turbine? Well, my old one did and after two years, I was really sick of it, so I decided to silence the beast.

The Components

  • CoolerMaster CAC-T05 Centurion 5 case. The case is small, light and offers tool-less installation. Most stuff is clip-on. All edges are folded so you won't cut yourself. Also, it doesn't come with a power supply, which is good since I'm going to install my own anyway. Again a few bucks saved (and a considerable amount of waste). The case is produced for more than a year which tells to me: It's a quality product that people still buy.
  • Gigabyte GA-P35C-DS3R, Intel P35, FSB 1333, DDR2/DDR3. A high quality board with some room to upgrade for the next two years (for example, to DDR3 when the modules become as cheap as DDR2 is today or a Quad core CPU).
  • Intel Core 2 Duo E6750, Dual Core, 2.66GHz, 4MB Cache, FSB 1333. Not the latest CPU but with a TPC (total power consumption) of 60 watts, easy to keep cool (which means you don't have to buy the most advanced cooler). It's the LGA775 socket version matching the mainboard.

    Here, I considered the E6650 (Dual Core, 2.33GHz) and the Q6600 (Quad Core). The smaller brother of the E6750 offers less bang for the buck and the Quad Core need insane coolers, right now. The board can take both, so I decided to go with the E6750 and wait for Intel to come up with a Quad Core with a TPC of less than 90.
  • Asus EN8600GT Silent, 2*DVI, 256MB RAM, PCI Express x16. This board comes with a passive cooler. There is a second version with 512MB RAM but I don't game that much and Blender runs comfortably with 256MB for my projects, so no need to waste any money on something I don't need and that I'd have to cool down. Every component you install draws power which eventually gets converted into heat. The less, the better. One thing to note: This board gets hot and when I say hot, I mean skin-burning hot. While running 3D games, the temperature can reach 100°C. This is normal. The board and the chips on it have been designed for that kind of stress. Alas, the rest of your PC is not, so it is important to get that heat out.

Unlike other components, RAM and hard drive don't add that much to the concept so you can choose almost anything your dealer can deliver. I installed two Kingston HyperX DDR2 2GB kits (for a total of 4GB RAM) and a 500GB Samsung HD501LJ drive (SATA-II). The board does have an IDE slot but in order to keep the cable jungle in the case to a minimum, you should use SATA drives, especially for the DVD drive. I installed a Samsung WriteMaster SH-S203N.

Noise Control

The tricky part is to select quiet components for the moving parts: Fans and power supply. For all other components, you should just select something which doesn't drain insane amounts of power (because that directly translates into insane amounts of head which you have to deal with).

  • ichbinleise® Power NT 500 Watt - the power supply. ichbinleise ("I'm silent") is a company that has specialized into silent computers and components. The big plus: If they don't have some part you need, they usually have something else which works equally well (or sometimes better because of new developments).
  • Fan mounts made of soft silicon. A must have. Those keep the fans in place without screws and make sure the vibrations don't cross over to the case. When you buy them, look for double tipped ones instead of ones with one flat side. The idea of the flat ones is that you have fingers which can bend by an arbitrary angle into any direction while you pull the ones behind the fan through the case and the holes in the corner of the fan. Just say no. The double tipped ones are much more easy to install (take the fan, pull them through, then easily pull them through the case from the outside) and if you can't stand the tips standing out, just cut them off after the installation with a sharp knife.
  • Arctic Cooling Freezer 7 Pro, Socket 775, 520g to keep the CPU cool. Easy to install if you follow the instructions. I didn't. I still managed it, though. Note: You don't need any thermo transfer goo for this cooler. It comes equipped with a pad.
  • Arctic Cooling AF12025 Fan, 120mm fan for the back of the case.
  • Pabst 8412N/2GLE fan, 80mm for the front.
  • Zalman FanMate 2 Control, fan control to silence the 120mm fan.
  • Sharkoon HDD Vibe-Fixer III to keep the hard disk away from the case (resonance control).

You might be wondering about the amount of fans and the lack of case insulation. The latter suffers from two problems: If the case insulation is perfect, no noise will come out ... and no heat, either. That means your PC will die of overheating in two minutes. If nothing in the case generates any sound you can hear, the insulation is futile. So the goal should always be to buy silent components and not to try to reduce the noise afterwards.

So the amount of fans is not a problem as such. It quickly becomes a problem when the fans can be heard. To avoid this, I use two strategies: First, I install enough fans that no component ever gets so hot that any fan would have to run at top speed. The slower they can go, the more silent they are. If there is always a constant flow of air through the case, the fans stay silent, so that's what I need. Secondly, I install quiet fans and use silicon fan mounts to make sure the inevitable vibrations of the fan can't resonate with the case. Problem solved.

In case you still hear something afterwards, the noise should be very quiet. Only then, you can consider adding a patch of insulation or two. But usually, the insulation only makes everything worse because it blocks the flow of air, gets in the way when you install components, etc. Furthermore, all these quiet components cost a few bucks. If one of them is broken and makes any sound, just throw it away and buy a new one.

Installation

If you have never build a PC before, google the internet for some basic help. I'll concentrate here on the major issues I ran into.

Installation order is not a big deal. I've found it hard to squeeze the hard disk past the mainboard, though. There are two problems here: The case is for quick/toolless installation. This means the Viber-Fixer can't be screwed into the 5 1/4" slots. My solution was to screw the big dampers to the hard disk, then plug the tracks onto that and just stuff that into the middle 5 1/4" slot. After locking this in place with the plastic lock of the case, the disk was held in place.

Sure, it won't stay there when you pull at it. But during normal operation, the drive won't move - the forces of moving the tiny heads around inside are just too small. You should be careful when you drag the case around, though (lan parties, etc). If you fear that the drive might move, just tape some thick paper around the mainboard edge. That will prevent accidental short circuits.

For the fans, install the silicon fan mounts in the fan, first and then position the fan inside the case to pull the other end through the holes in the case. This way, you don't have to do insane finger contortions to pull the mounts through the tight holes of the fan inside the case.

I plugged the fans into the fan plugs on the mainboard. You can connect them directly with the power supply but then, you'll have to open the case to check on them. If you plug them into the mainboard, you can use software to check the fan speeds.

I tried to install a silicon power supply mount, too. That didn't fit since the case has two wide metal trays on which the power supply rests and one of them collides with the silicon. If it was present, the holes for the screws weren't aligned anymore. But since the supply doesn't generate and vibrations (maybe the fan is already isolated; I didn't look inside), this is not an issue.

You might consider to plug in all the case's cables into the mainboard before installing the board itself. The cables from the front go into tiny pins at the bottom of the installed board and they can be hard to reach (especially after you installed half of them).

First Power

An observatory has "first light" when they open the covers for the first time. Plugging in the power cord for the first time into your newly assembled PC is also a moment to remember. You plug in the power cord, flip the switch on the power supply and if you're lucky ... nothing happens. Today's PCs don't start when power comes up. So nothing to worry about so far. If the lights go out and you hear a pop or a hissing sound, chances are you just blew something. Congratulation. Next time, invest a minute or two to check all the cables a second time. This time, swear and curse and then look for a black patch and replace whatever got fried.

So the big moment is when you press the big power switch at the front. At this time, it is advisable to have the case open because you'll probably miss any acoustic cue that the PC is actually booting (unless there is no other noise). In my case, the fans didn't even start which is always a bad sign. Note that today, PCs don't usually start to smoke and burn if you did something wrong. After twenty years of cheap back-alley assembly, manufacturers have build one or two safety features in the components like plugs which either can't be installed the wrong way or which simply don't do anything if they are (so they don't fry anything).

To locate the problem, unplug everything from the power supply, remove all cards except the CPU and it's cooler. Then start with the big 20pin power plug for the mainboard. Plug it in, try the switch. If the fan of the power supply doesn't start turning, either there is a short circuit somewhere or it doesn't get the signal from the power switch. Note: For the basic test, you don't even need any RAM installed! Just the CPU, the CPU cooler (which doesn't have to be plugged in; just keep the running time short in this case! Never start the system without a CPU cooler!) and the power supply is enough to check if the system is okay.

In my case, I had missed a pin when installing the main power switch. After replugging it, the main fan showed me that the system was coming up.

The front fan showed some erratic movements as did the CPU fan. Apparently, the mainboard only triggers them when needed. Nice.

Depending on your needs, you should go through the BIOS setup to disable anything you don't need. I didn't need the serial and parallel port plus I switched the SATA connectors to AHCI for Linux. Time to boot from the DVD drive.

Ubuntu

My computer magazine came with an Ubuntu DVD for 64bit systems (which you need if you ever want to use more than 3.5GB of RAM; you can install more but you won't be able to use it), so I have that a try.

Since I have a big file server (1.5TB), I installed a smaller 300GB HD as the main drive and made a backup of all the data on it on the new 500GB drive attached via the eSATA bracket that comes with the mainboard. Ubuntu came up with no fuzz, mounted the old drive without problem. When I tried to use the partition editor on the new (external) drive, it crashed. Hm.

Back to the command line. Unfortunately, there is no console installed. Okay, Alt-F2 works and xterm is there, too. So xterm it is. A few moments later, the second drive is partitioned with cfdisk, the filesystem is there (mkreiserfs) and rsync -avHPh ... (preserve all attributes, hard links, show some verbose progress in human readable format and continue partial files) starts to copy the files to the new, bigger home.

Ten minutes later, the screen freezes. On the keyboard, caps- and scroll-lock start to blink; it's a kernel oops ("Linux crashed"). Hm. That's not nice. Did I fry the RAM while installing it? openSUSE comes with a memory test but that can't find anything. So maybe a driver problem. Just to be sure, I do the procedure again and again, after half an hour, the system freezes with a blinking keyboard. This time, I had the kernel log open but the system hung before it could display the error. Also, there is no way to switch to a text console with the kernel output that I could find in a few moments. Well, Ubuntu, it's been nice to meet you. Goodbye.

openSUSE

Back to openSUSE. I'm using SUSE for 15 years, now, and I'm comfortable with the system. For some reason, Debian based systems hate me (dpkg usually corrupts its database with every second install that I try; did no one ever attempt to abort an install?). Maybe that's why I couldn't get Ubuntu to fly.

Memory test shows that the RAM is probably okay, so it's got to be a driver problem in Ubuntu. Trying to boot from a freshly burned openSUSE x86_64 DVD fails. Hm. In my old system, I can mount the DVD but the new drive won't accept it. Strange. I can boot from the DVD but I can't mount it later.

Oh well, after connecting and setting up the network (ifconfig eth0 ...ip... netmask 255.255.255.0) in the rescue system (another boot option with openSUSE), I just copied the ISO file over and unpacked it (mount -o loop openSUSE-10.3-DVD-x86_64.iso /mnt ; rsync -avP /mnt suse ; umount /mnt). Booting again and switching to "Source: Hard Disk" (F4). I didn't specify anything when it asked from which hard disk; later, the installer will present me a list to pick from.

The first thing in the installer is an error: It can't find the installation repository. Well, yeah, I know. So I press return to close the dialog, select the keyboard and then "Start Installation / System", "Start Installation/Update", "Hard Disk", select the right partition and the directory ("/suse" in my case). Houston, we have lift off.

The rest of the installation is pretty standard. I suggest not to add any online repositories during the installation. I did once and the installer figured it was much more smart to download all 4GB again instead of using the local files. Duh. Instead of 10 minutes, the install took five hours.

That's all folks.

Afterword

It seems the RAM didn't work with the board after all. That would explain the random crashes I got with Ubuntu. I'd hoped that this kind of problem had been solved in 1994. Let's see if my dealer takes the RAM modules back. I'm thinking about upgrading my RAID with 500GB disks.

Finally, a Great Setup

Check it out:

I now have a 3520 by 1200 desktop on two displays, 4GB of RAM and a Dual Core E6750 CPU. That means I can have Blender and a web browser open side by side or I can have my text editor jEdit, a thesaurus/dictionary and treeline plus a web browser open without any overlapping windows.

Life doesn't get much better than this :-)

Saturday, December 29, 2007

Gigabyte GA-P35C-DS3R with Kingston HyperX

If you plan to buy yourself 2GB of Kingston HyperX RAM (KHX8500D2K2/2GN to be precise) for a Gigabyte GA-P35C-DS3R (BIOS Rev. mainboard, beware: I couldn't get it to work. I tried:

  • DDR2-1066/PC-8500 and DDR2-800/PC-6400 settings
  • 1.8V and 2.2V
  • Installing both modules in bank 1 and 2 (instead of 1 and 3)

With DDR2-800/PC-6400 settings and 1.8V, the RAM would pass MemTest+ V1.70 but some applications would crash reliably (comix, for example, when opening the third file).

I've now replaced the modules with 2*2GB from G.Skill and the board is rock solid.

Weird Path Twist in Blender

If you ever ran into the "Weird Path Twist" (a.k.a Z-Twist or curve singularity twist) in Blender, I've opened a bug against it: [#8022] Some operations on control points can introduce weird twists in paths

If you don't know Blender, here is what I did in two days:

It's the entrance to a public bath on the TAURUS. Since the corridor outside is perpendicular to the bath's ground, it's a gravity lock; in the center of the circular walkway, you can see the floor make a 90° turn downwards to align visitors with the gravity field of the bath. If you want to gaze, you can stay on the circular walkway and have a great view of the bath without craning your neck.

Tuesday, December 18, 2007

N&N in Eclipse 3.4M4: StringBuffer "Optimization"

Another one for the futile/harmful optimization awards: The New & Noteworthy page for Eclipse 3.4M4 says:

The new 'Convert to StringBuffer' quick assist (Ctrl+1) transforms string concatenations into more efficient, albeit less compact, code using an explicit StringBuffer:

Hello? Since when is using StringBuffer more efficient than using String concatenation? Answer: It was upto Java 1.3 (or maybe 1.2; I'm too lazy to look it up right now).

With Java 1.4, the compiler used StringBuffer as well, so this optimization doesn't buy anything but makes the code harder to read.

Worse, with Java 1.5, the compiler generates more optimal code by using StringBuilder instead of StringBuffer. The builder is not synchronized; since string concatenation doesn't suffer from threading issues, this is safe and faster!

And the morale: If you optimize something, make sure you don't rely on some myth about X being faster than Y.

PS: Of course, there is already a bug tracking this.

Monday, December 17, 2007

Looking for Quote

I'm looking for a quote which goes along these lines: "If we are ever visited by aliens, we'll have a lot of trouble explaining how a race smart enough to design the bomb is dumb enough to actually build it". Does anyone know who said this?