refactor(blockchain): return block-building phase timings instead of deltaing histogram sums
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 55/100
- issue の種類
- リファクタリング
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- rust
- 領域
- blockchain
調査の方向性
bin/ethlambda/src/benchmark/mod.rs の PhaseTimer、registry の read helper、一度の build ごとに実行される assertion から始め、次に build_block とその phase timing data を追跡します。既存の histogram name、labels、values が変更されていないことを確認し、同じ seed で make bench を実行して iteration ごとの block roots を比較します。
索引モデルが issue の本文から書いたものです。
説明
Follow-up from review of #595, deferred there by agreement:
This is a really hacky way of recording phase times. We should record the duration of
each phase inside the relevant functions and return a report, which the metrics
consume. That way we don't have to do this here.We can do this in another PR
— @MegaRedHand, https://github.com/lambdaclass/ethlambda/pull/595#discussion_r3884295715
Current approach
The benchmark reads the lean_block_proposal_attestation_build_phase_seconds histogram
from the default prometheus registry before and after each build, and takes the
difference of the per-label sample sums as the phase durations
(PhaseTimer in bin/ethlambda/src/benchmark/mod.rs).
It is exact — histogram sums accumulate raw f64 seconds, so bucket boundaries play no
part — and it needs no changes to the hot path, which is why it was the right call to get
the harness landed. But it is a roundabout way to obtain numbers the building code
already has:
- Phase timings reach the benchmark only through a global registry, so the harness
depends on process-wide state and on the metric's label set staying exactly as it is. - Correctness rests on each phase being observed exactly once per build. The harness has
to assert that and fail the run when it does not hold, because it cannot otherwise tell
a mis-attribution from a real measurement. - It works only single-threaded and single-configuration per process; two concurrent
builds would interleave into the same counters.
Proposed change
Have the block-building phases measure themselves and return their durations as part of a
report, with the metrics layer as one consumer of that report rather than the channel
through which timings travel:
build_block(and the phases inside it) return the phase durations alongside their
result.- The existing histogram observations are fed from that report, so dashboards are
unchanged. - The benchmark consumes the same report directly and drops
PhaseTimer, the registry
read, and the once-per-build assertion.
Why it is worth doing
Beyond removing the indirection: the timings become available to anything that builds a
block, not just to a process that can read the global registry — which is what a
replay-from-datadir mode and any future per-build logging would want. It also removes the
only reason the benchmark is restricted to one configuration per process invocation.
Acceptance criteria
- Phase durations come from the building code, not from a registry diff.
lean_block_proposal_attestation_build_phase_secondskeeps its current name, labels and
values, so existing dashboards and alerts are unaffected.PhaseTimer, theread()helper and the "observed exactly once" assertion are gone
frombin/ethlambda/src/benchmark/mod.rs.make benchreports the same phases, and a same-seed run produces the same
per-iteration block roots as before.
Related: #465 (Optimize block building), #595 (the harness), #596 (report statistics).
- 主要言語
- Rust
- スター
- 82
- フォーク
- 28
- 平均マージ
- 1日 23時間
- マージ済み PR(30日)
- 19
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
lambdaclass/ethlambda のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
lambdaclass/ethlambda#529 · コメント 4 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
lambdaclass/ethlambda#521 · コメント 2 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
lambdaclass/ethlambda#609 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
lambdaclass/ethlambda#602 ·
-
performance
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
lambdaclass/ethlambda#583 ·
lambdaclass/ethlambda の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
bug team:backend track:services-maintenance
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
cowprotocol/services#4950 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
gitbutlerapp/gitbutler#15998 · コメント 1 件 ·