Redis weekly update #2 - Real world hashes, refactoring, and fixes
Monday, 22 March 10
Hello, welcome to the weekly update #2, this time it shifted to Monday as I used the whole Friday for debugging purposes as you'll read in a minute. So this is what happened in the last week, more or less in chronological order.
Also now the method to compare two Redis objects in hash table lookups is optimized in order to exploit the fact that two objects that are both REDIS_ENCODING_INT can be compared for the o->ptr field directly (as the pointer is instead a long representing the object integer value, casted to a void*). This leads to a major speedups in some Set and Sorted Set operation.
Thanks guys!
See you the next week with the weekly update.
Real world hashes
Hashes were just a shy start the last week, now they are much better:- More commands, now we have HSET,HGET,HDEL,HEXISTS,HKEYS,HVALS,HGETALLL,HLEN
- Tests for all the H-commands, resulting in...
- Many bugs fixed including a memory leak and other bugs in zipmap.c
- Support for Hashes in both Virtual Memory and Append Only File
- Documentation, finally.
Redis-rb hashes and a few other fixes
I find some time in order to hack a bit with Redis-rb and sent a pull request to Ezra that promptly merged the changes. This is what is now fixed:- Support for hashes, and fixed the support for multi-bulk requests
- Support for binary safe keys: Redis.new(:binary_keys => true)
- Now the .keys method will work the same against 1.2.x and 1.3.x
Refactoring and other improvements
I did a pretty big refactoring of redis.c, basically many commands started nesting with a couple of ifs in order to test if the key was actually found, reply with the right object if it was not, checking the type of the object after the lookup and so forth. Pretty lame, now there are helper functions to do this in a much more interesting way.Also now the method to compare two Redis objects in hash table lookups is optimized in order to exploit the fact that two objects that are both REDIS_ENCODING_INT can be compared for the o->ptr field directly (as the pointer is instead a long representing the object integer value, casted to a void*). This leads to a major speedups in some Set and Sorted Set operation.
Debugging
- A problem with VM was fixed, thanks to Tom for giving me access to one of his boxes to inspect a Redis process with gdb. Not sure 100% that what I fixed was the problem I observed, but it's definitely a bug less.
- I and Twidi did some crazy debugging session in order to reproduce a memory growing bug he was experimenting. Finally he found that the problem is related to MULTI/EXEC and I just found he filed this issue, so today I'll use some time in order to check this better trying to fix it. Thanks!
Contributions
The trend continues, even this week I received interesting patches:- Pieter Noordhuis provided an interesting patch in order to generalize the Virtual Memory check for keys that are arguments.
- Got a patch from russryba about redis-cli support for authentication, that I merged after some modification.
- Jeremy Zawodny provided a patch in order to support the include directive in redis.conf
- Alex McHale provided a patch to stop all the Redis madness about parsing integers that are not integers, and similar related issues. That is for instance, you may want Redis to raise an error when you pass an increment that does not look like an integer to the INCR command. I've still to review this patch as it's pretty sensible stuff but I bet I'll merge in a couple of days.
Thanks guys!
Linenoise
Redis-cli needed line editing support. Redis is zero-configuration and I always wondered why there wasn't a simple self-contained, BSD licensed, line editing library now that everybody is using an xterm-capable terminal. Linenoise is the result and just took 2 hours of my weekend. It will be included in Redis in a few days in order to provide out of the box line editing support. I'll try to support a few more Emacs-alike bindings in the future to make it a bit more usable, but I think it's already pretty decent.See you the next week with the weekly update.
Do you like this article?
Subscribe to the RSS feed of this blog or use the newsletter service in order to receive a notification every time there is something of new to read here.
Note: you'll not see this box again if you are a usual reader.
Subscribe to the RSS feed of this blog or use the newsletter service in order to receive a notification every time there is something of new to read here.
Note: you'll not see this box again if you are a usual reader.
Comments
22 Mar 10, 09:13:27
Great stuff - can't wait for hashes in production. Excellent work on linenoise. No scary autoconf junk as well :) Yours is the only C that doesn't scare me.
22 Mar 10, 09:29:10
Already starting support for hashes in redis-node-client, thanks for the great work!
01 Apr 11, 16:57:29
The documentation provided seems to follow perfectly the strategy used by the anti-viruses when they need to keep safe a computer. However, this technique can be used in other fields too.
come on, antirez.
see you next weekly update :)