Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Shard verifySig cache to reduce mutex contention.#5286

Open
dmkozh wants to merge 1 commit into
stellar:master from
dmkozh:sig_cache_opt
Open

Shard verifySig cache to reduce mutex contention. #5286
dmkozh wants to merge 1 commit into
stellar:master from
dmkozh:sig_cache_opt

Conversation

@dmkozh

@dmkozh dmkozh commented May 21, 2026

Copy link
Copy Markdown
Contributor

Description

Replace the single global mutex + RandomEvictionCache with 16 sharded caches (each with its own mutex) so concurrent signature verification threads no longer block on a shared lock.

Also use the single-lookup maybeGet() in place of the exists()/get() double-lookup and use Rust verification unconditionally (an overdue cleanup).

Checklist

  • Reviewed the contributing document
  • Rebased on top of master (no merge commits)
  • Ran clang-format v8.0.0 (via make format or the Visual Studio extension)
  • Compiles
  • Ran all tests
  • If change impacts performance, include supporting evidence per the performance document

Replace the single global mutex + RandomEvictionCache with 16 sharded caches (each with its own mutex) so concurrent signature verification threads no longer block on a shared lock.
Also use the single-lookup maybeGet() in place of the exists()/get() double-lookup and use Rust verification unconditionally.
Copilot AI review requested due to automatic review settings May 21, 2026 23:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR reduces lock contention in the global Ed25519 signature-verification result cache by sharding it into multiple independently-locked caches, improving throughput when signature verification occurs concurrently across threads. It also removes the protocol-gated switch to Rust ed25519-dalek verification and uses the Rust verifier unconditionally.

Changes:

  • Replace the single global RandomEvictionCache + mutex with 16 sharded caches (one mutex per shard).
  • Switch cache lookups from exists()/get() to maybeGet() to avoid a double hash-table lookup on hits.
  • Remove the protocol-version-triggered enableRustDalekVerify() mechanism and always verify via the Rust dalek bridge.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/main/ApplicationImpl.cpp Removes protocol-version-based enablement of Rust dalek verification during startup.
src/ledger/LedgerManagerImpl.cpp Removes protocol-version-based enablement of Rust dalek verification when setting LCL.
src/herder/Upgrades.cpp Removes Rust dalek enablement at the protocol version upgrade boundary.
src/crypto/test/CryptoTests.cpp Removes explicit test-time enabling of Rust dalek verification.
src/crypto/SecretKey.h Removes the enableRustDalekVerify() declaration and related comments.
src/crypto/SecretKey.cpp Implements sharded verifySig cache, atomic hit/miss counters, and unconditional Rust dalek verification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot Copilot left review comments

@marta-lokhova marta-lokhova Awaiting requested review from marta-lokhova

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

AltStyle によって変換されたページ (->オリジナル) /