Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Roasbeef
Copy link
Member

@Roasbeef Roasbeef commented May 4, 2020

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.

@Roasbeef Roasbeef force-pushed the bbolt-mmap-options branch 2 times, most recently from b443f89 to d4264e1 Compare May 4, 2020 23:12
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.
// 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
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

value larger than zero

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants