Skip to content

DSTOR-25768: Btree bulk insert - #928

Open
nnastonen wants to merge 1 commit into
eBay:dev/v8.xfrom
nnastonen:SDSTOR-25768_btree_bulk_insert
Open

nnastonen wants to merge 1 commit into
eBay:dev/v8.xfrom
nnastonen:SDSTOR-25768_btree_bulk_insert

Conversation

@nnastonen

@nnastonen nnastonen commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Add bulk put for sorted discrete key/values to btree

Adds BtreeBulkPutRequest<K, V>, which puts a sorted vector of key/value pairs in one request. Unlike BtreeRangePutRequest, the keys don't have to be contiguous and each key has its own value (for example, scattered LBA → BlkId updates in the LBA tree).

How it works

  • Each pass from the root descends by the current key. The leaf's parent then limits the batch to the entries that fall within that leaf, using its separator key. All of them are put in one step, so the tree is traversed once per leaf touched instead of once per key.
  • When a leaf fills up, or entries remain for other leaves, the leaf step returns 'has_more'. That reuses the existing restart-from-root and split path that range put uses.
  • FixedPrefixNode::bulk_put() lets adjacent entries share a prefix slot (e.g. adjacent LBAs mapped to adjacent blocks), where insert() allocates one prefix per entry. Other node types use a generic VariantNode::bulk_put().

Behaviour

  • Keys must be strictly ascending. This is asserted in debug builds.
  • INSERT on an existing key, UPDATE on a missing key, and 'filter_cb' returning 'keep' skip the entry and count it in num_skipped(); they aren't errors. 'filter_cb' returning 'remove' deletes the existing entry.
  • On a hard error, failed_idx() is the first entry that was not put, and all entries before it are already in the tree.
  • Not atomic across leaves: each leaf is committed separately, the same as range put.

Limitations / follow-ups

  • A prefix slot is shared only with entries from the same call, not with prefixes already in the node.
  • A full prefix node is split rather than compacted, so bulk overwrites can leave free prefix slots unused. Compaction is a planned follow-up (make "has room" count free slots for all puts).

SDSTOR-25768

@nnastonen
nnastonen force-pushed the SDSTOR-25768_btree_bulk_insert branch from 83480d6 to 28bc301 Compare September 29, 2026 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant