Skip to content

perf(benchmark): bound terminal run/batch registries - #738

Open
beruro wants to merge 3 commits into
developfrom
junyu/perf-benchmark-registry-bounds
Open

perf(benchmark): bound terminal run/batch registries#738
beruro wants to merge 3 commits into
developfrom
junyu/perf-benchmark-registry-bounds

Conversation

@beruro

@beruro beruro commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Problem

The process-wide benchmark run and batch registries retained every terminal entry for the lifetime of the app. Repeated benchmark use therefore grew memory without a bound, and evaluator subprocesses could remain alive when the app exited.

Solution

  • Keep every active run/batch resident, but retain only the 50 most recent terminal entries in each registry.
  • Apply a pure, deterministic retention policy whenever an entry is inserted or transitions to a terminal state; no polling or sweep timer was added.
  • Preserve persisted batch recovery: evicted batches continue to reload from batch history on demand.
  • Best-effort terminate running evaluator processes from the existing app-exit lifecycle next to PTY cleanup.
  • Unit-test active-entry protection, ordering, tie breaks, zero budgets, idempotency, status classification, and both registry adapters.

The branch is merged with the current develop; GitHub reports it mergeable.

Potential risks

  • Terminal standalone runs older than the newest 50 are no longer queryable because that registry has no persistence layer. Active runs are never evicted, and persisted batch results remain reloadable.
  • A run permanently stuck in an active state remains resident. This is conservative and matches the prior lifecycle behavior.
  • A pre-existing batch persistence failure can still lose the latest state after eviction; persistence failures are logged but are not made transactional by this PR.
  • Exit cleanup uses try_lock and SIGTERM, so it is best-effort and cannot cover a hard process kill.
  • There is no schema, DTO, IPC, or wire-format change. Rollback is a normal revert, which restores unbounded in-memory retention and the previous exit behavior.

Audit

Architecture review covered registry ownership, status/FSM classification, persistence fallback, lock boundaries, process lifecycle, and IPC compatibility. Performance-guard verdict: pass — terminal memory is capped, active work is not evicted, pruning runs only at existing mutations, no idle/background loop was introduced, and reopen/reload uses the existing persisted batch path.

Verification

  • CARGO_TARGET_DIR=/Users/junyu/github/ORGII/src-tauri/target cargo test -p org2 benchmark::retentionPASS, 11 passed / 0 failed.
  • rustfmt on the touched Rust files — PASS.
  • git diff --checkPASS.
  • Merge of current origin/developPASS, no conflicts; targeted tests were run after integration.

@beruro
beruro marked this pull request as ready for review August 8, 2026 12:35
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