acrosa/kafka-rb — pull request #7 by iconara (2012-05-07 14:49:56+00:00)
Title: Optimized message decoding

This patch roughly halves the time spent decoding messages. Instead of doing three #unpack calls it does just one, and the format string is now a constant.

Obviously this doesn't double the consumer performance, there's a lot of other overhead in just moving the bits around, but it's something.

There's a lot of string literals that could be moved into constants in the rest of the code, I think there's a potential for getting at least a 10% speed increase in just fixing that. Code that runs thousands of times per second should not use literal strings, they create way too much garbage (remember that in Ruby a literal string always creates a new object since strings are mutable -- this is a huge performance hog, especially in MRI). If you want I can send a patch for that too.