The Town Nerd

Streaming Disk Images Over the Network

In 2009, a customer needed a way to stream disk images over the network when imaging new machines. Since the machines were new, the images were mostly empty space, which made them good candidates for compression. CPU was a bigger bottleneck than network bandwidth, and he decided the existing compression options, including gzip, were too slow. He also wanted to use udpcast to image multiple machines at once.

Another developer and I worked on a proof of concept, passing code back and forth through the customer. The other developer wrote the first version, and I found several large speed gains.

We chose to leave the data uncompressed and compress only the empty blocks.

What I Did

The program was written in plain C. I knew SSE2 and was comfortable mixing assembler into C, but the user and system times I was reviewing with the customer didn’t point to enough of a gain to justify the effort.

The Numbers

I don’t have a clean timing of the first version. Early on, we were testing CPU, memory, disk write and network speeds on the customer’s systems, and those tests can’t be compared with the ones below, which I ran on the final sets of changes.

Compressing and decompressing a test file on one machine, with no network involved:

The combined changes took a little over half of gzip’s time. Most of their time went to waiting on I/O. They also beat my changes alone while doing slightly more processing of the data.

The customer’s tests, in his own environment, showed the program still sent the same amount of data as gzip: about 5 GB for an 80 GB disk.

In that same environment, my changes alone brought network transfers down from 20 minutes with gzip to 7 minutes, 15 seconds. The customer didn’t report final numbers for the combined version.