Skip to content

Add sub-stage timing spans to system trace generation#61

Draft
qwang98 wants to merge 1 commit into
v2-powdr-beta.2from
powdr-labs/tracegen-logging
Draft

Add sub-stage timing spans to system trace generation#61
qwang98 wants to merge 1 commit into
v2-powdr-beta.2from
powdr-labs/tracegen-logging

Conversation

@qwang98

@qwang98 qwang98 commented Apr 30, 2026

Copy link
Copy Markdown

Summary

Add sub-stage timing spans to system trace generation for performance profiling.

All spans are info level, captured by TimingMetricsLayer and emitted as *_time_ms gauge metrics.

New spans

System chip trace gen (system/mod.rs):

  • program_tracegen — program chip trace gen
  • memory_tracegen — entire memory controller

Memory controller (memory/controller/mod.rs):

  • boundary_finalize — boundary chip finalize (promoted from debug to info)
  • rechunk_memory — regrouping blocks into chunks
  • boundary_tracegen — boundary trace matrix creation
  • merkle_tracegen — merkle trace matrix creation

Merkle chip (memory/merkle/trace.rs):

  • merkle_finalize — overall merkle finalize (promoted from debug to info)
  • merkle_from_memory — initial merkle tree construction
  • merkle_tree_finalize — updating tree with touched leaves

New counter metrics

  • boundary_touched_chunks — actual (unpadded) chunk count
  • merkle_touched_chunks — touched leaf count
  • merkle_initial_tree_nodes — non-default nodes after from_memory
  • merkle_unpadded_rows — actual merkle trace rows before padding

These metrics were used to determine that the APC trace gen overhead is NOT in system chips (memory/merkle), but in PowdrAir trace generation.

Break system_trace_gen into measurable sub-stages to identify where
the 1.61x APC overhead in trace generation comes from:

- program_tracegen, memory_tracegen: top-level system chip spans
- boundary_finalize, rechunk_memory: memory controller sub-stages
- merkle_finalize (promoted to info), merkle_from_memory, merkle_tree_finalize
- boundary_tracegen, merkle_tracegen: trace matrix creation
- Counter metrics: boundary_touched_chunks, merkle_touched_chunks,
  merkle_initial_tree_nodes, merkle_unpadded_rows

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Apr 30, 2026

Copy link
Copy Markdown

Claude encountered an error —— View job


I'll analyze this and get back to you.

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.

1 participant