Skip to content

fix(store): improve inner locking#2074

Merged
Mirko-von-Leipzig merged 2 commits into
nextfrom
krisztian/improve-store-inner-lock
May 14, 2026
Merged

fix(store): improve inner locking#2074
Mirko-von-Leipzig merged 2 commits into
nextfrom
krisztian/improve-store-inner-lock

Conversation

@kkovaacs
Copy link
Copy Markdown
Contributor

There were two potential issues with the inner RwLock:

  • get_current_blockchain_data() was holding a read lock while doing an SQLite query
  • sync_notes() was re-acquiring the read lock while iterating over the blocks returned by the SQLite query

Both of these are trivial to fix.

The sync_notes() change has a measurable impact on the sync-notes benchmark of the stress test tool.

Before:

$ target/release/miden-node-stress-test benchmark-store -d /tmp/data --iterations 100000 --concurrency 8 sync-notes

Average request latency: 10.812451ms
P50 request latency: 10.48458ms
P95 request latency: 13.529188ms
P99 request latency: 15.948132ms
P99.9 request latency: 18.202669ms
1163.92user 174.37system 2:48.13elapsed 795%CPU (0avgtext+0avgdata 7712336maxresident)k
0inputs+0outputs (0major+282324minor)pagefaults 0swaps

After:

$ target/release/miden-node-stress-test benchmark-store -d /tmp/data --iterations 100000 --concurrency 8 sync-notes

Average request latency: 10.448098ms
P50 request latency: 10.084526ms
P95 request latency: 13.177924ms
P99 request latency: 15.408491ms
P99.9 request latency: 17.614128ms
856.57user 153.57system 2:11.52elapsed 768%CPU (0avgtext+0avgdata 2206476maxresident)k
0inputs+0outputs (0major+26126minor)pagefaults 0swaps

@kkovaacs kkovaacs added the no changelog This PR does not require an entry in the `CHANGELOG.md` file label May 13, 2026
Copy link
Copy Markdown
Collaborator

@Mirko-von-Leipzig Mirko-von-Leipzig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I think this further highlights that we really want a snapshot based system where these locks are impossible to misuse on accident.

@Mirko-von-Leipzig Mirko-von-Leipzig merged commit 680127b into next May 14, 2026
20 checks passed
@Mirko-von-Leipzig Mirko-von-Leipzig deleted the krisztian/improve-store-inner-lock branch May 14, 2026 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no changelog This PR does not require an entry in the `CHANGELOG.md` file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants