Skip to content

improve(infra): reduce scheduling work for session notice bursts - #146818

Merged
steipete merged 1 commit into
mainfrom
codex/v8-event-wake-admission
Sep 13, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/v8-event-wake-admission

Conversation

@steipete

@steipete steipete commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Bursts of session-state notices repeatedly scan every pending wake target while waiting for their coalescing timer.

Closes #146796.

User Impact

Less scheduling work for larger distinct-target bursts, with unchanged wake ordering, deadlines and settlement. Small same-target controls regress on Node 24: eight notices increase from 0.1747 to 0.1874 ms, and eight public-heartbeat admissions from 0.0436 to 0.0531 ms. No universal per-enqueue improvement is claimed.

Why This Change Was Made

An armed timer normally covers unchanged targets, so a targeted admission checks only its changed group. Handler installation can deliberately defer already-ready work; the timer records that condition and keeps the full scan until that delay is cleared. Global barriers and lifecycle changes also retain the full scan. The change uses the existing timer and pending-work owner.

Evidence

  • Complete enqueueSessionStateNotice source-copy flow on Windows, three alternating pairs per runtime (three warmups and five measured bursts per cell), measured on final corrected source:
Notice targets × repeats Node 24.19.0 before → after Node 26.8.2 before → after
1 × 1 0.1249 → 0.1245 ms 0.1222 → 0.1256 ms
1 × 8 0.1747 → 0.1874 ms 0.1676 → 0.1722 ms
8 × 3 0.2930 → 0.2885 ms 0.3224 → 0.3225 ms
32 × 3 0.6497 → 0.4596 ms 0.7002 → 0.5396 ms
128 × 3 2.3225 → 1.1735 ms 2.7183 → 1.0471 ms
512 × 3 (stress) 30.1397 → 6.2447 ms 21.4130 → 4.1898 ms
  • The 128-target case improved in all three pairs on both runtimes. At 32 targets, Node 26 won all three; Node 24 won two, with one 0.0196 ms adverse pair. Node 26's eight-target control has a 0.1309 ms adverse pair despite nearly equal overall medians. Node 24 notice ×8 and public-heartbeat single/×8 controls regress in all three pairs. Full timer-driven draining is outside admission timing, and no end-to-end speedup is claimed.
  • All 840 measured and 504 warmup bursts passed complete dispatch/system-event checks. Whole-process peak RSS medians were 241,392 → 215,992 KiB on Node 24 and 206,392 → 200,676 KiB on Node 26; this does not establish a general product-memory reduction.
  • Before/after 18-event lifecycle parity passed on both runtimes. The additional six-event installation trace and permanent public-heartbeat regression prove immediate dispatch/settlement after a new admission; the regression failed before the timer-delay correction. All 88 focused tests across eight files passed, including real-timer transcript-context detachment.
  • Fresh P2 review passed with no findings on the corrected source.
  • Core and test type checks, targeted lint, formatting and all remaining selected guards passed. The aggregate check retains its two unrelated dead-export failures (canonicalProviderName and listPackagedStaticExtensionAssetOutputs), independently reproduced on clean baseline; production unused exports were zero. No guard was disabled or baseline changed.
  • Earlier CI failed the inherited type-routing fixture (repaired in feat: share browser dashboards with agents #146702), then the existing agents-other 702-root headroom guard. Main fix: speed up short session links in large stores #146803 restores that headroom. This branch was refreshed onto 2e0bfa16 with a byte-identical patch and unchanged measured source owners. Historical CI run 34748397234 attempt 1 failed after compact-large-9 and compact-large-11 did not acquire runners. Separate OpenGrep and sampled CodeQL jobs failed during code-scanning upload; the OpenGrep log records 106 rules on three files, zero findings and successful artifact upload, without making that failed scan a pass. Initial rerun calls returned HTTP 500 and 502 without starting another attempt. A later successful rerun request started attempt 2, which completed successfully at the unchanged reviewed head. The earlier upload/acquisition failures and uncertain lower-level causes remain recorded; the current CI result does not retroactively resolve or relabel them. Current exact-head CI run 34748397234, attempt 2 completed successfully at 615c47b133b3b83524ee98349c9cdd8be4e86cff (2026-09-13T10:10:29Z). The current required-check query reports openclaw/ci-gate SUCCESS. This supports native preparation; it does not claim merge or cleanup, or a rerun of unchanged local performance proof.

@clawsweeper

clawsweeper Bot commented Sep 13, 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.

@steipete
steipete marked this pull request as ready for review September 13, 2026 07:02
@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Sep 13, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 13, 2026, 4:54 AM ET / 08:54 UTC (Revision 6).

ClawSweeper review

What this changes

Reduce repeated scheduling scans during bursts of session-state notices while preserving wake deadlines, ordering, and caller settlement.

Merge readiness

✅ Ready for maintainer review

Keep open: this remains a useful, focused optimization absent from current main. No actionable correctness or security defect was found, and the previous review’s changed files are byte-identical at this head.

Priority: P2
Reviewed head: 615c47b133b3b83524ee98349c9cdd8be4e86cff

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused optimization with meaningful boundary tests and candid, narrowly scoped benchmark evidence; no blocking patch defect was found.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied repository state identifies a maintainer-authored PR, so the external-contributor gate does not apply. Its Windows source-copy measurements exercise notice-to-heartbeat admission and report dispatch/lifecycle parity; they do not establish full-Gateway latency gains.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied repository state identifies a maintainer-authored PR, so the external-contributor gate does not apply. Its Windows source-copy measurements exercise notice-to-heartbeat admission and report dispatch/lifecycle parity; they do not establish full-Gateway latency gains.
Evidence reviewed 10 items Introduced scheduler optimization: The pinned merge-base comparison confirms that admission alone passes a changed target; timer firing, dispatch completion, and handler replacement retain full scheduling scans. Installation deferral is recorded and cleared with the timer lifecycle.
Current-main necessity: Current main still iterates every pending group in schedulePending and invokes that scan on each admission; it does not contain the proposed targeted scheduling path.
Latest release comparison: The supplied latest release also contains the full pending-target scheduling scan, so it does not already provide this optimization.
Findings None None.
Security None None.

How this fits together

Session-state notices queue context for watching sessions and request heartbeat turns. The shared wake scheduler coalesces those requests, applies deadlines and concurrency limits, dispatches handlers, and settles waiting callers.

flowchart TD
  A[Session state changes] --> B[Queue watcher notices]
  B --> C[Shared wake scheduler]
  C --> D{Existing timer covers other work?}
  D -->|Yes| E[Check changed target]
  D -->|No or installation delay| F[Scan pending targets]
  E --> G[Dispatch ready handlers]
  F --> G
  G --> H[Settle callers]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +13, Tests +69. Total +82 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 20 7 +13
Tests 2 69 0 +69
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 89 7 +82

Review metrics

Metric Value Why it matters
Reported burst admission timing 128 targets × 3: Node 24, 2.3225 → 1.1735 ms; Node 26, 2.7183 → 1.0471 ms The measured benefit targets distinct-session bursts; small controls are mixed and no end-to-end gain is claimed.
Production versus test growth Production net +13 lines; tests +69 lines Production growth records the installation-delay exception; tests protect deadlines and settlement at existing entry points.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #146796
Summary: This PR is the implementation candidate for the linked notice-burst scheduling issue.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep scheduling in the existing owner, using its armed timer to avoid redundant admission scans while preserving lifecycle rescans and deadline semantics.

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

Yes at source level: each current-main admission scans the growing pending-target map during synchronous notice bursts. Performance measurements are supplied, but this review did not execute them.

Is this the best way to solve the issue?

Yes: the optimization reuses the timer and queue owner, explicitly handles installation deferral, and leaves global barriers, dispatch, retry, and settlement policies intact.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a bounded scheduling-performance improvement for larger notice bursts, without evidence of an urgent user-facing outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied repository state identifies a maintainer-authored PR, so the external-contributor gate does not apply. Its Windows source-copy measurements exercise notice-to-heartbeat admission and report dispatch/lifecycle parity; they do not establish full-Gateway latency gains.

Evidence

What I checked:

  • Introduced scheduler optimization: The pinned merge-base comparison confirms that admission alone passes a changed target; timer firing, dispatch completion, and handler replacement retain full scheduling scans. Installation deferral is recorded and cleared with the timer lifecycle. (src/infra/session-event-wake.ts:409, 615c47b133b3)
  • Current-main necessity: Current main still iterates every pending group in schedulePending and invokes that scan on each admission; it does not contain the proposed targeted scheduling path. (src/infra/session-event-wake.ts:408, f01640e3fb78)
  • Latest release comparison: The supplied latest release also contains the full pending-target scheduling scan, so it does not already provide this optimization. (src/infra/session-event-wake.ts:418, 3a9d69db306c)
  • Production entry point and ownership: enqueueSessionStateNotice queues the system event and requests a heartbeat with a 20-second coalescing deadline. The public heartbeat module delegates directly to the shared scheduler; no separate implementation or Codex dependency contract is introduced. (src/sessions/session-state-notices.ts:54, 615c47b133b3)
  • Observable regression coverage: The added cases check earlier and later distinct-target deadlines and immediate settlement of already-ready work after handler installation. Existing surrounding cases cover global barriers, bounded concurrency, replacement, and deferred retries. Tests were read, not executed in this read-only review. (src/infra/heartbeat-wake.settlement.test.ts:35, 615c47b133b3)
  • Scoped performance evidence: The captured PR body reports Windows source-copy notice-to-heartbeat admission measurements on Node 24 and 26, dispatch/system-event checks for 840 measured and 504 warmup bursts, and lifecycle parity. It explicitly discloses slower small controls and excludes timer-driven draining from timing. These are contributor-reported results, not reviewer-executed measurements. (615c47b133b3)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (5 earlier review cycles)
  • reviewed 2026-09-13T07:08:28.616Z sha ec5b547e3f54d20769c5b5746659f5b2f1242f0b :: needs maintainer review before merge. :: none
  • reviewed 2026-09-13T07:14:32.101Z sha ec5b547e3f54d20769c5b5746659f5b2f1242f0b :: needs maintainer review before merge. :: none
  • reviewed 2026-09-13T07:33:20.661Z sha 4ee1305b734710a616d23e000ca4179ff6a4a420 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-13T07:40:54.009Z sha 4ee1305b734710a616d23e000ca4179ff6a4a420 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-13T07:56:30.401Z sha 4ee1305b734710a616d23e000ca4179ff6a4a420 :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the codex/v8-event-wake-admission branch from ec5b547 to 4ee1305 Compare September 13, 2026 07:27
@steipete
steipete force-pushed the codex/v8-event-wake-admission branch from 4ee1305 to 615c47b Compare September 13, 2026 08:43
@steipete
steipete merged commit be3d809 into main Sep 13, 2026
312 of 322 checks passed
@steipete
steipete deleted the codex/v8-event-wake-admission branch September 13, 2026 10:17
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@jumardi2635-commits jumardi2635-commits left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jumardi2635-commit

vincentkoc added a commit that referenced this pull request Sep 13, 2026
* refs/heads/temp/pr-146883: (159 commits)
  fix: retain route ownership while discovering conversations (#146927)
  refactor: reuse plugin fixture shell runner (#146920)
  fix(worker): stop preparing disabled live previews (#146896)
  fix(runtime): support Bun across tooling suite (#146807)
  chore(i18n): refresh native locales (#146924)
  perf(secrets): limit expiry metadata to transient credentials (#146882)
  fix(ui): preserve queued refreshes during session discovery (#146535)
  test(ui): wait for quiet scrolling and close named file tabs (#146836)
  fix(ui): prevent Usage hour filters from freezing during DST (#146919)
  test(ui): share browser page cleanup across layout fixtures (#146805)
  ci: balance complete PR runtime test groups (#146916)
  improve(infra): reduce scheduling work for session notice bursts (#146818)
  improve: prepare Gateway skill commands asynchronously (#146812)
  improve(agents): skip unused assistant delivery parsing (#146858)
  improve(ui): reuse date formatters across timestamp lists (#146789)
  fix(tests): isolate installer and Docker shell snippets (#146897)
  test(heartbeat): share explicit channel configuration fixtures (#146853)
  fix: retain conversation reply claims through write admission (#146866)
  perf(sessions): bound history reads and stabilize cursor paging (#146770)
  fix(ui): let slow dashboard downloads finish before recovery (#146881)
  ...
vincentkoc added a commit that referenced this pull request Sep 13, 2026
* refs/heads/temp/pr-146833: (43 commits)
  fix(memory): preserve newer indexes and disclose automatic rebuild costs (#146908)
  fix: retain route ownership while discovering conversations (#146927)
  refactor: reuse plugin fixture shell runner (#146920)
  fix(worker): stop preparing disabled live previews (#146896)
  fix(runtime): support Bun across tooling suite (#146807)
  chore(i18n): refresh native locales (#146924)
  perf(secrets): limit expiry metadata to transient credentials (#146882)
  fix(ui): preserve queued refreshes during session discovery (#146535)
  test(ui): wait for quiet scrolling and close named file tabs (#146836)
  fix(ui): prevent Usage hour filters from freezing during DST (#146919)
  test(ui): share browser page cleanup across layout fixtures (#146805)
  ci: balance complete PR runtime test groups (#146916)
  improve(infra): reduce scheduling work for session notice bursts (#146818)
  improve: prepare Gateway skill commands asynchronously (#146812)
  improve(agents): skip unused assistant delivery parsing (#146858)
  improve(ui): reuse date formatters across timestamp lists (#146789)
  fix(tests): isolate installer and Docker shell snippets (#146897)
  test(heartbeat): share explicit channel configuration fixtures (#146853)
  fix: retain conversation reply claims through write admission (#146866)
  perf(sessions): bound history reads and stabilize cursor paging (#146770)
  ...
vincentkoc added a commit that referenced this pull request Sep 13, 2026
…ssion-list-roster-batch-20260913

* commit 'f513c0f345f7f2514c49ccfbc00adc3f78b9a755': (46 commits)
  chore(i18n): refresh native locales (#146924)
  perf(secrets): limit expiry metadata to transient credentials (#146882)
  fix(ui): preserve queued refreshes during session discovery (#146535)
  test(ui): wait for quiet scrolling and close named file tabs (#146836)
  fix(ui): prevent Usage hour filters from freezing during DST (#146919)
  test(ui): share browser page cleanup across layout fixtures (#146805)
  ci: balance complete PR runtime test groups (#146916)
  improve(infra): reduce scheduling work for session notice bursts (#146818)
  improve: prepare Gateway skill commands asynchronously (#146812)
  improve(agents): skip unused assistant delivery parsing (#146858)
  improve(ui): reuse date formatters across timestamp lists (#146789)
  fix(tests): isolate installer and Docker shell snippets (#146897)
  test(heartbeat): share explicit channel configuration fixtures (#146853)
  fix: retain conversation reply claims through write admission (#146866)
  perf(sessions): bound history reads and stabilize cursor paging (#146770)
  fix(ui): let slow dashboard downloads finish before recovery (#146881)
  fix: share Doctor lifecycle coordination with SQLite workers (#146714)
  fix: retain native session model provenance (#146801)
  fix: settle embedded transcript repairs before session cleanup (#146842)
  feat(macos): improve agent navigation and chat layout (#146531)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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.

perf: avoid repeated full wake scans during session-state notice bursts

2 participants