Skip to content
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

internal/arenaskl: batch allocate nodes #3097

Open
jbowens opened this issue Nov 22, 2023 · 0 comments
Open

internal/arenaskl: batch allocate nodes #3097

jbowens opened this issue Nov 22, 2023 · 0 comments

Comments

@jbowens
Copy link
Collaborator

jbowens commented Nov 22, 2023

While applying a batch to the memtable, we iterate over the batch and one-by-one we allocate memory for each individual KV pair's node in the memtable. Each individual KV performs an atomic load and an atomic increment. Allocating a contiguous swath of memory from the arena all at once may reduce the overhead of batch application. If KVs within a batch are more likely to be proximate to each other than to KVs being committed by other batches (almost certainly), this would also improve read-time cpu cache locality by avoiding interleaving KVs from separate concurrently-applied batches.

The amount of memory required for a node is a function of the size of the key, the size of the value, and the height of the skiplist node. The height of the skiplist node is random and not a function of the existing skiplist at all. It could be decided ahead of time before even entering the commit pipeline, but then we'd need a place to remember it. We could conceivably steal 5 bits from the trailer somewhere (20 is the max node height; ⌈log2(20)⌉ = 5) but that sounds delicate. Or, we could avoid explicitly deciding each individual KV's node's height pre-application, and instead accumulate an aggregate height of all nodes in the batch. Then, at batch application time, we'd need to randomly distribute the aggregate height to individual KVs. (This could use some thought.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Storage
  
Backlog
Development

No branches or pull requests

1 participant