Skip to content

perf(store): hybrid sync.Map + RWMutex in multiversion Store#2836

Merged
pdrobnjak merged 1 commit intoperf/lazy-cachemultistorefrom
perf/hybrid-syncmap-rwmutex
Feb 11, 2026
Merged

perf(store): hybrid sync.Map + RWMutex in multiversion Store#2836
pdrobnjak merged 1 commit intoperf/lazy-cachemultistorefrom
perf/hybrid-syncmap-rwmutex

Conversation

@pdrobnjak
Copy link
Contributor

Summary

  • Replace pure sync.Map with a hybrid sync.Map + RWMutex approach in the multiversion store for better read/write performance

Stack

1/13 — base of the perf stack

🤖 Generated with Claude Code

@github-actions
Copy link

github-actions bot commented Feb 11, 2026

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

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedFeb 11, 2026, 1:20 PM

@codecov
Copy link

codecov bot commented Feb 11, 2026

Codecov Report

❌ Patch coverage is 85.18519% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.26%. Comparing base (bb5063e) to head (f8b8fc9).
⚠️ Report is 3 commits behind head on perf/lazy-cachemultistore.

Files with missing lines Patch % Lines
sei-cosmos/store/multiversion/store.go 85.18% 8 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (bb5063e) and HEAD (f8b8fc9). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (bb5063e) HEAD (f8b8fc9)
sei-tendermint 1 0
Additional details and impacted files

Impacted file tree graph

@@                      Coverage Diff                       @@
##           perf/lazy-cachemultistore    #2836       +/-   ##
==============================================================
- Coverage                      56.78%   46.26%   -10.52%     
==============================================================
  Files                           2070     2005       -65     
  Lines                         168339   163080     -5259     
==============================================================
- Hits                           95586    75445    -20141     
- Misses                         64262    81114    +16852     
+ Partials                        8491     6521     -1970     
Flag Coverage Δ
sei-chain 40.89% <77.77%> (+0.01%) ⬆️
sei-cosmos 48.18% <85.18%> (+0.02%) ⬆️
sei-db 68.72% <ø> (ø)
sei-tendermint ?

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

Files with missing lines Coverage Δ
sei-cosmos/store/multiversion/store.go 90.75% <85.18%> (-0.92%) ⬇️

... and 359 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.

Comment on lines +205 to +207
for index, keys := range s.txWritesetKeys {
writesetKeys[index] = keys
return true
})

}

Check warning

Code scanning / CodeQL

Iteration over map Warning

Iteration over map may be a possible source of non-determinism
Keep sync.Map for multiVersionMap (lock-free reads essential for OCC
workers) while replacing sync.Map with plain map + RWMutex for the
three per-tx-index maps (txWritesetKeys, txReadSets, txIterateSets)
where contention is low (each worker writes to its own index slot).

Eliminates HashTrieMap allocations from per-tx-index maps while
preserving lock-free read performance for the hot multiVersionMap path.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@pdrobnjak pdrobnjak force-pushed the perf/hybrid-syncmap-rwmutex branch from 2b3cec4 to f8b8fc9 Compare February 11, 2026 13:19
@pdrobnjak pdrobnjak force-pushed the perf/replace-syncmap-cachekv branch from 6ab07c6 to bb5063e Compare February 11, 2026 13:19
Base automatically changed from perf/replace-syncmap-cachekv to perf/lazy-cachemultistore February 11, 2026 13:19
@pdrobnjak pdrobnjak merged commit f8b8fc9 into perf/lazy-cachemultistore Feb 11, 2026
2 of 3 checks passed
@pdrobnjak pdrobnjak deleted the perf/hybrid-syncmap-rwmutex branch February 11, 2026 13:19
@pdrobnjak pdrobnjak restored the perf/hybrid-syncmap-rwmutex branch February 11, 2026 13:22
@pdrobnjak
Copy link
Contributor Author

This PR was auto-merged by GitHub during a stack reorder (branch force-push made head appear merged into base). No code was actually merged to main. This PR has been superseded — see the restacked PR chain starting at #2849.

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

Comments