-
Notifications
You must be signed in to change notification settings - Fork 702
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
Follow-up of #1502: Embed field and value in hashTypeEntry #1551
Comments
Overall I think it would be great to embed the value in the hashEntryType. We had some internal discussion which I would like to bring the main highlights here:
the hashTypeEntry* is just a pointer to the start of the field sds string (like every ordinary sds) lets distinguish between the 2 cases: non embedded entry:
embedded entry: I would suggest that we will decide to embed the value only in case the complete entry size (field sds + value sds) is less than cache line size (eg 64 bytes). we can take this decision during hashTypeCreateEntry, but we might have to revise it every time we change the value (which is a point to consider). I think that given the fact that we set the threashold at 64 bytes we can always ensure the value length is not more than 256 bytes (it would be smaller than 64 bytes) so we can always use sds8 thus simplify the code and reduce the need to maintain a header_size bytes between the field and value.
overall this way we would even reduce the current implementation memory allocation by 6 bytes when embedding the value. small update: in case of conversion from listpack --> hash we currently use hashTypeCurrentObjectNewSds which will not guarantee the field sds will have sds8 header. This will probably have to be handled in some way (eg force sds8 on the field or some other solution) small update 2: the same is also for modules. apparently modules are using createRawStringObject for some reason, which can also produce sds5 type strings. |
When field + value fit within a cache line, embed both of them in the same allocation. We use fewer allocations and save the memory of a pointer we save a memory access when reading the value.
Follow-up of #1502.
The text was updated successfully, but these errors were encountered: