basho/riak_kv — pull request #451 by jtuple (2012-12-14 19:46:55+00:00)
Title: Change AAE hashtree to buffer and batch write to LevelDB

Change AAE to batch write to LevelDB rather than write hash updates one at a time. While AAE writes are small and asynchronous, having 2x the writes (normal Riak write + AAE write) going into LevelDB has shown to have an impact on Riak throughput. This pull-request has hashtrees buffer writes in memory until there are 200 hash updates, and then send all writes to LevelDB as a single batch write. This has been benchmarked to show a noticeable performance improvement.

In addition to batch writing once every 200 writes, the hashtree will also always flush writes before updating a tree and performing a tree exchange. Thus, AAE semantics are identical between non-batched and batched approach.

If a `riak_kv_index_hashtree` crashes for some reason, and therefore crashes the `hashtree` processes, we may lose the last few writes buffered in RAM. This isn't a problem, as AAE is designed to be lossy anyway, and exchanges with other replicas and/or eventual re-building of the tree will sort things out.

This pull-request also makes the LevelDB options used by AAE configurable, as well as bumps the default write-buffer size from 1 MB to 4 MB.