Skip to content

perf(consensus): grow BLS QC verification LRU cache from 256 to 2048 entries#37

Open
simonzg wants to merge 2 commits into
mainnetfrom
perf/bls-qc-cache
Open

perf(consensus): grow BLS QC verification LRU cache from 256 to 2048 entries#37
simonzg wants to merge 2 commits into
mainnetfrom
perf/bls-qc-cache

Conversation

@simonzg

@simonzg simonzg commented May 1, 2026

Copy link
Copy Markdown
Contributor

Why

ValidateQC is called on every incoming vote and block proposal during HotStuff consensus. It attempts to verify the quorum certificate against up to 5 different BLS committee configurations in sequence — each attempt is a full BLS aggregate signature verification, which involves elliptic-curve pairing operations and is one of the most expensive per-call operations in the node.

The validQCs LRU cache short-circuits all of this on a cache hit, returning immediately. However, at 256 entries the cache is far too small for real workloads:

  • A 100-validator committee producing blocks every 2 seconds generates ~30 unique QCs per minute.
  • During a view change or catch-up, the same QCs are re-presented from multiple peers.
  • At 256 entries, QCs from earlier in the current epoch get evicted and must be re-verified when seen again — paying the full BLS pairing cost each time.

What Changed

lru.New(256)lru.New(2048)

The LRU stores only a string key per entry (no large values). 2048 entries adds negligible memory overhead (< 1 MB) while covering a full epoch's worth of unique QCs without eviction under normal operation.

All existing cache population paths (validQCs.Add) and the cache-hit fast-path (validQCs.Contains) are unchanged — this fix simply makes the cache large enough to be effective.

Expected Impact

  • QCs from the current and recent epochs are served from cache on repeat verification, making those calls essentially free (O(1) hash lookup vs. milliseconds of BLS pairing work).
  • Reduced CPU spikes during view changes and block catch-up when the same QCs arrive from multiple peers.
  • Lower and more consistent block confirmation latency.

simonzg and others added 2 commits July 10, 2025 09:54
ValidateQC is called on every incoming vote and proposal during consensus.
It tries up to 5 BLS committee configurations sequentially, each requiring
a full aggregate signature verification (elliptic-curve pairing operation).

The validQCs LRU cache short-circuits this work on cache hit, but at 256
entries it is far too small: with ~100-validator committees producing a block
every few seconds, an epoch's worth of QCs alone overflows it, causing
repeated re-verification of QCs seen during view changes and catch-up.

Increase to 2048 entries (still < 1 MB overhead) to cover a full epoch
without eviction and eliminate redundant BLS pairings in steady state.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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