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
Add FromUnsafeBytes to prevent small allocations caused by ByteInputAdapter #395
Conversation
Some irrelevant changes are caused by the auto-formatter of my editor.. |
…dapter Signed-off-by: Xiaochao Dong (@damnever) <the.xcdong@gmail.com>
7e0ab72
to
423c967
Compare
Updated benchmark result with damnever@e8266c1:
|
4fd784f
to
41b5bcb
Compare
Signed-off-by: Xiaochao Dong (@damnever) <the.xcdong@gmail.com>
41b5bcb
to
e8266c1
Compare
Signed-off-by: Xiaochao Dong (@damnever) <the.xcdong@gmail.com>
575bebd
to
ba2dbcb
Compare
We can now reuse the underlying slices of Bitmap after Clear, and reuse the sizeBuf as KeyBuf to avoid allocation damnever@ba2dbcb
|
Running tests. |
@damnever If you recommend merging this, then I will do so and issue a release. It seems uncontroversial. |
@lemire Yes, I would say it is safe to merge this since I have experimentally used it in our system. |
We are utilizing the rocksdb merge operator to manipulate values that are encoded by roaring bitmap. The bitmap will be read from disk and merged together, these frequent operations can consume significant CPU resources due to the memory allocations.
So, I am proposing to add an alternative function called FromUnsafeBytes to address this problem. The caller can decide whether to make a copy or reuse those byte buffers if necessary.
The benchmark results (note that I have allocated a large buffer and made a copy before FromUnsafeBytes)