-
Notifications
You must be signed in to change notification settings - Fork 183
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
Allow ULEs to be bit-packed rather than byte-packed #1487
Comments
I'm fine with a new type, strongly against making this change to ZeroVec itself since it would trade off performance for size in a much stronger way. We could even make this work in ZeroMap by introducing a Packed wrapper type (i.e. To me, the primary value proposition of ZeroVec is zero-copy deserialization, efficient encoding is nice to have but if we're trading off performance for it I'd prefer not to. It's going to be tricky to implement; I suspect what we'll need to do is:
|
I agree with this. |
As part of the work on this issue, the performance impact of bitpacking should be measured, and weighed against the resulting impact on data size. |
As a step in this direction, we could add a byte-sized type that is valid for only certain bits, which could be composed into a ULE type, such that the only manual impl required for bit-packing is a (safe) AsULE impl. I think the |
I think we should pull this back up and discuss it in the context of zerovec 1.0 and the holistic design. |
I kind of feel like this would probably be a third trait PackedULE and BitPackedZeroVec, I have a hard time seeing how this can work within ZeroVec without a tradeoff |
Currently, all ULE values are aligned to a byte boundary. We should consider making them aligned to a bit boundary instead.
This would solve two problems:
Script
requires 10 bits, which means it needs to use a 16-bit unit, wasting 37% of space. (Restrict Script (and ScriptWithExt) to specific range #1404)#[derive(ULE)]
to efficiently pack a struct containing many small fields. (Proc macros for AsULE and AsVarULE #1079)There are crates like bitpacking which may provide some prior art. However, I believe that our bitpacking can be less sophisticated, since ZeroVec already returns stack copies of elements in the array.
This may be suited to be a new type, like
ZeroVecPacked
, rather than re-writing the current class, which is optimized for its current byte-aligned use case.CC @Manishearth
The text was updated successfully, but these errors were encountered: