-
Notifications
You must be signed in to change notification settings - Fork 48
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
Add test which attempts to encounter a concurrent resize and retrieval #39
Conversation
Of course it decides to not hit the codepath in CI :P. How would you feel about me adding a unit test for the |
A unit test for that would be fantastic! |
I also wonder whether you might be able to trigger more resizes by forcing all the keys into a single bucket like we do here: Lines 88 to 104 in 5fe084b
|
This has the added benefit of avoiding code coverage fluctuating due to non-determinism in the concurrent tests
At least when testing locally, using the one bucket hasher makes the |
This looks great! I do still wish we had a reliable way to check that the |
I would guess the only way to do it reliably is using a tool like loom to test each of the permutations |
I think the strategy I outlined above should actually work pretty reliably, but yes, ultimately we'll want something like loom as well (#34). |
@jhinch would you be interested in also trying to implement the test strategy above? |
Increase the resize capacity to 32768 to increase likelihood of triggering the behaviour
Apologies. I thought your comments were more speculative of how things could be done rather than of something which should be changed as part of this PR. I have switched it over to use |
No worries. It was a bit of a speculative comment :p I think you'll first want to do many many inserts, and then start the thread that does resizing. Otherwise the resizes will all finish very quickly, and you may not even see it. |
amount of work required on each resize
It looks like I've introduced a memory leak in the unit tests I added. I'm working through the problem now. |
Ah, yes, the tests you've written never actually free any of the memory they allocate since you do not create a |
in the entry unit tests to avoid leaking memory
Alright, all tests are passing again and merge conflicts have been resolved |
Great, thanks! |
I noticed that one of the areas of the code which had low test coverage was the BinEntry::Moved branch in node.rs. This test is designed to exercise that codepath. At least on my machine it seems to exercise the codepath but it is non-deterministic whether it will actually encounter the path.