Skip to content

Rust perf: hotspots presenter walks the ledger twice per invocation #342

Description

@willwashburn

Context

crates/relayburn-cli/src/commands/hotspots.rs:217-249 describe_excluded_turns walks the ledger a second time after the SDK verb already walked it. The reason: the SDK's HotspotsAttributionResult.fidelity doesn't surface the per-source breakdown the CLI wants to print, so the CLI re-reads turns to recover it.

For a many-month ledger this doubles the time burn hotspots spends in I/O.

Proposed fix

Widen HotspotsAttributionResult.fidelity (or add a sibling field) in the SDK so the per-source breakdown is computed in the same pass that produced the rest of the result. Then describe_excluded_turns becomes a pure renderer over already-computed data — no second ledger walk.

This is a concrete instance of the design rule documented in #316: CLI dogfoods SDK; SDK owns composition. The fix here might fold into that issue's broader refactor.

Verification

The hotspots golden tests under crates/relayburn-cli/tests/golden.rs are byte-identical against TS — the conformance gate catches any drift in the breakdown.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions