Skip to content

perf: cost-tracker subagent half and memory-audit-commit fork overhead #379

Closed

Description

@wasikarn

From the 2026-10-03 performance and purity analysis (three analysts plus three attackers; numbers below are the attackers' re-measurements).

cost-tracker.sh, subagent half. It is about 52% of wall time at p90 and 6.5 s per Stop at the 193-subagent session. The hook is async, so this is CPU per turn, not time the user waits.

  • build_type_map forks jq and basename 2 to 3 times per subagent. One batched jq call gave identical output on 276 sessions / 1,500 rows under bash 3.2 and bash 5 with the real verify map: 61 to 68x faster at 193 subagents, 4.1x at 6 (the typical case).
  • scan_transcript forks basename once per subagent file (about line 428). Parameter expansion takes 426 ms to 9 ms at 193 files, same output.
  • The usage-record builder and the error-row builder are copied inside the script and differ only in the t: and f: keys (the comment near lines 461 to 463 admits one copy; a past fix had to edit both). One shared jq definition.
  • Optional, lower value: the codex tally re-reads subagent files that raw_records already read. The corpus cannot test the codex half (0 of 4,003 local subagent files call a codex: skill or agent), so it needs hand-made fixtures.

memory-audit-commit. It runs the memory-dir resolver (python3 plus git) twice before it checks whether the store is opted in. Reordering the checks measured 84.4 ms to 44.6 ms per Stop on bash 3.2 (the existing test passes 29/29 on both versions). It saves CPU only, because the hook is async.

Constraints: bash 3.2 (macOS), output byte-identical (diff against a frozen copy on real transcripts), costs.jsonl rows unchanged, #162/#163 behaviour unchanged.

Activity

  1. added 3 commits that reference this issue on Oct 3, 2026
  2. wasikarn commented on Oct 3, 2026

    @wasikarn
    OwnerAuthor

    All three items merged: #380 (memory-audit-commit opt-in before --enc), #384 (batched build_type_map), #386 (shared usage-record def and sentinel row). The optional single-pass codex tally was skipped; see #386 for the measured cost (~1.15 s at 193 subagents) and why.

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions