Repository navigation
perf(gateway): avoid temporary profile reference projections - #179796
Conversation
Preserve raw retained identities and viewer-specific person filtering while scanning existing participants directly. Share profile ID resolution with display projection and remove display object allocation from ID-only callers. Add reproducible owner allocation measurements and person-filtered Gateway soak captures.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed as b3245a2 under the authorized inherited-failure exception. The only failing test file on exact head e2262b8 was Both interleaved, swapped Gateway pairs passed v5, with matched 384 turns and zero resets per side. All 27 owner golden results and 24 normalized full RPC responses matched. The PR body contains the per-side counts, paired deltas, workload, and limitations. The native merge helper refused before submission because it requires a separate review worktree; the lane's one-worktree constraint was preserved using the explicitly authorized exact-SHA REST fallback. |
Revert the ordering facts and sharing-wrapper changes from 2e36582 while preserving #179796 profile-reference handling and #180067 archive filtering. Retain the pin/sidebar-root behavior regression and reusable measurement support. The owner comparator gain did not produce the required per-request production gain. Gateway pairs were flat (+10% promotion, +1.6% CPU/RPC), and the change added 24 runtime lines. Production profiles include other commits, so the next production profile must establish the effect of this revert.
Revert 6cb819f (#180067) on top of the #179211 revert, preserving #179796 and later unrelated fixes. Restore archive-prefiltered ordering views and their callers. Production r182 made filterSessionEntries the top OpenClaw self frame: 233 to 1751 samples, inclusive selectSessionEntries samples/rpm 8.27 to 25.2, and main-thread busy 37% to 57% despite lower traffic. All 108 golden cases remain identical to the historical owner path.
…179211 and #180067 (#180166) * revert(gateway): restore sessions.list ordering before #179211 Revert the ordering facts and sharing-wrapper changes from 2e36582 while preserving #179796 profile-reference handling and #180067 archive filtering. Retain the pin/sidebar-root behavior regression and reusable measurement support. The owner comparator gain did not produce the required per-request production gain. Gateway pairs were flat (+10% promotion, +1.6% CPU/RPC), and the change added 24 runtime lines. Production profiles include other commits, so the next production profile must establish the effect of this revert. * revert(gateway): restore archive-specific session list filtering Revert 6cb819f (#180067) on top of the #179211 revert, preserving #179796 and later unrelated fixes. Restore archive-prefiltered ordering views and their callers. Production r182 made filterSessionEntries the top OpenClaw self frame: 233 to 1751 samples, inclusive selectSessionEntries samples/rpm 8.27 to 25.2, and main-thread busy 37% to 57% despite lower traffic. All 108 golden cases remain identical to the historical owner path. * chore(perf): remove retired session ordering benchmark registration
…w#179796) Preserve raw retained identities and viewer-specific person filtering while scanning existing participants directly. Share profile ID resolution with display projection and remove display object allocation from ID-only callers. Add reproducible owner allocation measurements and person-filtered Gateway soak captures.
…penclaw#179211 and openclaw#180067 (openclaw#180166) * revert(gateway): restore sessions.list ordering before openclaw#179211 Revert the ordering facts and sharing-wrapper changes from e3c341e while preserving openclaw#179796 profile-reference handling and openclaw#180067 archive filtering. Retain the pin/sidebar-root behavior regression and reusable measurement support. The owner comparator gain did not produce the required per-request production gain. Gateway pairs were flat (+10% promotion, +1.6% CPU/RPC), and the change added 24 runtime lines. Production profiles include other commits, so the next production profile must establish the effect of this revert. * revert(gateway): restore archive-specific session list filtering Revert f46e5d9 (openclaw#180067) on top of the openclaw#179211 revert, preserving openclaw#179796 and later unrelated fixes. Restore archive-prefiltered ordering views and their callers. Production r182 made filterSessionEntries the top OpenClaw self frame: 233 to 1751 samples, inclusive selectSessionEntries samples/rpm 8.27 to 25.2, and main-thread busy 37% to 57% despite lower traffic. All 108 golden cases remain identical to the historical owner path. * chore(perf): remove retired session ordering benchmark registration
What Problem This Solves
Person-filtered
sessions.listrequests repeatedly flatten every visible session's creator and participants into temporary arrays. ID-only callers also build participant display objects that they immediately discard.User Impact
The same sessions, people, owners, and profile links are returned with less allocation. Exact references, retained identities, merged profiles, prefix ambiguity, and viewer-specific disclosure retain their existing semantics. No configuration, schema, cache, or invalidation change.
Why This Change Was Made
Scan raw creator/participant identities with two request-scoped callbacks, preserving creator-first exact-match precedence. Reuse the existing profile identity map through one ID resolver; display projection and ID-only callers consume that same owner. With 5,000 rows and three participants, a full scan no longer constructs 25,000 temporary arrays and 5,000
flatMapcallbacks (source-derived counts).Production delta: 33 insertions, 33 deletions (net zero) across the two Gateway modules. The added code outside those modules is reproducible benchmark/capture tooling. This is a simplification; whole-Gateway allocation noise is too large to establish a small owner's improvement.
Evidence
Owner replay: Node 26.8.2 on an isolated Linux sandbox, 5,000 sessions, 50 profile identities including aliases and retained identities, three participants per session, 27 requests across three visibility scopes. Five serial interleaved A/B samples per side, each after 54 warmups and containing 108 measured filter operations. Both include-collected allocation sampling flags enabled. All 27 golden filter results are byte-identical across all pairs.
Focused local validation: 38 tests passed across
session-utils-profile-reference,session-utils-owners, andsession-utils.filters; 22 import/wrapper closure tests passed; export-name collision guard, changed-file format/lint, andpnpm tsgo:corepassed. Independent Codex autoreview is clean at P0–P2. PR CI supplies broad validation.Gateway no-regression result
Pass under decision rule v5; land as a net-zero production simplification. Two concurrent A/B pairs used interleaved 16-core placements, with baseline/candidate swapped in pair 2. Pair 1 used slot A (baseline even 96–126, candidate odd 97–127); pair 2 used slot B (baseline odd 65–95, candidate even 64–94). The mean of within-pair percentage changes cancels residual placement bias. No gated metric has mean regression ≥20% or regression ≥10% in both pairs.
Each side used 120 s warmup and 480 s measurement, 5,000 retained sessions, 6,000 retained runs, 16 clients, 12 concurrent turns, 50 streamed chunks, and missing-prefix person-filter polling every 500 ms. Fixtures used 1 MiB transcript payload and one project. Both sides completed 32 measured cohorts / 384 turns, plus eight warmup cohorts; resets were 0/0 in both pairs. Both diagnostic captures had no dropped events, histogram samples, or collection errors.
p99 gates require ≥1,000 samples per side; turn p95 gates have ≥200 per side. Turn p99 is context only at n=384 per side. Major-GC collection counts are shown explicitly; total GC carries the gate. Whole-Gateway sampled allocation is context only: this experiment is not powered to attribute a small owner's allocation win. Promotion's +1.73% mean is within the predeclared no-regression limit.
All 24 captured full RPC responses matched in both pairs after normalizing only response/snapshot timestamps and each isolated fixture's absolute root. The resulting normalized response hashes also match across pairs. The owner replay separately proves 27 byte-identical results across viewer scopes without normalization.
Every side ran in a resource-limited systemd scope with CPUWeight/IOWeight 10, 32 GiB MemoryMax, and the shared production guard. One transient guard sample in pair 2 recovered on the next check; neither valid pair was aborted. An earlier setup attempt missed the shared startup deadline on both sides and produced no measurement; it was discarded, fixtures regenerated, and the startup allowance raised from 210 to 300 seconds. Source, workload, and measurement duration were unchanged. Synthetic provider/state and disabled plugins limit this evidence to the exercised session-list path, not plugin-invocation performance.
CI and review
Independent Codex autoreview is clean at P0–P2; hosted Codex review completed with no findings. Exact-head CI run 39654618593 passed all selected jobs except one inherited UI test file and its aggregate gate.
Inherited failure:
ui/src/e2e/boot-module-boundaries.e2e.test.ts, the sidebar-download recovery cases at 390px and 1280px, both time out onRetry nowatgateway-module-boundaries.test-support.ts:62. PR job 119412335759 and scheduled main job 119376935880 show the same assertions and 30-secondlocator.isDisabledtimeouts. The test uses a mock Gateway; the entire UI tree is unchanged by this PR. CI's automatic classification says unknown solely because PR UI shards are 1/2 while scheduled main uses 1/9. No CI rerun was requested.The inspected CI checkout is
582b1a14af96937f800446c1066aea81b531c9c8, with ordered parents200d82b012aaf4e937da13c0788828ce1a8c560fand this PR's exact heade2262b8f0d519b629e18902655c8b778ae83d474. Security, type, lint, closure, and affected Node test jobs passed. The sandbox baseline wase18310f1ba35; the intervening main commits incorporated before push changed none of the measured owner/harness paths.Related: #179211.