db/datastruct/btindex: EF-encode .bt pivot offsets - #21893
Merged
Merged
Conversation
sudeepdino008
force-pushed
the
sudeep/bt-nodeofft-ef
branch
from
June 19, 2026 02:18
d68a2f3 to
fbbde06
Compare
The pivot cache's only per-node heap cost was nodeOfft (a flat []uint64, 8 B/node). The offsets are strictly increasing, so store them Elias-Fano-encoded (~7 bits/node) as the sole representation — no flat array, no toggle. The EF is built at open directly from the existing nodes section; no on-disk format change. decodeNodes (v2 footer) and decodeListNodesV0 (legacy) build it for both layouts, WarmUp for the no-nodes-section path. On commitment 141M keys (M=256): pivot heap 4.35 MB -> 0.46 MB (~9.5x); lookup latency and major-faults/op unchanged.
sudeepdino008
force-pushed
the
sudeep/bt-nodeofft-ef
branch
from
June 19, 2026 03:45
fbbde06 to
af28239
Compare
AskAlexSharov
approved these changes
Jun 19, 2026
Collaborator
|
i guess we can add it to |
Collaborator
|
Member
Author
yeah, cpu will be more because of ef; things i cared about more -- not much effect on majfaults + heap reduction and fast startup. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Stacks on #21875. After that PR, the
.btpivot cache's only per-node heap cost is the offset array — a flat[]uint64(8 B/node). Those offsets are strictly increasing, so this stores them Elias-Fano-encoded (~7 bits/node) as the only representation: no flat array, no toggle.The EF is built at open, directly from the existing nodes section — no on-disk format change, and both layouts are covered (v2 footer and v0 legacy list).
Heap (open pivot cache, commitment, M=256)
[]uint64(before)≈ 6.8 bits/pivot. On a mainnet node the aggregate pivot heap (storage-dominated, ~340 MB after #21875) drops to ~36 MB.
Latency / major-faults (cold = evicted page cache, 15k sampled keys)
Identical fault count, latency within run-to-run noise: the extra
EF.Getcalls in the pivot search are pure CPU and don't register against the ~80 µs/major-fault cost.Tests
Test_BtreeIndex_NodeOfftEF_V0_V2opens both v0 and v2 files and checks every key resolves to its true.kvvalue through the EF-decoded pivots.decodeNodes/decodeListNodesV0unit tests updated for the EF return. Fullbtindexsuite passes.