Use shared buffers for transferring keys and values for fast get/getSync #294
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
According to the benchmarks, this improves the performance of
getSynccalls by about 2x andgetcalls by about 2.5x (at least in the common case of cached values).With
getSync, the breakdown of time spent is now about 420ns spent on the RocksDB side, and 240ns spent in this library (bindings and JS). Since it was about twice as slow before, I think it was previously spending about 800ns in this library, so really the performance gain on this side is 3-4x (and even more withget). At this point, RocksDB is dominating the time spent, so this puts us in a good position. This still isn't as fast as LMDB. However, once we get a better cache layer implemented, we might be competitive.This also fixes an issue with tracking the key in the
AsyncGetState. Previously this was held by a RocksDBSlice, which does not copy or own the target reference, and so it could change before the async task was called. The key is now safely copied into astd::string. The concurrent get test I added fails on main due to this problem, but is corrected in this branch.