-
Notifications
You must be signed in to change notification settings - Fork 175
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
Consider FlexZeroVec #1443
Comments
Hmm, what do you think about making |
This seems interesting. Do we have any vectors that are both large enough and heterogenous enough that this would be worth it? CPT comes to mind but I suspect this isn't that heterogenous. |
huh, that's interesting. Yeah that would work! |
The main initial use case I had in mind was the index portion of the VZV buffer. We can cast that section of the buffer to a FlexZeroSlice. Also, in ZeroMap2k, the |
Ah! Well, we should probably add that as an internal abstraction and then consider making it public (the way we did with SliceComponents -> VZVBorrowed) |
Since d90dbf9 added 10% to the postcard data size, I wanted to drill down and see where the impact came from. I split out the postcard data into individual files (#1606) and then compared the resource Size differences:
I show gzip to demonstrate that the new postcard files are larger even when compressed. I should note that the difference is smaller as a percentage on the full postcard file. Looking inside the file, here's what I see. Old, first 40 bytes:
New, first 16 bytes followed by an excerpt in the middle:
Interpretation:
Discussion: If we were to use FlexZeroVec, we could represent the index array using However, this does raise questions about whether we could use an even more compact encoding for VZV. As an extreme example, we could use Postcard's own representation and pay |
Let's say we want to store the following values in a ZV:
Right now, we store:
We can cut that almost in half by using FlexZeroVec, with one additional read per lookup (the item width):
Here's a hypothetical structure storing derivatives (lengths of individual items) with constant-time lookup and 1-4 extra reads per lookup that supports item widths of up to 255 bytes. To read from this structure, first you read the item width, then you read the first item in the
My conclusion is that we can keep the same VZV structure, and iterate on the representation of |
(discussion continues)
|
We agree on using FlexZeroVec as the only index array type for VarZeroVec. We will start with the "basic" FlexZeroVec where the first byte is the item width. +1 from @iainireland, @Manishearth, @echeran |
In #1410 we've been talking about making the index array flexible in integer length.
Perhaps we should generalize this to be a new type called FlexZeroVec. A FlexZeroVec is a ZeroVec that can only hold unsigned integers, and where the first byte is a marker to signal how many bytes each element in the array consumes. Mutation operations on a FlexZeroVec may result in the bytes being expanded or shrunk.
For example:
Note that we would need both
FlexZeroVec
andFlexZeroSlice
, and also note that, likeVarZeroVec
and unlikeZeroSlice
,FlexZeroSlice
would not support subslices.Open questions:
.get()
function return? It could return ausize
, or it could return au32
, depending on whether we decide to limit the capacity of zerovec structs to 2^32.CC @Manishearth
The text was updated successfully, but these errors were encountered: