-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fix: Hash @indices
can grow larger than Int32::MAX bytes
#15347
Fix: Hash @indices
can grow larger than Int32::MAX bytes
#15347
Conversation
fixes crystal-lang#15341 Co-authored-by: Johannes Müller <[email protected]>
We should add a spec for this. Something like |
Oh, |
The spec is painfully slow, wasting over 9s to allocate & initialize the memory 😕
The overall std spec runtime is 45s on my computer. Adding 9s has a +20% impact 😰 |
It does allocate too much memory, which breaks on CI, is definitely too large on 32-bit targets, and is far too slow overall, even on fast hardware.
Ouch that's a lot 🙈 Of course, we're trying to allocate 10GB total (8 for the indices, 2 for the entries). What if we try to allocate just |
Where are the manual specs 🔍 |
That's exactly what I meant with "it'll almost never be tested" 😆 👉 https://github.com/crystal-lang/crystal/tree/master/spec/manual |
It actually allocates even more memory than that. With
With
In fact I wonder if the indices are worth taking so much memory. |
Oh, right. It's Yeah that's quite a lot for huge collections. Probably quite a lot for smaller ones, too? |
Argh, I got the megabytes wrong for |
One thing is quite certain then: It's pretty hard to understand the code and reason about the allocations 🙈 |
This pull request has been mentioned on Crystal Forum. There might be relevant details there: https://forum.crystal-lang.org/t/goldbachs-conjecture-and-crystal-code/7579/27 |
fixes #15341
See #15341 (comment) for details.