Commit d77374c
authored
fix(metrics): discard block-processing time for duplicate blocks (#523)
## Problem
`lean_fork_choice_block_processing_time_seconds` is sampled by a
`TimingGuard` created at the top of `on_block_core`, **before** the
idempotent duplicate-block check returns early. A duplicate block does
no processing, so it recorded a near-zero sample that skews the
histogram low. Duplicates are common during range sync, so the effect is
not negligible.
This is the same class of issue as the recently fixed tick-interval
metric (#514): the sample boundary didn't line up with the unit of work
— there it inflated the tail, here it deflates the percentiles.
## Change
- Add `TimingGuard::discard()` to cancel a measurement before the guard
drops (a `disarmed` flag checked in `Drop`).
- Call it on the duplicate-block early return in `on_block_core`.
The block hashing (`hash_tree_root`) stays inside the timed span since
it is real work; only the sample for a no-op duplicate is dropped. All
other early returns (validation rejections) still record, as they
represent real processing time.
## Verification
`make fmt`, `make lint` (clean), full workspace build. Two new unit
tests in `timing.rs` cover the guard: `records_a_sample_on_drop` and
`discard_suppresses_the_sample` (both pass). `cargo test -p
ethlambda-blockchain` 46 unit tests pass. Fork-choice/signature spec
tests require downloaded fixtures (absent in this env).1 parent 98ba0be commit d77374c
2 files changed
Lines changed: 23 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
569 | 569 | | |
570 | 570 | | |
571 | 571 | | |
572 | | - | |
| 572 | + | |
573 | 573 | | |
574 | 574 | | |
575 | 575 | | |
| |||
581 | 581 | | |
582 | 582 | | |
583 | 583 | | |
| 584 | + | |
584 | 585 | | |
585 | 586 | | |
586 | 587 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
8 | 13 | | |
9 | 14 | | |
10 | 15 | | |
| |||
17 | 22 | | |
18 | 23 | | |
19 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
20 | 41 | | |
21 | 42 | | |
22 | 43 | | |
| |||
0 commit comments