Skip to content

flatkv cache#3027

Draft
cody-littley wants to merge 55 commits intomainfrom
cjl/flatkv-cache
Draft

flatkv cache#3027
cody-littley wants to merge 55 commits intomainfrom
cjl/flatkv-cache

Conversation

@cody-littley
Copy link
Contributor

@cody-littley cody-littley commented Mar 5, 2026

Describe your changes and provide context

Add a caching layer to FlatKV, more than doubling performance in cryptosim benchmarks.

Testing performed to validate your change

Unit tests, ran benchmark over several days.

@github-actions
Copy link

github-actions bot commented Mar 5, 2026

The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedMar 11, 2026, 4:03 PM

@codecov
Copy link

codecov bot commented Mar 6, 2026

Codecov Report

❌ Patch coverage is 80.71121% with 179 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.09%. Comparing base (2bb2537) to head (c3f34b1).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
sei-db/state_db/sc/flatkv/store_write.go 66.43% 28 Missing and 21 partials ⚠️
sei-db/state_db/sc/flatkv/config.go 62.71% 11 Missing and 11 partials ⚠️
sei-db/db_engine/pebbledb/db.go 71.21% 11 Missing and 8 partials ⚠️
sei-db/db_engine/pebbledb/pebblecache/shard.go 91.66% 15 Missing and 3 partials ⚠️
sei-db/state_db/sc/flatkv/store.go 65.38% 9 Missing and 9 partials ⚠️
sei-db/db_engine/pebbledb/pebble_metrics.go 0.00% 10 Missing ⚠️
sei-db/db_engine/pebbledb/pebbledb_config.go 47.36% 5 Missing and 5 partials ⚠️
...db/db_engine/pebbledb/pebblecache/cache_metrics.go 85.48% 8 Missing and 1 partial ⚠️
sei-db/state_db/sc/composite/store.go 28.57% 5 Missing ⚠️
sei-db/db_engine/pebbledb/batch.go 80.00% 2 Missing and 2 partials ⚠️
... and 6 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3027      +/-   ##
==========================================
- Coverage   58.33%   58.09%   -0.25%     
==========================================
  Files        2079     2094      +15     
  Lines      171885   173991    +2106     
==========================================
+ Hits       100268   101075     +807     
- Misses      62671    63922    +1251     
- Partials     8946     8994      +48     
Flag Coverage Δ
sei-chain-pr 48.78% <80.71%> (?)
sei-db 70.41% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
sei-db/common/metrics/phase_timer.go 74.46% <100.00%> (+0.55%) ⬆️
sei-db/common/threading/adhoc_pool.go 100.00% <100.00%> (ø)
sei-db/common/threading/chan_utils.go 100.00% <100.00%> (ø)
sei-db/config/sc_config.go 100.00% <ø> (ø)
sei-db/db_engine/pebbledb/pebblecache/lru_queue.go 100.00% <100.00%> (ø)
...ei-db/db_engine/pebbledb/pebblecache/noop_cache.go 100.00% <100.00%> (ø)
sei-db/db_engine/pebbledb/pebbledb_test_config.go 100.00% <100.00%> (ø)
sei-db/state_db/sc/flatkv/flatkv_test_config.go 100.00% <100.00%> (ø)
sei-db/state_db/sc/flatkv/snapshot.go 66.95% <100.00%> (+0.39%) ⬆️
sei-db/state_db/sc/flatkv/store_lifecycle.go 57.14% <100.00%> (+0.69%) ⬆️
... and 17 more

... and 27 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.


coreCount := runtime.NumCPU()
readPoolSize := int(cfg.ReaderThreadsPerCore*float64(coreCount) + float64(cfg.ReaderConstantThreadCount))
miscPoolSize := int(cfg.MiscPoolThreadsPerCore*float64(coreCount) + float64(cfg.MiscConstantThreadCount))

Check notice

Code scanning / CodeQL

Floating point arithmetic Note

Floating point arithmetic operations are not associative and a possible source of non-determinism

coreCount := runtime.NumCPU()
readPoolSize := int(cfg.ReaderThreadsPerCore*float64(coreCount) + float64(cfg.ReaderConstantThreadCount))
miscPoolSize := int(cfg.MiscPoolThreadsPerCore*float64(coreCount) + float64(cfg.MiscConstantThreadCount))

Check notice

Code scanning / CodeQL

Floating point arithmetic Note

Floating point arithmetic operations are not associative and a possible source of non-determinism
ctx, cancel := context.WithCancel(ctx)

coreCount := runtime.NumCPU()
readPoolSize := int(cfg.ReaderThreadsPerCore*float64(coreCount) + float64(cfg.ReaderConstantThreadCount))

Check notice

Code scanning / CodeQL

Floating point arithmetic Note

Floating point arithmetic operations are not associative and a possible source of non-determinism
ctx, cancel := context.WithCancel(ctx)

coreCount := runtime.NumCPU()
readPoolSize := int(cfg.ReaderThreadsPerCore*float64(coreCount) + float64(cfg.ReaderConstantThreadCount))

Check notice

Code scanning / CodeQL

Floating point arithmetic Note

Floating point arithmetic operations are not associative and a possible source of non-determinism
"io"
"os"
"path/filepath"
"runtime"

Check notice

Code scanning / CodeQL

Sensitive package import Note

Certain system packages contain functions which may be a possible source of non-determinism
valueChan := entry.valueChan
s.lock.Unlock()
s.metrics.reportCacheMisses(1)
startTime := time.Now()

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism
entry.valueChan = valueChan
s.lock.Unlock()
s.metrics.reportCacheMisses(1)
startTime := time.Now()

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism
}

s.metrics.reportCacheMisses(int64(len(pending)))
startTime := time.Now()

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism
}

s.metrics.reportCacheMissLatency(time.Since(startTime))
go s.bulkInjectValues(pending)

Check notice

Code scanning / CodeQL

Spawning a Go routine Note

Spawning a Go routine may be a possible source of non-determinism
missLatency: missLatency,
}

go cm.collectLoop(ctx, scrapeInterval, getSize)

Check notice

Code scanning / CodeQL

Spawning a Go routine Note

Spawning a Go routine may be a possible source of non-determinism
@cody-littley cody-littley marked this pull request as ready for review March 10, 2026 21:11
@cody-littley cody-littley marked this pull request as draft March 11, 2026 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant