Skip to content

improve: keep the lean Gateway from running out of memory on its first start - #203790

Merged
jalehman merged 5 commits into
mainfrom
perf/lean-startup-peak
Nov 23, 2026
Merged

jalehman merged 5 commits into
mainfrom
perf/lean-startup-peak

Conversation

@jalehman

@jalehman jalehman commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Related: #202379, #202373

What Problem This Solves

In a small container (1.5 GiB), the Gateway can run out of memory and be killed by the kernel a few seconds into its first start, while its first agent turn runs. On main 1a0a24dc, the lean profile hit this in 1 of 3 runs. The peak comes from start-up work all happening at once: the first turn, background maintenance, a process that launches commands, and a file-watching process.

User Impact

On hosts that auto-select the lean profile (under 8 GiB, or gateway.resources.profile: "lean"), the first turn after a start no longer competes with background start-up work for memory. Lean also uses one fewer helper process.

When memory runs out on Linux, the kernel now picks the file-watching helper or a database read helper before the Gateway. Both recover on their own.

Standard-profile hosts are unchanged, apart from that Linux kill preference and one fewer thread inside the file-watching helper.

Trade-offs on lean:

  • Post-ready maintenance, cron start and prewarming start once the Gateway is idle, at most 60 seconds after startup.
  • Commands start directly from the Gateway rather than through a separate launcher, which costs some fork latency. Hosts with 1 GiB or less already work this way.

Why This Change Was Made

Approved scope from #202379 (items 1, 2 and 4); the plan is in #202379 (comment).

  • Post-ready work waits for a quiet Gateway on lean. Standard releases post-ready work 500 ms after startup settles. That point lands inside a first turn sent right after ready. Lean first checks 2 s after settle, then every second, until no request root work is active, with a 60 s cap.
    • Post-ready maintenance now waits for the barrier before it admits its own root. Otherwise it would hold the idle check busy itself.
    • Requests never wait on anything behind the barrier. The native model catalog is advisory, and a turn acquires its own.
  • Lean skips the Linux command spawn broker, the same as the existing ≤1 GiB mode. It couldn't be started lazily, because SQLite readers need to spawn about 2 s into startup.
    • Bootstrap resolves the profile only later, so the broker gate predicts it from the CLI startup snapshot. On in-process restarts it predicts from the config being started instead, read with dotenv applied into an isolated env.
    • The plugin native-resource broker (the other worker.js) is unchanged. It already starts on demand, and it can't restart.
  • The directory watch helper on Linux now ends itself after its caller dies, using a timer instead of a second V8 isolate. macOS keeps the thread because of FSEvents close stalls.
  • OOM victim preference. The directory watch helper and natively spawned SQLite read-only helpers get oom_score_adj 1000, under the existing Linux child policy and its OPENCLAW_CHILD_OOM_SCORE_ADJ=0 opt-out.
    • Both brokers keep the Gateway's score. A killed native broker leaves plugin native resources unusable until restart, and repeated command-broker kills use up its restarts.
    • Documented in docs/platforms/linux.md.

Known bounded case: the retained-plugin cleanup idle task still waits inside its own admission, which is unchanged. If it fires at 30 s while the barrier is still held, lean's release waits for the 60 s cap.

Evidence

Real-behaviour campaign: done; the pass criterion is met. Read the numbers with care (n=3).

I re-ran the 1a0a24dc integration campaign on this head (8d78ba4e) with the same harness and method. Each case ran in its own Studio Crabbox local-container lease built from the pushed commit, under the membench lock, with MALLOC_ARENA_MAX=2, pinned profiles, and startup samples at +2/4/6/8 s and at first ready. I added a lean 1.5 GiB ×3 control on the merge base 80e233cd. Failures stay in the denominator, and nothing was rerun.

Completion:

  • Lean 1.5 GiB on this PR: 3/3, oom/oom_kill 0 in every round.
  • The merge-base control also completed 3/3. Completion alone doesn't separate this PR from main, and main's earlier 2/3 looks like a near-miss rather than a deterministic failure.
  • Standard 1.5 GiB: 2/3 again; r2 was OOM-killed, the same as on main. The PR is lean-only.
  • 3 GiB: all six rounds passed. The quick checks (auto 4/8 GiB, host, upgrade) and the shared-host fault case also passed.

Paired results, lean at 1.5 GiB, PR vs merge base (median and range; MiB unless noted):

PR merge base
First-start cgroup anon peak 1,145 (1,130–1,282) 1,312 (1,274–1,382)
First-start Gateway child PSS peak 149 (136–169) 212 (181–249)
First-start Gateway RSS peak 1,079 (1,064–1,216) 1,180 (1,142–1,250)
Gateway children at first ready 3 (watch host, native broker, transient reader) 4 (watch host, 2 brokers, …)
Live worker isolates at +8 s 19 22
Whole-run anon peak 1,371 (1,347–1,393) 1,401 (1,340–1,418)
memory.events max 5,227 (1,664–5,234) 5,785 (2,643–5,994)
Anon headroom to the limit: first start / whole run ~391 / ~165 ~224 / ~135
Time to first ready (s) 5.1 (5.07–5.22) 5.6 (5.14–5.65)
First measured turn (s) 5.54 (5.36–5.59) 5.52 (5.46–5.53)
Turn p95 / median (s) 1.55 / 1.17 1.77 / 1.17

How to read these:

  • Clear effects: child PSS is lower with no overlap between ranges, because the command broker no longer starts. The first-start anon peak is about 166 MiB lower at the median, and its ranges only just touch. Gateway RSS, max events and the whole-run peak are lower, but their ranges overlap.
  • memory.peak isn't informative here. It reached the 1,536 MiB limit in every 1.5 GiB round on both arms, because page cache fills the limit.
  • No latency cost at n=3.
  • Known gap: the deferral only partly cleared the startup window. It removed session-accessor.sqlite-archive and some session-transcript isolates from the +8 s window. But disk-budget, git-operation, fs-safe-copy and discovery still appear there: they're either turn-driven or started outside the post-ready barrier. That isn't attributed yet.

Redacted evidence: https://gist.github.com/jalehman/36f79343b766a90a8a504e79bc3e420f. It holds the report, per-case receipts, comparison.json, startup isolates, the quick checks, and the latest-stable upgrade capture, which shows 2026.11.6 → candidate with config, sessions and records preserved and a completed first turn. CI attribution: #203790 (comment).

The campaign measured 8d78ba4e. The current head bd3318d3 changes only how the helper OOM score is written (now an asynchronous write, so lean's direct SQLite reader spawns don't do synchronous /proc writes on request paths), plus ratchet hygiene.

Tests. Fail-first where the behaviour is new:

  • Lean release: held during an active turn, released at the first idle check, at the cap, and stopped on close. Standard timing is unchanged.
  • The real scheduleGatewayPostReadyMaintenance with the lean release: fails on the pre-fix ordering.
  • Broker gate: skipped for lean without disabling later starts, started for standard.
  • Profile prediction: snapshot, in-process restart, invalid or unreadable config, and dotenv substitution without mutating process.env.
  • OOM score written asynchronously to the watch helper and to native SQLite readers, never synchronously on the request path, and skipped when opted out.

Existing suites pass: post-ready lifecycle, the import boundary, spawn-broker context, directory watch (including parent death with open pipes), owned-directory observation, SQLite reader sessions, Linux OOM score, idle tasks, gateway work admission, and the wrapper source closure.

Also pass: tsgo:core, scoped oxlint, format, docs format, config:docs:check and git diff --check.

Three independent Astra reviews were run:

  • Two rounds found P2s: the maintenance root self-blocking the idle check, restart-time profile prediction, and dotenv parity. All were fixed.
  • The final round found no production P0–P2.

🦞 Made with OpenClaw

Lean holds post-ready maintenance until the Gateway goes quiet after startup, so a first turn no longer shares its memory with the maintenance isolates that work starts. Lean also skips the Linux command spawn broker, as hosts with 1 GiB or less already do, and the Linux directory watch helper ends itself after its caller dies with a timer instead of a second isolate. The directory watch helper and natively spawned SQLite read-only helpers become the preferred Linux OOM victims under the existing child OOM policy.
Post-ready maintenance admits its root before it waits for the barrier, so lean's idle check now ignores roots that are waiting on the barrier. The spawn broker placement reads the configured profile from the config being started when an in-process restart brings no CLI snapshot.
Post-ready maintenance and retained plugin cleanup now wait for the barrier before they admit root work, so lean's idle check counts only real requests. Profile prediction resolves dotenv values into an isolated env, as bootstrap would, without changing process env.
@clawsweeper

clawsweeper Bot commented Nov 22, 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 docs Improvements or additions to documentation gateway Gateway runtime app: linux plugin: linux-node size: L labels Nov 22, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 22, 2026
@clawsweeper

clawsweeper Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR defers lean startup background work, skips its Linux command broker, and reduces helper memory and OOM exposure.

Example: A lean Gateway starts in a 1.5 GiB Linux container and immediately receives an agent turn.

  • Before: Background work releases after 500 ms and a command broker remains resident; the reported median first-start anonymous-memory peak is 1,312 MiB.
  • After: Background work waits for idle, bounded at 60 seconds, and commands spawn directly; the reported median peak is 1,145 MiB.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful production-path measurements and a coherent patch support the improvement, with required upgrade validation still incomplete.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Partial
User problem: A first agent turn can compete with startup helpers and background work until a small Linux container kills the Gateway.
Reason: The maintainer-authored direction has a measurable memory benefit and explicitly accepts the bounded startup delay and direct-spawn tradeoff; the broader linked lean program remains open.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR provides a useful, measured reduction in lean Gateway startup memory, and current main retains the overlapping startup work; no actionable correctness defect was found.

Priority: P1
Reviewed head: bd3318d3487958a3ef6ca1e596c08bb4278e1034

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Provide a redacted v2026.11.7-to-candidate upgrade capture showing preserved settings and data plus a completed first turn; redact IPs, API keys, phone numbers, and non-public endpoints.
Agent review details

How this fits together

Gateway startup resolves resource policy and launches request and background runtimes; the scheduler controls background admission, while process owners launch and retire command, watch, and SQLite helpers.

flowchart TD
  A[Gateway startup] --> B[Resource profile selector]
  B --> C[Command spawn placement]
  B --> D[Post ready scheduler]
  E[Active request roots] --> D
  D --> F[Maintenance cron and prewarming]
  C --> G[Child process owners]
  G --> H[Linux OOM preference]
Loading

Technical review

Best possible solution:

Retain the bounded lean-only scheduling and direct-spawn changes using the existing resource, scheduler, and process owners.

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

Source confirms startup background work can overlap the first turn; the reported OOM is intermittent, and both paired lean arms completed three runs, so a deterministic current-main OOM reproduction is not established.

Is this the best way to solve the issue?

The patch addresses measured startup competition with bounded deferral and an existing direct-spawn mode, while preserving macOS watcher isolation and standard release timing.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Post-ready release timing changes intended behavior with a stated reason (65f3e42: The original barrier provided a short I/O window before background imports competed with startup CPU.)
  • Scheduler ownership and maintenance admission keeps the original intent (d9d4066: One Gateway scheduler owns release and maintenance timing, cancellation, and joins; this PR keeps that owner while avoiding a barrier waiter counting as active work.)
  • Linux command broker changes intended behavior with a stated reason (67cedc3: A small spawning parent avoids Linux page-table-copy stalls; the PR explicitly trades that optimization for lower lean resident memory.)
  • Existing constrained-host direct spawning keeps the original intent (67ecf6b: Hosts with at most 1 GiB already skip the optional broker to preserve memory for requests.)
  • Directory-watch isolation and parent monitoring keeps the original intent (0dc6b7f: A separate monitor ends a helper whose main loop can block during macOS FSEvents cleanup; this PR retains that thread off Linux and retains the watch helper itself.)
  • Shared resource-profile selection keeps the original intent (28aa5c8: One startup owner selects lean below 8 GiB, with explicit configuration taking precedence; prediction reuses the same selection logic without publishing another profile.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Introduced change and current main: The pinned introduced diff changes the startup barrier and broker placement. Fetched main still releases post-ready work after 500 ms and skips the broker only under the existing small-memory threshold. (src/gateway/server-start.ts:148, bd3318d34879)
  • Existing owners and bounded scheduling: The change retains the shared scheduler and root-work counter, moves maintenance's barrier wait before root admission, and preserves immediate barrier release during close and startup failure. (src/gateway/server-post-ready-release.ts:32, bd3318d34879)
  • Measured benefit and accepted tradeoffs: The maintainer-authored PR records the lean-only delay and direct-spawn latency tradeoff. Its reported paired campaign has three lean completions per arm, a first-start anonymous-memory median of 1,312 → 1,145 MiB, and one fewer child process; these results support reduced memory pressure rather than guaranteed OOM prevention. (8d78ba4e9226)
  • Upgrade evidence and release baseline: The contributor's public capture describes a 2026.11.6 upgrade preserving config, session messages, and Knowledge records with a completed first turn. GitHub confirms v2026.11.7 was published on 2026-11-23, so the disclosed run does not exercise the latest stable baseline. (e31bbf056de3)
  • Campaign artifact access limitation: The prior request to attach sanitized captures was addressed with a linked gist and a self-contained public evidence summary at improve: keep the lean Gateway from running out of memory on its first start #203790 (comment). The review token cannot read gists and the proxy blocks the raw artifact host; this infrastructure limitation is not treated as a contributor defect.
  • Reviewed head and CI: GitHub still reports head bd3318d as mergeable, with the aggregate CI gate pending; the security-sensitive status reports no sensitive product changes. Pending checks are not attributed to a patch defect. (bd3318d34879)

Likely related people:

  • Josh Lehman: Raw commit 28aa5c8 adds src/infra/gateway-resource-profile.ts:17 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 28aa5c88fd45; files: src/infra/gateway-resource-profile.ts)
  • Peter Steinberger: Raw commit 67cedc3 adds src/process/spawn-broker/context.ts:18 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 67cedc32e996; files: src/process/spawn-broker/context.ts)
  • Vincent Koc: Raw commit 67ecf6b adds src/process/spawn-broker/context.ts:19 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 67ecf6bf352d; files: src/process/spawn-broker/context.ts)

PR surface

Source +165, Tests +378, Docs +24. Total +567 across 20 files. Added test files: 3.

View PR surface stats
Area Files Added Removed Net
Source 11 187 22 +165
Tests 7 378 0 +378
Docs 2 24 0 +24
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 20 589 22 +567

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P1: The targeted first-start memory pressure can terminate the Gateway during an agent turn on constrained Linux hosts.
  • 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.

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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-11-22T22:42:52.373Z sha 8d78ba4 :: needs maintainer review before merge. :: none
  • reviewed 2026-11-23T02:50:00.936Z sha 8d78ba4 :: needs maintainer review before merge. :: none

Reviewed November 22, 2026, 11:36 PM ET / November 23, 2026, 04:36 UTC (Revision 3).

@jalehman
jalehman marked this pull request as ready for review November 23, 2026 02:43
@jalehman

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Nov 23, 2026
Lean spawns SQLite readers directly, so their OOM score write ran synchronously on Gateway request paths. The watch helper and native readers now raise their score with an asynchronous write. Also satisfy the assertion-safety and mock-exports ratchets.
@jalehman

jalehman commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Evidence and CI attribution for head bd3318d3

Redacted campaign evidence

Gist: https://gist.github.com/jalehman/36f79343b766a90a8a504e79bc3e420f

It contains no transcripts, hostnames, local paths or credentials:

File Contents
report.md the campaign report
cases.json every case: exit code, verified turns, oom/oom_kill/max deltas
comparison.json the paired per-round metrics and startup series for the PR, the merge base 80e233cd and 1a0a24dc
startup-isolates.json per-sample worker isolates and Gateway child processes
quick-checks.json auto 4 GiB → lean, auto 8 GiB → standard
harness-manifest.json harness and driver hashes
upgrade-proof-summary.json the latest-stable upgrade capture described below

Upgrade capture (k-upgrade-3072, PR head 8d78ba4e):

  • Starting release: in a 3 GiB container, the Gateway ran stable 2026.11.6 and created three synthetic Knowledge records, saved through agent turns.
  • After upgrading to the candidate:
    • Under auto, the candidate resolved lean (reason memory, cgroup v2 limit 3 GiB).
    • configPreserved, sessionMessagesPreserved and recordsPreserved are all true.
    • The HTTP server started listening, and the agent database recovered after background inspection.
    • A first turn completed: chat.send, then agent.wait ✓ in 1.9 s.
  • Shutdown: it logs Plugin runtime still owns resources. The same line appears in the 1a0a24dc upgrade capture, so it is pre-existing and not changed by this PR.

The code delta from 8d78ba4e to bd3318d3 touches only the OOM-score write and test and type hygiene. The campaign measurements came from 8d78ba4e.

CI attribution (run 45101871140 on 8d78ba4e)

Caused by this PR, fixed in bd3318d3:

  • checks-node-changed-compact-large-21 (server-worker-placement-session-evidence.test.ts, { writeFileSync: 1 }): the OOM-score write for natively spawned SQLite readers and the watch helper was synchronous on the request path. It is now an asynchronous write.
  • checks-fast-baseline-ratchets: the job died with "runner lost communication". Running the ratchets locally against 80e233cd found two failures from this PR, both now fixed:
    • assertion-safety: an uncommented as in server-startup-resource-profile.ts, replaced with a type guard.
    • mock-exports: a vi.mock without importOriginal in context.lean.test.ts.
    • The other ratchets pass.

Inherited. Each of these was reproduced with the same failing tests on the merge base 80e233cd, in a detached checkout with pnpm vitest run (e2e config where applicable):

Job Failing test file(s) Base result
compact-large-8-2 server-http.openai-compat.test.ts (3× "policy changed", 401 vs 200) same 3 fail
compact-large-5-1 server.sessions.create.projects.test.ts 3 fail on base
compact-small-4-2 server.sessions.create.durability.test.ts 8 fail on base
compact-large-40-1 server-methods/sessions-create-device-folder.test.ts (revoked while validating) same 1 fails
checks-node-changed-2 gateway-skill-authoring-plugin.e2e.test.ts same failure (expected [] to have a length of 1)
compact-small-4-3 server.openclaw-id-member-suspension.test.ts, server.config-security-policy.test.ts 3 / 2 fail on base
compact-large-8-1 server.plugin-reload-send-revocation.product.test.ts fails on base
compact-large-4-2 server.sessions.create.lifecycle.test.ts (durable replay revocation), server.chat-abort-initiator.product.test.ts 1 / 1 fail on base
compact-large-9 flows/doctor-health.legacy-update.test.ts, mcp-http.async-scope.test.ts, server.chat-membership-authority.product.test.ts 3 / 1 / 1 fail on base
compact-large-31 server-cron-failure-repair.final-effect.test.ts 11 fail on base
checks-node-changed-3 agents/bash-tools.exec-gateway-approval.e2e.test.ts (hook token source across reload) same failure

The remaining failures are not jobs in their own right: openclaw/ci-gate is the aggregate of the above, and the auto-response, dispatch and PR context and evidence cancellations came from the draft → ready transition.

A fresh CI run is now on bd3318d3.

🦞 Made with OpenClaw

@jalehman

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Nov 23, 2026
@jalehman

Copy link
Copy Markdown
Contributor Author

CI attribution for head bd3318d3: run 45112306833, attempt 2

Every failed job is attributed to main; none exercises code this PR changes. "Base" means the same test file run locally without this PR, on merge base 80e233cd or on d2915cd01c, which is the main parent of the CI-tested merge 8bd56e2e.

Job Failing test(s) Evidence
compact-large-40-2 server-http.openai-compat ×3 ("policy changed", 200 vs 401) Same 3 fail on 80e233c
compact-large-5-1 server.sessions.create.projects:1013 Fails on 80e233c
compact-small-4-3 server.openclaw-id-member-suspension ×3, server.config-security-policy Both fail on 80e233c
compact-small-4-4 server.session-row-baselines.integration, server.session-row-deltas.integration Both fail on 80e233c
checks-node-changed-2 gateway-skill-authoring-plugin.e2e:217 Same failure on 80e233c
compact-large-4-3 server.sessions.create.lifecycle (durable replay revocation), server.chat-abort-initiator.product Both fail on 80e233c
compact-small-4-2 server.sessions.create.durability ×3 Fails on 80e233c (8 there)
compact-large-10-1 mcp-http.async-scope:266 Fails on 80e233c
compact-large-29 server-methods/sessions-create-device-folder:178 Fails on 80e233c
compact-large-41 flows/doctor-health.legacy-update:336 ×3 Same 3 fail on 80e233c
compact-large-21 server.talk-consult-history ("isolates registered Talk replay across authenticated callers") Fails on 80e233c
compact-large-31 server-cron-failure-repair.final-effect Fails on 80e233c
checks-node-changed-3 agents/bash-tools.exec-gateway-approval.e2e:524 Same failure on 80e233c
compact-large-19-1 server.chat-membership-authority.product:149 Fails on 80e233c
compact-large-40-1 server.plugin-reload-send-revocation.product Fails on 80e233c
compact-large-40-1 server.guest-history-http (200 vs 404 at :69 via the revocation-during-snapshot race at :101) See note below
check-docs format:check flags only src/update/AGENTS.md This PR doesn't touch it; added on main in 2e8c1ad (#203914), and main CI run 45112229424 failed check-docs on that commit
ci-gate aggregate of the jobs above —

server.guest-history-http note. This test passes locally on 80e233c and on bd3318d3 alone, under bun, both as a single file and in the full 12-file shard with 3 workers. It fails with the CI assertion on d2915cd01c alone (no PR changes) and on the merge tree 8bd56e2e. The test file is identical in both. The likely cause is #203847, "check runtime and HTTP authority once at request start" (14f185b), which landed on main between the merge base and d2915cd01c.

The CI runner has 4 CPUs and 16 GiB, so the Gateway resolves the standard profile there, and this PR's lean-only paths are inactive.

The single job rerun (attempt 2) was diagnostic only and failed the same way.

ClawSweeper's exact-head review of bd3318d3 reported no findings.

@jalehman
jalehman merged commit 0e45cc7 into main Nov 23, 2026
235 of 272 checks passed
@jalehman
jalehman deleted the perf/lean-startup-peak branch November 23, 2026 06:12
@jalehman

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

tideclaw-bot pushed a commit that referenced this pull request Nov 24, 2026
…es (#203241)

* fix(gateway): shutdown never first-imports chunks an in-place update replaced

* test(gateway): guard built shutdown against late first-imports

* fix(gateway): keep broker close functions visible to dead-export scan

* fix(process): supervisor shutdown warnings never first-import their logger; guard tracks pre-signal modules

* test(ci): watch supervisor shutdown owners for the late-import guard

* test(gateway): readable late-import entry parsing

* test(gateway): stop the guard Gateway after startup maintenance settles

* test(gateway): guard only hashed dist chunks that a swap removes

* test(gateway): skip the SIGTERM guard where taskkill stops the Gateway

* fix(gateway): prime supervisor shutdown logger from the shutdown runtime; add restart worker to PR wrapper inventory

* fix(memory-core): own the manager runtime loader in a leaf module so closing never loads the provider

* fix(state): agent lease cleanup handler loads with the state worker; guard stop budget and watch paths

* fix(cron): claimed runs load their finalization before shutdown can need it; watch memory loader owners

* fix(cron): scheduled runs also load finalization with their scheduler

(cherry picked from commit 78a6ca1)

Release adaptation: Preserve the stable cron dispatch preamble and command set, without main-only cron.importLegacyMemberSources; scheduler and queue still prepare finalization together. The shutdown-runtime overlap is supplied by the preceding #203185 backport.

Companions: #203185 selected and applied first. #203839 replaces test process ownership separately and is not required for this guard: the stable fixture supports the same child, entrypoint and stop APIs. #203790, #202507, #202495 startup/resource changes, #201024 cgroup sizing, #197395 cron backoff, and #204210/#203458/#203271 wrapper-only overlaps are not dependencies.
Co-authored-by: RomneyDa <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 24, 2026
…t start (openclaw#203790)

* perf(gateway): cut the lean first-start memory peak

Lean holds post-ready maintenance until the Gateway goes quiet after startup, so a first turn no longer shares its memory with the maintenance isolates that work starts. Lean also skips the Linux command spawn broker, as hosts with 1 GiB or less already do, and the Linux directory watch helper ends itself after its caller dies with a timer instead of a second isolate. The directory watch helper and natively spawned SQLite read-only helpers become the preferred Linux OOM victims under the existing child OOM policy.

* fix(gateway): release lean post-ready work past its own waiters

Post-ready maintenance admits its root before it waits for the barrier, so lean's idle check now ignores roots that are waiting on the barrier. The spawn broker placement reads the configured profile from the config being started when an in-process restart brings no CLI snapshot.

* fix(gateway): wait for post-ready work before admitting its root

Post-ready maintenance and retained plugin cleanup now wait for the barrier before they admit root work, so lean's idle check counts only real requests. Profile prediction resolves dotenv values into an isolated env, as bootstrap would, without changing process env.

* fix(gateway): keep retained plugin cleanup scheduling unchanged

* fix(gateway): raise helper OOM scores off the event loop

Lean spawns SQLite readers directly, so their OOM score write ran synchronously on Gateway request paths. The watch helper and native readers now raise their score with an asynchronous write. Also satisfy the assertion-safety and mock-exports ratchets.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: linux docs Improvements or additions to documentation gateway Gateway runtime P1 High-priority user-facing bug, regression, or broken workflow. plugin: linux-node rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L 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