Repository navigation
feat(kvdb): add a transient sector read cache for the loading phases - #433
Open
xidongxu-xfaith-tech wants to merge 1 commit into
Open
xidongxu-xfaith-tech wants to merge 1 commit into
xidongxu-xfaith-tech wants to merge 1 commit into
Conversation
xidongxu-xfaith-tech
force-pushed
the
read_cache
branch
from
October 27, 2026 05:20
06ea1aa to
0955f53
Compare
A KV search reads the sector chunk by chunk: walking the KV chain, and searching the used area end. For a 64 KB sector which holds a few KB of data that is thousands of storage reads, and it dominates the time a small database takes to load. This adds an optional read cache above the storage layer: while a scan is running, the sector it reads is copied into RAM once and every later read of that sector is served from there. It is invalidated before any write or erase of the sector, so it never returns stale data. The cache is borrowed, not owned. It is allocated by the first read which needs it and given back when the phase which opened it ends: - fdb_kvdb_init() opens a phase, released when the initialization ends; - fdb_kv_iterate() opens a phase, released when the iteration completes. A single key read or write at run time never allocates it, so a running database keeps no sector sized buffer in RAM. Opt-in, zero behaviour change when FDB_USING_READ_CACHE is 0.
xidongxu-xfaith-tech
force-pushed
the
read_cache
branch
from
October 27, 2026 06:06
0955f53 to
1227fdf
Compare
This branch has not been deployed
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.
A KV search reads the sector chunk by chunk: walking the KV chain, and searching the used area end. For a 64 KB sector which holds a few KB of data that is thousands of storage reads, and it dominates the time a small database takes to load.
This adds an optional read cache above the storage layer: while a scan is running, the sector it reads is copied into RAM once and every later read of that sector is served from there. It is invalidated before any write or erase of the sector, so it never returns stale data.
The cache is borrowed, not owned. It is allocated by the first read which needs it and given back when the phase which opened it ends:
Opt-in, zero behaviour change when FDB_USING_READ_CACHE is 0.