Skip to content

perf(gateway): retain only the requested ordered session page - #171968

Merged
steipete merged 1 commit into
mainfrom
steipete/perf-micro-session-filter-alloc-20260919
Oct 14, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/perf-micro-session-filter-alloc-20260919

Conversation

@steipete

@steipete steipete commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Paged sessions.list reads allocate a full matching-roster array before slicing out a small page. This adds avoidable allocation when session publications invalidate a cached selection.

User Impact

Session ordering, pagination, visibility, owner-first rows, totals, and owner/people facets remain unchanged. No configuration or storage changes.

Why This Change Was Made

The filter retains only the requested page when the resident selection is already ordered, and caps owner-first retention at its existing limit. It still scans every candidate for exact totals and facets. sessions.resolve keeps sorting its unordered candidate selections; transcript search still receives the entire filtered roster. Existing revision-aware presentation reuse remains the sole cache owner.

Production LOC: +9 net (34 added, 25 removed). The extra counter/window contract preserves exact full-roster totals and unpaginated transcript search while deleting full-roster result retention and redundant page slices.

Evidence

  • Focused filter and owner tests: 28 passed across two files (54.86s command wall time). After strengthening the fixture, the filter file passed all 18 tests again (57.16s wall time, including worker preparation). It covers shuffled input, overlapping owner-first rows, off-page facets, later pages, and an empty page.
  • Changed-file oxfmt and repository lint passed; git diff --check passed. Broad typecheck/build/suites delegated to PR CI. No Testbox lease.
  • Independent subagent review (autoreview route unavailable): clean through P2. The autoreview helper refused the requested provider because it did not match operator configuration; no configuration was changed.
  • PR CI: all 60 checks passed on c72bbdea1c88855c2ef7fc97d006cfbee6eb312d, without reruns: https://github.com/openclaw/openclaw/actions/runs/38535170193.

Measurement

Linux sandbox, 8,400 synthetic sessions, 24 profiles, 20% archived; 32 KiB V8 allocation sampling includes collected objects. Each fresh-selection case has five rounds of 1,000 operations after warming ordered resident metadata and identity facts. Full canonical output hashes match before/after for all four shapes, including exact totals, facets, and 60 owner-first rows.

Fresh selection Allocated MB/op before → after Main-thread ms/op before → after
Sidebar, 200 rows 1.988 → 1.755 (-11.7%) 1.104 → 1.054
Compact, 100 rows 1.978 → 1.756 (-11.2%) 1.161 → 1.097
Dashboard + people, 100 rows 5.544 → 5.307 (-4.3%) 2.758 → 2.165
Owner-first + people, 200 shared rows 5.579 → 5.333 (-4.4%) 2.694 → 2.230

These are medians at the production selector boundary with a fresh selection every operation, not end-to-end RPC claims. Exact counts/facets still require scanning all candidates; the change bounds temporary retained rows. The real WebSocket sessions.list allocation harness also ran against fresh synthetic fixtures (8,400 seeded sessions + 2 driver sessions; 6,000 retained runs, 200 approval recovery records, 100 disabled cron jobs, 12 projects; approximately 250 MB session database). Base fa48c5f72db5 versus this head, identical 32 KiB sampling, 500 requests/round. Sidebar/compact used five rounds each; dashboard used three. Fixture background events prevented the harness's quiet-drain assertion, so a lane-local driver used an identical fixed one-second post-RPC interval on both revisions. No production state was used.

Full RPC Allocated MB/op before → after Main-thread ms/op before → after
Sidebar, 200 rows 13.818 → 8.646 34.484 → 19.512
Compact/chat panel, 100 rows 3.683 → 3.611 6.653 → 6.401
Dashboard, 100 rows 3.630 → 3.420 6.317 → 6.952

RPC limits: sidebar medians are confounded by startup heartbeats settling at different times; no end-to-end speedup is attributed to this patch. Compact CPU ranges overlap (base 6.141–6.947; head 5.804–6.964 ms/op). The initial dashboard CPU increase prompted one targeted reverse-order confirmation on settled, equally sized fixtures: unchanged head 6.090 ms/op (6.043–6.210), then base 7.489 (7.213–9.102), with no background events in either. Allocation medians were 3.576 MB/op head versus 3.626 base. The apparent CPU regression did not reproduce; neither direction supports a reliable RPC CPU speedup claim. Both original and confirmation results are reported here.

The attributable result is approximately 0.23 MB less allocation per fresh ordered selection with identical output; whole-Gateway production impact remains unmeasured.

@clawsweeper

clawsweeper Bot commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S labels Oct 14, 2026
@steipete
steipete marked this pull request as ready for review October 14, 2026 08:26
@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 ✅ Completed 2026-10-14T08:29:39.317644Z c72bbde 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.

@steipete
steipete merged commit 738336a into main Oct 14, 2026
195 of 196 checks passed
@steipete
steipete deleted the steipete/perf-micro-session-filter-alloc-20260919 branch October 14, 2026 08:54
vincentkoc added a commit that referenced this pull request Oct 14, 2026
…/plugin-memory-addon-presentation-20261014

* commit 'a8da8c92e3dbb21dd1441a30eb842fcd942e82b6': (52 commits)
  test(ui): await terminal reconnect fixture readiness (#171945)
  perf(gateway): retain only the requested ordered session page (#171968)
  test(gateway): cover automation run-alias placement lifecycle (#139313)
  fix(ci): retry FRV job listings with smaller pages after GitHub 5xx (#171952)
  fix(process): prevent false cleanup failures after CLI stdin closes (#171969)
  test(doctor): cover released updater advisory warnings (#157086)
  fix(ci): skip Testbox builds for known prose files (#171946)
  perf(sessions): remove redundant snapshot walks (#171964)
  fix(ci): skip plugin scaffold build for SDK instructions (#171944)
  fix(infra): preserve scheduler scope abort state after retirement
  fix: setup diagnostics can repair state without approval (#171960)
  perf(usage): avoid per-session admission churn during inventory (#171868)
  fix(ci): exclude documentation from extension lint scope (#171909)
  test(gateway): keep runtime-only compat flags out of live gateway config (#171953)
  docs: document ClawHub install telemetry opt-out (#114376)
  fix: recover completed chat replies after missed publication (#171766)
  refactor(ui): decouple session controller types from Lit (#171559)
  fix(gateway): settle worker reconciliation during busy shutdowns (#171843)
  fix(ci): ignore protocol prose in bundled check selection (#171908)
  fix(ui): align replacement lines and highlight inline diff edits (#171935)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant