perf: speed bounded projections and correct click timing#61
Conversation
Benchmark entrypoint: bash autoresearch.sh Goal: Reduce projection event processing cost for the fixed 10,000-entry snapshot plus 100,000-event workload without changing protocol, ordering, cursor, history, or bounded-retention semantics.
… improvement, pending required identical-tree confirmation.
Result: {"status":"keep","projection_event_ns_per_event":51616.94091,"projection_event_p95_ns_per_event":60812.81317000001,"projection_events_ms":5161.694091,"projection_snapshot_ms":84.44190400000002,"projection_event_heap_growth_bytes":42670976}
…rsus the segment baseline and 5.8% versus the prior best, pending identical-tree confirmation.
Result: {"status":"keep","projection_event_ns_per_event":48600.09677999999,"projection_event_p95_ns_per_event":51156.74766999997,"projection_events_ms":4860.009677999999,"projection_snapshot_ms":76.79977500000018,"projection_event_heap_growth_bytes":2316392}
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8ec4655955
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Pull request overview
Improves performance observability and throughput for bounded transcript projections by tightening projection updates, reducing retention/serialization overhead, and refining browser benchmark timing boundaries to separate Playwright automation cost from application click-to-render work.
Changes:
- Optimizes projection snapshot updates (LRU/touch + arrival ordinal handling) to reduce per-event overhead.
- Speeds retained transcript byte accounting and key ordering; adds tests to pin JSON-byte semantics and prioritization behavior.
- Extends perf tooling (warmups, ns/event metric, autoresearch output, and new browser click timing phases) with updated docs.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/perf/ui.mjs | Adds new browser phase metrics separating Playwright delivery time from real DOM click timing. |
| scripts/perf/core.test.ts | Adds warmups and a normalized ns/event metric; strengthens projection semantics assertions during perf runs. |
| scripts/perf/autoresearch-report.mjs | New script to emit standardized metrics + evidence metadata for autoresearch ingestion. |
| packages/client/test/transcript-retention.test.ts | Adds coverage for retained JSON byte counting and key prioritization under tight budgets. |
| packages/client/src/transcript-retention.ts | Optimizes byte accounting (fast paths, cached encoder) and reduces unnecessary key sorting / ancestor copying. |
| packages/client/src/projection.ts | Adds LRU touch fast-path and moves arrivalOrdinal updates into withSession for fewer allocations. |
| e2e/remote-app.spec.ts | Captures real DOM click timestamp to support new UI perf phase boundaries. |
| docs/PERFORMANCE.md | Documents the split between Playwright-delivery-inclusive vs DOM-click-origin metrics. |
| autoresearch.sh | New runner script to generate perf artifacts and autoresearch-friendly output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Outcome
Speeds the fixed 10,000-entry plus 100,000-event projection workload while preserving retention, ordering, cursor, and immutability contracts. It also separates Playwright action delivery from the real DOM click so browser reports measure application work directly.
Evidence
Verification
The VPS has a real /usr/local/bin/omp, so three pre-existing desktop discovery assertions that assume the fallback path is absent are left to clean CI. All changed client tests and the remaining desktop suite passed.