François Schiettecatte’s Blog

Chrome OS

Posted in General, Software Development by François Schiettecatte on November 22, 2009

I have been snowed under with work lately and was only able to spend a little time playing with Google’s new Chrome OS.

I did find a very good review by Paul Thurrott though, well worth reading.

Fedora 12

Posted in Software Development by François Schiettecatte on November 19, 2009

Just upgraded to Fedora 12, much nicer than Fedora 11.

And the upgrade process was smooth which was welcome.

InnoDB Compression

Posted in Scaling, Software Development by François Schiettecatte on November 19, 2009

I had a few hours to spare a couple of days ago and decided to check InnoDB Plugin 1.0’s support for data compression.

In a project I work on from time to time, there is a table which contains three blobs which contains text data. To store the data efficiently I was using the COMPRESS() function in MySQL and doing a “CONVERT(UNCOMPRESS(text) AS utf8)” to uncompress the data and present it as utf8. No problems there, but with the recent move to the InnoDB Plugin 1.0 in MySQL 5.1 there was an opportunity to push that down the stack.

I ran a few benchmarks and it turned out that using 8K pages was the optimal trade-off between space and time. Using 16K pages did not compress the data very well, and using pages smaller than 8K increased the time needed to store the data. I should note that 8K is also the default.

There are some interesting wrinkles in all this, innodb_file_per_table needs to be enabled and I think the innodb_file_format needs to be set to ‘barracuda’ thought I am not sure about that.

Number Encoding II

Posted in Scaling, Search, Software Development by François Schiettecatte on October 16, 2009

To conclude my little foray into number encoding (see the presentation by Jeffrey Dean from Google titled “Challenges in Building Large-Scale Information Retrieval Systems” (video, slides)), here are a few conclusions:

  • In terms of raw performance the “Varint Encoding” is much faster than “Byte-Aligned Variable-length Encodings” and I was able to get better numbers than Google got, most likely because I am using a different machine. It would be interesting to know what kind of machine/OS they used for their timings so I could do a direct comparison. My lookup array structure is different (and more compact) than Google’s, assuming I understood Google’s lookup array structure in the presentation.
  • The “Byte-Aligned Variable-length Encodings” is faster if you are storing three numbers per posting, namely a document ID, a term position and a field ID. The “Group Varint Encoding” is faster if you are storing four number per posting, namely a document ID, a term position, a field ID and a weight.
  • As I described in the last comment in the original post, two bits are used in the header for each varint to indicate its size in bytes, so 0, 1, 2 or 3 indicate whether your varint is 1, 2, 3 or 4 bytes long respectively. However if you store deltas a lot of the numbers you store will be 0, using a byte to store 0 seems wasteful to me. So I changed this so that the two bits indicate the actual number of bytes in the varint, and 0 bytes means 0. This way I don’t actually allocate space unless there is a value other than 0 to store. This saves about 10% in my overall index size, and a lot more if you only take the term postings into account because I store some amount of document metadata in my index. Of course this means that you can’t store a number greater than 16,777,216 which won’t happen unless you are creating huge indices with more than 16,777,216 documents in them or have documents longer that 16,777,216 terms.

Basically it comes down to trade-offs, index compactness vs. decode speed, and looking at speed both in test code (usually a contrived example) and performance on a real data set. I used the Wikipedia data for that along with 200 relatively complex searches designed to read lots of postings lists.

Danger Danger

Posted in General, Scaling, Software Development by François Schiettecatte on October 13, 2009

Plenty has been written about the Danger data loss over the weekend (TechCrunch). For me the most interesting commentary came from John C. Dvorak, he got some things right but he also got some things wrong:

Over the past week, users of the T-Mobile Sidekick platform found that all their contacts and other important information was permanently lost, because of server mishaps. If Microsoft had wanted to throw a monkey wrench into cloud computing, it could not have done a better job.

Huh, don’t think so, this was a data loss screw-up, nothing to do with the cloud. If what we are reading is to be believed, a SAN upgrade went wrong and the data was lost, with no backup.

Insert Ellen Feiss ad here…

Seriously though backups are essential because things will go wrong. Note that I use ‘will’ and not ‘may’, and these may or may not be under our control.

The other things I used to tell clients is to do a fire drill on a regular basis, by that I mean taking the backups and making sure they can be restored properly and completely. I had one client who discovered that all their backups were useless when they checked.

Number Encoding

Posted in Scaling, Search, Software Development by François Schiettecatte on September 29, 2009

A while back I came across this very interesting presentation by Jeffrey Dean from Google titled “Challenges in Building Large-Scale Information Retrieval Systems” (video, slides) where he talks about the various challenges that Google ran into over time as they scaled up and how they solved them.

This abstract sets the stage pretty well

Building and operating large-scale information retrieval systems used by hundreds of millions of people around the world provides a number of interesting challenges. Designing such systems requires making complex design tradeoffs in a number of dimensions, including (a) the number of user queries that must be handled per second and the response latency to these requests, (b) the number and size of various corpora that are searched, (c) the latency and frequency with which documents are updated or added to the corpora, and (d) the quality and cost of the ranking algorithms that are used for retrieval.

In this talk I’ll discuss the evolution of Google’s hardware infrastructure and information retrieval systems and some of the design challenges that arise from ever-increasing demands in all of these dimensions. I’ll also describe how we use various pieces of distributed systems infrastructure when building these retrieval systems.

Finally, I’ll describe some future challenges and open research problems in this area.

What particularly appealed to my (gnarly) mind were the various encoding algorithms they tried to encode numbers in their index (pages 54 to 63 of the slides).

Having written a search engine I was particularly interested in how they approached that. I actually settled for what they call “Byte-Aligned Variable-length Encodings” (slide 56) ten years ago having done a bunch of benchmarking (which I repeated every few years to see how well it fared on newer generations of processors.) The encoding is very compact and does very well when you have powerful CPUs and weak IO. I did some revisions over time in the C code which drives it to steer the optimizer, but it has held up well. I used this encoding for the Feedster search engine. As an aside one of the pluses of this encoding is that it is endian independent.

So I was very interested by the “Group Varint Encoding” (slide 63) specifically the claim that the decode time was faster.

Google was able to achieve a decode speed of ~180M numbers/second for the Byte-Aligned Variable-length Encodings and ~400M numbers/second for the Group Varint Encoding.

So I set out to replicate the results and ran into some interesting things.

The machines used for this are an Intel DX58SO motherboard with a Core i7 920 CPU, 2.66GHz, 6GB of RAM, Fedora 11, gcc 4.1.1, and a Mac Pro with 2 Dual Core Xeons, 2.66GHz, 13GB of RAM, Mac OS X 10.5.8, gcc 4.2.1.

The test code is pretty simple, one test writes and reads number from the same area of memory and the second test writes and reads a sequence of numbers over 1GB of memory. I added in verification code to check that the number read was the same as the number written to simulate some in between reading the data.

My results for Byte-Aligned Variable-length Encodings were better, I was able to get ~226M numbers/second on the DX58SO and ~190M numbers/second on the Mac Pro. Removing the verification code I was able to get ~426M and ~405M numbers/second respectively.

And the results for the Group Varint Encoding were much better, I was able to get ~680M numbers/second on the DX58SO and ~500M numbers/second on the Mac Pro. Removing the verification code made reading pretty much instantaneous (less than 1 microsecond to read 4.8B numbers.)

UPDATED October 9th, 2009 – Obviously my own BS meter was off when I wrote that last paragraphs, as I point out in the comments, the optimizer was doing away with most of the code because the results were not used. Preventing it from doing that gave me the same results as the ones I got with the verification code in place and was certainly not instantaneous.

Boston MySQL User Group Meeting Videos

Posted in Software Development by François Schiettecatte on August 3, 2009

There is a MySQL User Group in the Boston area, which I keep meaning to attend but never get to go because of time pressures. So I was happy to see that they are making meeting videos available on YouTube.

CloudCamp Boston – July 29th, 2009

Posted in Scaling, Software Development by François Schiettecatte on July 12, 2009

CloudCamp Boston will be held on July 29th, 2009.

From the conference web site:

CloudCamp is an unconference where early adopters of Cloud Computing technologies exchange ideas. With the rapid change occurring in the industry, we need a place we can meet to share our experiences, challenges and solutions. At CloudCamp, you are encouraged you to share your thoughts in several open discussions, as we strive for the advancement of Cloud Computing. End users, IT professionals and vendors are all encouraged to participate.

I will be attending.

Unix Toolbox

Posted in General, Software Development by François Schiettecatte on July 12, 2009

A friend pointed me to this very useful list of Unix/Linux/BSD commands, worth taking a look at and bookmarking.

Update on CentOS 5.3

Posted in General, Software Development by François Schiettecatte on July 12, 2009

I tried my best with CentOS 5.3 but it had a serious problem on my core i7 motherboard, for some reason everything was running about half as fast as it should have been, cpu bound application were spending a lot more time than they should have been in system land. I was getting better performance running under VMware on my MacPro!

I posted a questions to the CentOS forums and, getting no answer after 24 hours, decided to install Fedora 11, which seems to work well so far. The 150+ updates which are installed on top of a fresh install are hardly inspiring given that Fedora 11 came out barely 3 weeks ago, but everything seems to be ok so far.

Except for two drives failures in quick succession, same model and same amount of run time, both ran out of spare sectors within days if each other.