-
Notifications
You must be signed in to change notification settings - Fork 587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
walletdb/bdb: attempt to set initial memory map size when opening #697
base: master
Are you sure you want to change the base?
Conversation
b443f89
to
d4264e1
Compare
In this commit, we modify the Create and Open methods for bbolt to accept the bbolt config struct directly. With this change, we don't need to update this file each time we want to expose a new config option for the caller to set.
In this commit, we start to set the initial memory map size when opening the database. This helps with bulk insertions or migrations of the database, as if we set this to a larger value, then bbolt needs to remap less often. Remapping can be memory intensive as it needs to copy over the entire existing database. For 32-bit systems, we take care to clamp this value to ensure we don't exceed the largest addressable memory on such systems.
d4264e1
to
d0cfd37
Compare
// If we're on a 32-bit system, then we'll need to limit this | ||
// value to ensure we don't run into errors down the line. | ||
if !is64Bit { | ||
mmapSize = max32BitMapSize |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we always set this for 32-bit systems, this will fail bc the process may be using other virtual memory. Also the mmap is a contiguous block of vmem, so even if this value is lower, this problem can still occur. Part of the reason why I think 32-bit support should be dropped
if !create { | ||
// The other value that we want to set is the initial memory | ||
// map size. When bolt expands the mmap, it actually copies | ||
// over the entire database. By setting this to a large value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
value larger than zero
In this commit, we start to set the initial memory map size when opening
the database. This helps with bulk insertions or migrations of the
database, as if we set this to a larger value, then bbolt needs to remap
less often. Remapping can be memory intensive as it needs to copy over
the entire existing database.
For 32-bit systems, we take care to clamp this value to ensure we don't
exceed the largest addressable memory on such systems.
In PR commit, also we modify the Create and Open methods for bbolt to
accept the bbolt config struct directly. With this change, we don't need
to update this file each time we want to expose a new config option for
the caller to set.