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

test exceeding and increasing the map size #82

Merged
merged 2 commits into from
Oct 22, 2018

Conversation

mykmelez
Copy link
Contributor

Per the comment from @shivawu in #34 that there should be a way to set an environment's map size, here are tests that demonstrate how to do that.

NB: We should file upstream bugs/PRs in the LMDB crate and C library to fix the code or docs (probably the latter) to agree about the default map size for an LMDB environment.

@mykmelez mykmelez requested a review from rnewman October 19, 2018 00:10
@mykmelez
Copy link
Contributor Author

@rnewman How does this look?

(Perhaps it makes sense to add an Rkv::with_size() constructor function that sets the map size, just as we have Rkv::with_capacity() for setting the database capacity.)

src/env.rs Outdated
builder.set_map_size(1024 * 1024 * 10 /* 10,485,760 bytes, i.e. 10MiB */);
let k = Rkv::from_env(root.path(), builder).unwrap();
let sk: Store = k.open_or_create_default().expect("opened");
let val = "x".repeat(1024 * 1024 /* 1,048,576 bytes, i.e. 1MiB */);
Copy link
Contributor

Choose a reason for hiding this comment

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

You should make sure that this test and the one above use the same value or size (maybe fn get_larger_than_default_map_size_value()), and are thus related more closely. Consider a year from now when the default bumps to 2MB, and/or set_map_size accrues a bug. The first test will break, and this one will not, because this value is now smaller than the limit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, I've refactored references to the default map size into a get_larger_than_default_map_size_value() function that both tests use to determine a value slightly larger than the default map size.

This refactors determination of a value larger than the default map size to reduce the risk of tests diverging if the default map size changes in the future.
@mykmelez mykmelez merged commit 92df8d9 into mozilla:master Oct 22, 2018
@mykmelez mykmelez deleted the test-map-size branch October 23, 2018 00:04
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