boltdb/bolt — pull request #24 by benbjohnson (2014-02-12 18:38:54+00:00)
Title: Remapping

## Overview

This pull request includes the ability to remap data files when allocating new pages from the end. This differs from LMDB's approach where there is a single fixed limit on the mmap size.

## Pros & Cons

### Contrasting with LMDB's Approach

LMDB's approach works well for the most part in that a user can simply set the mmap size to the size of the hard disk. One issue I ran into with this previously was that I was running many LMDB databases in the same process and setting a high limit for all of them which exhausted the virtual memory space for my process.

### Bolt's Approach

Bolt's approach is to start with a small memory mmap (4MB) and double it whenever the data file exceeds that size. The mmap uses a `sync.RWLock` so remapping can get exclusive access to the map. The downside of this is that it requires waiting for all read transactions to complete before remapping can occur. Bolt is aimed at short read transactions (because of its page reclamation design) so this shouldn't be an issue.

### Summary

I don't think either LMDB or Bolt has a better approach. I think they're just trade offs. Bolt's API aims to be simple and limit the number of configuration parameters but does it at some performance cost.

Feedback welcome.