Skip to content

FCR Optimization part1: Speed up fast confirmation with memoization and one-pass chain scoring - #11212

Open
zilm13 wants to merge 5 commits into
Consensys-Incorporated:masterfrom
zilm13:fcr-optimization
Open

FCR Optimization part1: Speed up fast confirmation with memoization and one-pass chain scoring#11212
zilm13 wants to merge 5 commits into
Consensys-Incorporated:masterfrom
zilm13:fcr-optimization

Conversation

@zilm13

@zilm13 zilm13 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

PR Description

Numbers before, Macbook M4 Max, Mainnet:
epoch transition: 18-20 seconds
1 slot: 300-400ms

Numbers after part1:
epoch transition: 2 seconds
1 slot: 300-400ms

First part mainly addresses slow epoch transition when we do several runs on the same block inside calculator.
Speed up fast confirmation with memoization and one-pass chain scoring

Memoize the per-slot calculator queries (slot committees and ranges,
adversarial weight and safety threshold per balance source, current
target score, honest FFG support, equivocator set) and score a whole
chain segment in a single pass over the active validator set instead of
one pass per block. Add a JMH benchmark covering both scoring paths.

Fixed Issue(s)

Documentation

  • I thought about documentation and added the doc-change-required label to this PR if updates are required.

Changelog

  • I thought about adding a changelog entry, and added one if I deemed necessary.

Memoize the per-slot calculator queries (slot committees and ranges,
adversarial weight and safety threshold per balance source, current
target score, honest FFG support, equivocator set) and score a whole
chain segment in a single pass over the active validator set instead of
one pass per block. Add a JMH benchmark covering both scoring paths.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@zilm13 zilm13 changed the title FCR Optimizations FCR Optimization part1 Sep 1, 2026
@zilm13 zilm13 changed the title FCR Optimization part1 FCR Optimization part1: Speed up fast confirmation with memoization and one-pass chain scoring Sep 1, 2026
@zilm13
zilm13 marked this pull request as ready for review September 1, 2026 19:13
Comment on lines 1068 to +1071
int i = index;
while (UInt64.valueOf(i).isGreaterThan(targetSlot)) {
while (UInt64.valueOf(chainSlots.get(i)).isGreaterThan(targetSlot)) {
i--;
if (i < 0) {

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.

we're comparing to uint64, converting etc, im surprised this isn't just using UInt64 as the counter, surely the constant conversion like this s inefficient...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

makes sense, updated 63420ca

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.

2 participants