Skip to content

perf(sessions): filter archived rows in the list pass - #179939

Closed
steipete wants to merge 1 commit into
mainfrom
steipete/perf-micro-session-archive-filter-match-20260919
Closed

steipete wants to merge 1 commit into
mainfrom
steipete/perf-micro-session-archive-filter-match-20260919

Conversation

@steipete

@steipete steipete commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Session-list reads allocate intermediate archive-filtered arrays before traversing the same rows again for other filters.

User Impact

List results, archive semantics, pagination, facets, and viewer-specific disclosure are preserved. Archive matching moves into the existing filter loop after visible-roster person-reference resolution. Dirty partitions expose their iterators, ordering retains one sequence per sort mode, and unscoped selection copies the map values directly. All internal callers migrate together. Production delta: −14 lines, with no new cache, schema, configuration, or public API.

Decision: rejected by measurement rule v5

Not merged. Two complete interleaved baseline/candidate pairs ran under the current shared production guard (default loop maximum 2,500 ms, abort after three consecutive bad checks), with no threshold override or additional watcher. Both pairs completed on their first attempt under this policy. The authorized fallback for four consecutive guard-aborted attempts with no valid pair therefore does not apply.

The mean of the paired deltas is +22.57% promotion MB/turn and +23.01% sessions.list p99. Both exceed v5's +20% rejection threshold. The second pair reverses the sessions.list sign, but the required mean still fails. No causal performance-regression claim is made from this noisy host; these are failed acceptance measurements, so the simplification is not landing on this evidence.

Gateway measurements

Baseline 399a360fdfbb15546498a97886cef41fd8cac66b; candidate 95ddfd4b793b3e43e4f6774b8ca5417fa4498bba. The PR head 5beb78c164ae91f355484431a1a4007d70aee56a is a patch-identical rebase over unrelated UI-only changes; the measured owners and lockfile are unchanged. Both revisions ran their verified qaRuntime builds through dist/entry.js.

Pair 1 used slot B: baseline on even CPUs 64–94, candidate on odd CPUs 65–95. Pair 2 used slot A with the placement swapped: baseline on odd CPUs 97–127, candidate on even CPUs 96–126. Each pair acquired its own slot through acquire-slot.sh and used the shared guard wait/watch, CPUWeight=10, IOWeight=10, and MemoryMax=64G. Synthetic fixture: 5,000 sessions, one project, no retained runs/approvals/cron. Each side completed 240 measured turns, 24 measured cohorts, 8 warmup cohorts, and 30 session resets. The equal reset/work counts exclude the known reset-boundary artifact.

Each scored window was approximately 480 seconds after 120 seconds of warmup. Percentile counts are given separately for every side below. Turn p99 is context only (n=240); turn p95 is valid. Event-loop and sessions.list p99 are valid (n≥1,000). Every side has fewer than 50 major collections, so major GC alone is context only; total GC carries the gate.

Metric Pair 1 baseline Pair 1 candidate Pair 2 baseline Pair 2 candidate Mean paired delta Gate
Sampled allocation, MB/turn 147.8497 157.3290 147.1534 146.7652 +3.07% context
Promotion, MB/turn 16.1558 23.5374 15.9316 15.8427 +22.57% FAIL
Minor GC, s/min 0.5008 0.6391 0.5107 0.5005 +12.81% context
Major GC, s/min 0.2876 0.1726 0.1770 0.1625 -24.07% context
Total GC, s/min 0.7884 0.8117 0.6877 0.6630 -0.31% pass
Event-loop p99, ms 38.830 (n=22,794) 43.483 (n=22,570) 35.946 (n=23,070) 37.126 (n=23,038) +7.63% pass
Turn p95, ms 6822.670 (n=240) 7116.587 (n=240) 4164.542 (n=240) 4501.268 (n=240) +6.20% pass
sessions.list p99, ms 152.595 (n=2,391) 241.134 (n=2,454) 62.543 (n=2,270) 55.035 (n=2,315) +23.01% FAIL

Major collection counts, baseline/candidate: 47/44 in pair 1 and 44/39 in pair 2. Context-only turn p99, baseline/candidate: 7,142.156/10,998.878 ms (n=240/240) in pair 1 and 5,419.030/5,511.264 ms (n=240/240) in pair 2.

Pair-specific failing-metric deltas: promotion +45.69% / −0.56%; sessions.list p99 +58.02% / −12.00%. The decision uses their arithmetic means, as required by v5.

The shared guard logged two isolated dirty-page violations in pair 1 (dirty_kb=2747092, dirty_kb=2225480) and one isolated load violation in pair 2 (load=61.93). Neither reached three consecutive failures, and neither pair was aborted. Earlier attempts under the superseded 500 ms/two-check policy are excluded entirely. The host was known to have production swap stalls; that context does not convert a completed failed acceptance pair into a passing one.

node --import ./scripts/tsx.mjs scripts/perf/transcript-broadcast-measure.ts \
  --entry dist/entry.js --state-dir <synthetic-fixture> \
  --scenario memory-soak --clients 8 --runs 10 \
  --chunks 100 --chunk-interval-ms 10 \
  --warmup-ms 120000 --duration-ms 480000 --soak-rounds 24 \
  --round-interval-ms 15000 --reset-every-rounds 12 --retained-profile-ms 0 \
  --allocations --trace-gc --diagnostics --list-interval-ms 500 \
  --poll-seed archive-filter --capture-responses --start-at <shared-epoch-ms> \
  --port <isolated-port> --mock-port <isolated-mock-port> --revision <revision>

Measured polling uses archived: "all". After each window, all 20 captured Gateway requests matched between revisions, including archive on/off, pagination, sorting, and other filters. Normalization is limited to exact synthetic sandbox prefixes, the response ts, and sessions[].snapshotAt, which is the documented presentation clock assigned by presentSessionRow in session-utils-row.ts. No content, ordering, count, facet, or identity field was removed from comparison.

Owner measurements and correctness

Five interleaved baseline/candidate processes per side, 5,000 sessions, 96 warmup calls and 480 measured calls per process. All 48 complete archive/person/facet/viewer golden results matched in each process pair. Allocation sampling includes objects collected by minor and major GC. Cold measurement covers the first request. Each p95 below has only n=5 process observations per side and is context only.

Metric Baseline median Candidate median Baseline p95 (n=5) Candidate p95 (n=5) Mean paired delta
Warm allocation, bytes/request 2,182,642 2,168,309 2,200,413 2,176,437 −0.67%
Warm CPU, ms/request 1.1170 1.0482 1.3849 1.9132 +8.53%
Cold first-read allocation, bytes 4,480,696 3,579,840 4,951,808 3,957,336 −22.39%
Cold first-read CPU, ms 9.680 10.264 11.416 10.509 +4.27%

Warm allocation is effectively neutral. No timing improvement is claimed. The cold owner-allocation improvement does not override the failed whole-flow gates.

node --expose-gc --import ./scripts/tsx.mjs scripts/perf/session-profile-reference-measure.ts --archive-filters --iterations 480 --output result.json --golden golden.json

66 focused tests passed across nine files covering archive/rematerialization ordering, scope/federation, profile/owner facets, viewer sharing, projects, usage, catalog snapshots, and retired-row collection. Changed-file formatting/lint and the core typecheck lane passed. Independent review found no actionable P0–P2 defects. ClawSweeper's exact-head review also found no actionable defect.

CI attribution

Exact-head CI run 39681041351 completed with one failed non-aggregate job: checks-node-changed. x-publication-owner-composition.e2e.test.ts:949 intermittently returned HTTP 503 instead of 200 for the anonymous public read. The unchanged baseline and candidate each passed twice, then reproduced the identical failure on their third focused invocation. The failing public-read admission/representation code and test are byte-identical between baseline and PR head. The real-auth public-entry sibling passed all seven cases in the same CI job. All other non-aggregate exact-head CI jobs passed or were intentionally skipped. No CI rerun was requested.

Focused attribution used the supported CI qaRuntime build followed by:

OPENCLAW_E2E_USE_PREBUILT_DIST=1 node scripts/run-vitest.mjs src/gateway/x-publication-owner-composition.e2e.test.ts --maxWorkers=1

This inherited CI failure would qualify for the authorized inherited-failure route; the failed performance gates prevent landing independently of CI.

Remove archive prefilter arrays and per-archive ordering variants while preserving profile-reference resolution, facets, pagination, and viewer disclosure. Return unscoped row values directly. Extend the owner benchmark with archive/viewer golden comparisons.
@clawsweeper

clawsweeper Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime scripts Repository scripts size: S labels Oct 21, 2026
@steipete
steipete marked this pull request as ready for review October 21, 2026 21:43
@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-21T21:43:18.231640Z 5beb78c Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 21, 2026
@clawsweeper

clawsweeper Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR moves archive filtering into the existing session-list pass and removes archive-specific ordering variants and intermediate arrays.

Example: Request 25 open sessions from a roster of 5,000 sessions with archived: false.

  • Before: Selection prepares archive-filtered candidates before applying the remaining list filters.
  • After: The existing filter loop rejects archived rows while preserving the returned page, totals, and facets.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The source supports a correct, focused simplification, with reported owner-level comparisons but no completed Gateway performance acceptance.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; its reported production-owner probe covers archive/person/facet/viewer selection, while Gateway acceptance remains explicitly pending.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Large session-list reads allocate temporary archive-filtered collections and repeat traversal work.
Reason: The maintainer-authored direction removes machinery without changing list contracts, adding runtime settings, or introducing a parallel owner.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it makes a focused simplification to session selection, and no actionable correctness or security defect was identified.

Priority: P2
Reviewed head: 5beb78c164ae91f355484431a1a4007d70aee56a

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The PR explicitly awaits paired isolated-Gateway measurements through the real sessions.list transport against its declared acceptance criteria.
Agent review details

How this fits together

The Gateway selects resident session metadata, resolves visible person references, applies archive and access filters, and presents paginated session rows to clients.

flowchart LR
  A[Session metadata publications] --> B[Resident row projection]
  B --> C[Shared session selection]
  C --> D[Visible person references]
  D --> E[Archive and list filters]
  E --> F[Facets and pagination]
  F --> G[Authorized session response]
Loading

Technical review

Best possible solution:

Keep archive matching in the existing filter owner and retain the simpler ordering representation if the declared Gateway acceptance criteria pass.

Do we have a high-confidence way to reproduce the issue?

The base source directly shows intermediate archive-filtered arrays and separate archive orders; reported owner-probe results support the allocation premise, but no target code was executed during this read-only review.

Is this the best way to solve the issue?

This is a small, coherent simplification using the existing selection and filter owners, with full-roster callers migrated and the distinct child-row archive contract retained.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 4a5d689c1a74.

Provenance checked

  • Archive-specific orders and prefiltering changes intended behavior with a stated reason (79a4205: Avoid scanning the opposite archive population while preserving facets, person resolution, and full-roster consumers.)
  • Prepared ordering facts keeps the original intent (2e36582: Reuse revision-bound ordering facts and avoid repeated per-comparison allocation.)
  • Unscoped row matching keeps the original intent (7367ec7: Reuse topology paths while preserving physical scope, federation, aliases, and insertion order.)
  • Existing owner measurement script keeps the original intent (b3245a2: Measure profile-reference allocation through real production owners with complete golden results.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source -14, Tests 0, Docs +7, Other +33. Total +26 across 11 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 7 29 43 -14
Tests 2 3 3 0
Docs 1 7 0 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 1 45 12 +33
Total 11 84 58 +26

Review metrics

Metric Value Why it matters
Production versus tests Production +29/-43; tests +3/-3 The production change removes redundant selection machinery; test changes only migrate existing callers.
Benchmark option 1 added flag: --archive-filters The measurement script gains an archive/person/viewer scenario matrix; runtime configuration and protocol options remain unchanged.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded performance improvement for large session inventories, with no demonstrated urgent user-facing regression.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Supply the paired Gateway results and evaluate them against the acceptance rule already recorded in the PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 21, 2026, 6:00 PM ET / 22:00 UTC.

@steipete

Copy link
Copy Markdown
Contributor Author

Closing under measurement rule v5. Both requested interleaved pairs completed under the current shared guard, with 240 measured turns and 30 resets per side. Mean promotion was +22.57%; mean sessions.list p99 was +23.01% (pair 1 n=2,391/2,454; pair 2 n=2,270/2,315). Both exceed the +20% rejection threshold. All forty captured Gateway responses matched after documented timestamp/path normalization, and the owner cold-allocation result remains −22.39%, but those do not override the whole-flow gates. The four-abort/no-valid-pair fallback did not trigger. Full results and the unrelated baseline-reproduced CI failure are recorded in the body; no CI rerun or merge was attempted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant