Lessons learnt from trying to contribute to redis.

These are the lessons i learnt from trying to add bloom filter as a data type to redis(See here). Given i had no experience with C outside lab/training classes, it was an immense learning experience.

1.It’s always worth the time taken to sit down and understand the interface to be provided, even if you are only porting existing code.
2.Time invested understanding the structure/architecture of the target app codebase, is time saved, and more importantly frustration saved.
3. I now understand why so much of C code has the opening { brackets right at the function declaration and not a newline.
Because of cscope. it displays the line where it found the function.
Even though you don’t need it to distinguish function declaration vs call, it is easier.

4.GDB is a very useful and handy tool, but if you compile by default(i.e: simple make. ) Usually that is configured to optimize the code.
that implies, you can’t print out and see values of intermediate variables in your code. That is a important tool while debugging imperative code.
Corollary: Purely Functional Languages need advanced type checking and type errors, to speed up the debug,change code,compile,test,debug cycle.
Else one’s constrained by the brainspace he can devote to keeping track of functions and their operations/expressions

5.Once you master the tools(editor+cscope/similar tools) the challenge of fixing syntax errors, function mismatch etc are trivial.
i.e: compared to the meaty core challenge of merging the logical flow(function call stack) of the original program with the retrofitted/backported program.

6.Man vim quitting and closing just to use cscope is a pain.i want to search and get a function in a diff file, while am in a diff file where it’s called.
Basically, a keystroke to open the file(in a vsplit) where the function at current cursor is defined. am sure there’s a plugin.

7. By simple base rate, if there’s segmentation fault(while on linux compiling with gcc), then it’s a dangling pointer or null-pointer access.
go check your pointers track them and fix them.

8.While gdb is awesome in general, the gcc -O0 option is not effective on library files and other make dependencies Phew. but in some cases it’s alright.

UPDATE: Here’s a successful running code I contributed to redis. https://github.com/antirez/redis/pull/2058.


3 thoughts on “Lessons learnt from trying to contribute to redis.

  1. Why would use, Bloom filters on top of an in memory database. I would rather prefer consistent hashing as feature on top of Redis based cluster? If this is just to learn Redis/C depths I am sorry for this comment.


    1. Perhaps, it doesn’t make a lot of sense to add bloom filter to in-memory database. For me this is just a C-project to get some hands-on knowledge.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s