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

Resize with a more conservative amount of space after deletions #86

Merged
merged 1 commit into from Jun 6, 2019

Conversation

edre
Copy link
Contributor

@edre edre commented Jun 4, 2019

Otherwise we can force a rehash for each insert and removal if we're right under the size limit.

Benchmark with SIZE=895, just under a rehash limit.
name oops ns/iter okthen ns/iter diff ns/iter diff % speedup
insert_erase_std_serial 9,875,585 60,696 -9,814,889 -99.39% x 162.71

Fixes #85

@Amanieu
Copy link
Member

Amanieu commented Jun 5, 2019

I think a better solution would be to change the else clause to

self.resize(usize::max(new_size, full_capacity + 1), hasher, fallability)

This ensures that we always increase the table size if we are resizing.

Also the condition should probably be changed from < to <= to match the original C++ version.

…deletions.

Otherwise we can force a rehash for each insert and removal if we're right under the size limit.

Benchmark with SIZE=895, just under a rehash limit.
    name                     oops ns/iter  okthen ns/iter  diff ns/iter   diff %   speedup
    insert_erase_std_serial  9,875,585     60,696            -9,814,889  -99.39%  x 162.71

Fixes rust-lang#85
@Amanieu
Copy link
Member

Amanieu commented Jun 6, 2019

@bors r+

@bors
Copy link
Collaborator

bors commented Jun 6, 2019

📌 Commit afc20d7 has been approved by Amanieu

bors added a commit that referenced this pull request Jun 6, 2019
Resize with a more conservative amount of space after deletions

Otherwise we can force a rehash for each insert and removal if we're right under the size limit.

Benchmark with SIZE=895, just under a rehash limit.
    name                     oops ns/iter  okthen ns/iter  diff ns/iter   diff %   speedup
    insert_erase_std_serial  9,875,585     60,696            -9,814,889  -99.39%  x 162.71

Fixes #85
@bors
Copy link
Collaborator

bors commented Jun 6, 2019

⌛ Testing commit afc20d7 with merge b240ee0...

@bors
Copy link
Collaborator

bors commented Jun 6, 2019

☀️ Test successful - checks-travis
Approved by: Amanieu
Pushing b240ee0 to master...

@bors bors merged commit afc20d7 into rust-lang:master Jun 6, 2019
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.

Frequent rehashes when size is close to capacity
3 participants