rvagg/node-levelup — pull request #41 by rvagg (2012-12-16 03:38:25+00:00)
Title: 0.4.0 branch tracking

This is the work I've been doing for a 0.4.0 release. A ton of stuff in here but there are two major themes:

* Upgrade to LevelDB 1.7.0, more painless than I thought, there aren't too many changes in the codebase. I've also cleaned up the GYP build process a bit more and removed warnings (at least in some OSs).
* Performance: Leveled provides a good base for measuring performance because it's so minimal and raw. I've integrated it into my benchmark suite; and basically rewritten the suite so I can plug in other 'engines'. At the moment it can run LevelUP, LevelUP (release) (i.e. from npm), LevelUP (no compression) and Leveled. I also need to add a node-sqlite benchmark to see how we're going against the major alternative to LevelDB.

I've managed to dramatically increase performance in this code by avoiding `Buffer`s where they aren't required and just passing down `String`s; this avoids an extra copy of the string data and gives a major boost. I'm also doing the same on the way back out of the native layer. It's amazing the difference it makes. I've also done a bunch of tweaking on the JS side to find some more speed boosts.

Going forward, probably the main source of performance improvement would be moving more of the work done in the JS layer down into the native. From the beginning one of the core goals of LevelUP is safety, **it must not kill your current process**, so I opted for exposing none of the native binding directly and wrapped it around a largish JS layer. As the test suite is bulked up and I become a bit more comfortable with the quality of the C++ code I think we can move more stuff down in to those dungeons.