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

Store only 7 bytes instead of 8 #3

Open
jplatte opened this issue Jun 19, 2019 · 1 comment
Open

Store only 7 bytes instead of 8 #3

jplatte opened this issue Jun 19, 2019 · 1 comment
Labels
experimentation Something to experiment with

Comments

@jplatte
Copy link
Member

jplatte commented Jun 19, 2019

We theoretically have 54 bits of information in Int and 53 bits in UInt. Because it is much simpler to just wrap an existing numeric type, we currently use 8 bytes (64 bits) to store this data, even though 7 bytes (56 bits) would be sufficient. Implementing 7-byte storage would certainly complicate the code quite a bit and potentially affect performance negatively. I could imagine developing it out under a feature flag though. If we have benchmarks until then (#4), that would be very useful.

@jplatte jplatte added the experimentation Something to experiment with label Jul 8, 2019
@FSMaxB
Copy link
Contributor

FSMaxB commented Nov 10, 2021

This could actually save more space than one would initially expect, because it leaves one byte free for booleans or enum tags (think Option) without exceeding the required memory alignment of 8. This would therefore reduce the required memory for Vec<Option<Int>> by half for example.

But I agree that this has much potential to slow things down and should definitely be benchmarked.

(Also it needs to be considered if the alignment should still be 8 or 1 instead, since it probably needs to be copied to a register anyways)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
experimentation Something to experiment with
Development

No branches or pull requests

2 participants