This repository has been archived by the owner on Mar 9, 2019. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.