Skip to content

Command details take ~35s because every read re-parses historical Session traces #1363

Closed

Description

@JacobStephens2

This was generated by AI during triage.

Command details in the Console stay on "Loading details…" for about 35 seconds on every Command, and thirdshift show <command> --json and thirdshift metrics --json take just as long. Every read that loads Run metrics re-parses the Session trace of each Command that ended before #1037, and keeps nothing, so each pane open, live refresh and metrics call pays the whole cost again.

Reproduction

On the stephens host with thirdshift 0.16.1, and again on main at 21e8b5b4:

  • thirdshift show <command> --json passed a 30-60s timeout for secure-20261025T063021-0400 (JacobStephens2/voice-agent-scheduling), secure-20261025T033012-0400, secure-20261025T050021-0400 and pickup-20261025T145901-0400. thirdshift metrics --json did the same.
  • thirdshift status --json returns immediately, so it only happens on the Run metrics load.
  • The process sits at ~100% CPU with no children, so it is not waiting on GitHub.

Measurement

With temporary timing around each session_signals::read call in a release build of 21e8b5b4, one thirdshift metrics --json took 34.6s, and 34.3s of that was 562 Session trace reads. The logs directory holds 1,750 .jsonl files (8.2G). No single file is the problem: the slowest read was 0.87s, most were 0.2-0.5s.

Cause

Snapshot::load_metrics_with_silence reads records with past_metrics: true. For each record whose RunMetrics has no session_signals, either a pre-#1037 record or a historical reconstruction, RunMetrics::add_session_signals calls session_signals::read on every stage's Session trace. Records completed after #1037 (b59894e0, 2026-10-23) store their signals and skip this step. The record cache keeps parsed records only, not signals.

The Console's loadPeek fetch has no timeout, so the pane shows "Loading details…" until the response arrives.

Activity

  1. JacobStephens2 commented on Oct 26, 2026

    @JacobStephens2
    OwnerAuthor

    This was generated by AI during triage.

    Agent Brief

    Category: bug
    Summary: Command details and Run metrics re-parse every historical Session trace on each read, so each request takes ~35s

    Current behavior:
    Any read that loads a Snapshot with past Run metrics (Console Command details via /peek, thirdshift show, thirdshift metrics) calls RunMetrics::add_session_signals for every Command whose stored RunMetrics has no session_signals. That parses each stage's Session trace with session_signals::read. On a host with 562 such Session traces this takes ~34s per request, and nothing is kept between requests. A Console pane open plus its live refreshes repeat the cost every time.

    Desired behavior:

    • Command details for one Command (stop::inspect, the show path) read Session signals only for the Command being shown and its dispatched records. Usual ranges and every other Command's health must stay the same.
    • Readers that need every Command's Session signals (weekly trends from thirdshift metrics) parse each Session trace at most once while it is unchanged. Keep derived SessionSignals keyed on the trace's identity (path plus length and modification time, or something equally strict), the same way the parsed-record cache keys records. A trace that changes or is still being written must be read again, never served stale.
    • Commands whose stored RunMetrics already has session_signals behave exactly as they do now.

    Key interfaces:

    • Snapshot::load_metrics_with_silence / load_metrics and the past_metrics flag on record reading: decide which records need Session signals, not just whether.
    • RunMetrics::add_session_signals(record, read): its read closure is where a memoized reader slots in.
    • session_signals::read(&Path) -> Result<Option<SessionSignals>>: unchanged contract; results become cacheable.
    • stop::inspect(&UserConfig, &str) -> Inspection: should no longer cost one parse per historical Session trace.

    Acceptance criteria:

    • A test with many completed pre-Session-trace signals #1037 records (no stored session_signals) shows Command details for one Command calls the Session-signal reader only for that Command's own Session traces.
    • A test shows a second Run metrics load over unchanged Session traces does not re-parse them, and that appending to a trace or replacing it makes the next load read it again.
    • The Session signals that Command details and thirdshift metrics --json report for a historical Command match what they report today (same JSON for the same fixtures).
    • On a logs directory of this size (hundreds of historical Session traces), thirdshift show <command> --json returns in under 1s, and so does opening Command details in the Console.
    • The Console details pane shows "Details unavailable. Reload to try again." if the details request does not finish within a bounded time, instead of "Loading details…" forever.

    Out of scope:

    • Writing derived Session signals back into historical Command records (a migration).
    • Changing what Session signals measure or how trends aggregate them.
    • Speeding up session_signals::read itself, beyond what caching needs.
    • Other Console views and thirdshift status, which do not load past Run metrics.
  2. added
    bugSomething isn't working
    ready-for-agentFully specified, ready for an AFK agent
    in-progressA Claim: thirdshift has taken this issue
    and removed
    ready-for-agentFully specified, ready for an AFK agent
    in-progressA Claim: thirdshift has taken this issue
    on Oct 26, 2026
  3. JacobStephens2 commented on Oct 26, 2026

    @JacobStephens2
    OwnerAuthor

    Retrying on codex. Earlier Runs failed on codex capacity errors (05:01, 09:14), and the 09:30 grok Run's diagnosis ended without a reproduced or not reproduced line. Branch issue-1363 and draft PR #1377 are reused.

  4. added
    ready-for-agentFully specified, ready for an AFK agent
    in-progressA Claim: thirdshift has taken this issue
    and removed
    in-progressA Claim: thirdshift has taken this issue
    ready-for-agentFully specified, ready for an AFK agent
    on Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions