Fix hash @indices can grow larger than Int32::MAX bytes#15347
Conversation
fixes crystal-lang#15341 Co-authored-by: Johannes Müller <straightshoota@gmail.com>
|
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 |
@indices can grow larger than Int32::MAX bytes@indices can grow larger than Int32::MAX bytes
fixes #15341
See #15341 (comment) for details.