Skip to content

fix(hashmap): size the rebuild by live entries so churn does not grow capacity - #3767

Merged
BaseMax merged 2 commits into
mainfrom
fix/hashmap-tombstones
Nov 21, 2026
Merged

BaseMax merged 2 commits into
mainfrom
fix/hashmap-tombstones

Conversation

@BaseMax

@BaseMax BaseMax commented Nov 21, 2026

Copy link
Copy Markdown
Member

Remove leaves a tombstone and Put always doubled the table when used hit the load limit, so insert/remove churn grew capacity without bound (2,000,000 Put/Remove pairs left 0 live entries in 2,097,152 slots).

The rebuild now picks the smallest power-of-two capacity for the live count (same as doubling when nothing was removed, same size or smaller when mostly tombstones). Amortised cost stays O(1).

Test: tests/en/stdlib/hashmap_tombstone_churn (churn then bounded capacity and correct contents); existing hashmap tests unchanged.

… capacity

Remove leaves tombstones and Put always doubled, so insert/remove churn grew the table without bound. Rebuild now picks the capacity from the live count.
@BaseMax
BaseMax requested a review from a team as a code owner November 21, 2026 15:58
@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@BaseMax
BaseMax merged commit fb15803 into main Nov 21, 2026
6 checks passed
@BaseMax
BaseMax deleted the fix/hashmap-tombstones branch November 21, 2026 17:08
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.

1 participant