Skip to content

std: hash_map: Better handling of no available slots case - #7472

Closed
LemonBoy wants to merge 3 commits into
ziglang:masterfrom
LemonBoy:fix-7468
Closed

LemonBoy wants to merge 3 commits into
ziglang:masterfrom
LemonBoy:fix-7468

Conversation

@LemonBoy

Copy link
Copy Markdown
Contributor

Whenever self.available reaches zero we're not allowed to use free
slots, enforce this constraint while looking for a usable one.

Closes #7468

We need a test case that's independent of the hash function being used, I'll see if I can come up with something nice later.

Whenever self.available reaches zero we're not allowed to use free
slots, enforce this constraint while looking for a usable one.

Closes ziglang#7468
@LemonBoy

Copy link
Copy Markdown
Contributor Author

So... what the fuck is wrong with the Windows CI? Both this and #7447 are failing due to some OOM error that I don't see on master...

Keep scanning the whole set of slots and exit when we've reached the
starting index. At that point if we don't have a free (!isUsed) slot it
means we've overshot the maximum capacity.

Closes ziglang#7494
@Sahnvour

Copy link
Copy Markdown
Contributor

@LemonBoy Please see my answer in #7468 and let me know what you think, I currently think this it not the good way to fix the problem. I don't have time to look at it in depth at the moment however 😦

@LemonBoy

Copy link
Copy Markdown
Contributor Author

Yes, in #7494 I was wondering if this was just be a documentation problem.
TBH the assumeCapacity naming is a bit misleading as there's an hidden dependence on the load factor.

@Vexu Vexu added the standard library This issue involves writing Zig code for the standard library. label Dec 25, 2020
@LemonBoy LemonBoy closed this Dec 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

standard library This issue involves writing Zig code for the standard library.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prevent interleaving calls to HashMap.removeAssertDiscard() / HashMap.putAssumeCapacity() from causing the hashmap to run out of memory

3 participants