perf(consensus): grow BLS QC verification LRU cache from 256 to 2048 entries#37
Open
simonzg wants to merge 2 commits into
Open
perf(consensus): grow BLS QC verification LRU cache from 256 to 2048 entries#37simonzg wants to merge 2 commits into
simonzg wants to merge 2 commits into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
ValidateQCis 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
validQCsLRU 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: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