Skip to content

Add BAL-related metrics#9714

Merged
daniellehrner merged 6 commits intohyperledger:mainfrom
mirgee:bal-metrics
Feb 3, 2026
Merged

Add BAL-related metrics#9714
daniellehrner merged 6 commits intohyperledger:mainfrom
mirgee:bal-metrics

Conversation

@mirgee
Copy link
Contributor

@mirgee mirgee commented Jan 30, 2026

Adds some BAL-related metrics inspired by this spec draft.

The draft assumes structured OTEL span instrumentation across the block-processing path, which isn't currently present in Besu (beyond JSON-RPC tracing), so this PR starts with adding lightweight metrics as a first step.

Important part of the BAL-related metrics will be related to prefetching, which will be added in #9656.

Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com>
protocolSpec
.getStateRootCommitterFactory()
.forBlock(protocolContext, blockHeader, blockAccessList);
blockProcessingMetrics.wrapStateRootCommitter(
Copy link
Contributor

Choose a reason for hiding this comment

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

we are only adding BAL metrics. why not having that only for the bal commiter ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This metric is under BLOCK_PROCESSING category. This approach allows for measuring state root computation for any committer. What is the downside? The overhead of starting and stopping a timer is negligible.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

it is more related to the fact that we are calling recordBlockAccessListMetrics in a generic part even if we can be in a fork without BAL. as we have specific path for it i will prefer to call it inside or maybe rename it to recordBlockMetrics and only add bal metrics inside the method when it's available as you are doing now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed the method to take the BAL instead of an optional and moved it so that it's called only when BALs are active.

}

private long encodedSizeBytes(final BlockAccessList bal) {
final Bytes encoded = RLP.encode(out -> BlockAccessListEncoder.encode(bal, out));
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel the metrics will impact performance if we need to encode bal. i will say maybe not adding this one for the moment or find another way

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed this metric. Maybe this can be addressed together with this #9674 (comment)

@matkt
Copy link
Contributor

matkt commented Feb 2, 2026

Some tests are failing

Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com>
Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com>
@mirgee mirgee requested a review from matkt February 2, 2026 15:47
mirgee and others added 3 commits February 3, 2026 11:39
Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com>
Signed-off-by: Karim Taam <karim.t2am@gmail.com>
@daniellehrner daniellehrner merged commit d9cecc3 into hyperledger:main Feb 3, 2026
46 checks passed
macfarla pushed a commit to CPerezz/besu that referenced this pull request Feb 6, 2026
* Add BAL-related metrics

Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com>

* Remove metric measuring size of RLP-encoded BALs

Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com>

* Initialize metricsSystem to NoOpMetricsSystem if null

Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com>

* Record BAL metrics only if BALs are active

Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com>

* fix nullpointer issue

Signed-off-by: Karim Taam <karim.t2am@gmail.com>

---------

Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com>
Signed-off-by: Karim Taam <karim.t2am@gmail.com>
Co-authored-by: Karim Taam <karim.t2am@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants