Skip to content

perf(subagents): release settled run text from memory - #173548

Merged
steipete merged 6 commits into
mainfrom
steipete/perf-micro-completed-run-text-retention-20260919
Oct 16, 2026
Merged

steipete merged 6 commits into
mainfrom
steipete/perf-micro-completed-run-text-retention-20260919

Conversation

@steipete

@steipete steipete commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Settled subagent runs retained full task and result strings in the live registry, persisted-row cache, and session-list indexes for the lifetime of retained history. Aggregate-only heap analysis identified 7,080 registry task holders (25.16 MiB), 6,635 completion result holders (33.70 MiB), and 704 pending-delivery task holders (2.93 MiB). Retainer paths overlap; these are not additive retained-size claims. No snapshot or user text was exported.

User Impact

Completed runs release large task/result payloads after cleanup and requester obligations settle. Full selected reads, later metadata writes, and restart recovery preserve durable text. Pending/suspended delivery, requester settlement, yielded work, and cancellation retain their payloads.

Why This Change Was Made

The existing registry keeps a detached 160-character task preview and hydrates selected payloads through its worker reader. FIFO mutations hydrate before planning, preventing later metadata writes from replacing durable text with a preview. Session-list indexes retain compact facts with the original runtime identity, preserving executor/reservation liveness. They compare ownership and displayed facts so progress-only publications do not invalidate projections.

No schema, stored format, durable-retention, or configuration change. Production delta: +159 lines net (+212/-53). The growth implements the required hydration boundary while preserving durable text and lifecycle ownership.

Scope: compact identity/status records remain resident for topology and authorization; this does not cap record count or total registry memory. Structured collector results, schemas, and diagnostic strings remain unchanged. Collector schemas also participate in synchronous request authorization. Visible terminal-reply evidence retains its existing 4,096-character bound.

Evidence

Measurement

Isolated Linux fixture uses the real registry writer, resident caches, session-list index, and forced GC: 6,000 completed runs across 5,000 child-session keys, in batches of 64. Each has independent 4,096-character task and 6,144-character result strings plus a retained 4,096-character visible reply. This is subsystem memory proof, not a whole-Gateway load test.

At 6,000 completed runs Parent Final production code
Retained heap 103.16 MiB 53.42 MiB
Retained heap per 1,000 runs 17.19 MiB 8.90 MiB
RSS after GC 1,073.29 MiB 1,042.95 MiB
Peak RSS 1,095.84 MiB 1,044.54 MiB
Whole-process elapsed time 14.10 s 14.29 s
Resident full result characters 36,864,000 0
Resident task characters 24,576,000 960,000

Retained heap falls 48.2%. RSS/time include the source loader, workers, and initialization; elapsed time is effectively neutral in this single paired run, with no throughput gain claimed. Earlier heap baselines varied by about 4.45 MiB; the table uses the conservative final paired result. A fixture without visible replies retained 79.13 → 23.79 MiB (13.19 → 3.97 MiB/1,000).

Representative observed retainers: Object.runs -> SubagentRunMap.table -> array -> Object.task, SubagentRunIndex.latest -> Map.table -> array -> Object.task, session-list inMemoryRuns / inMemoryDisplayByChildSessionKey, and Object.completion -> Object.resultText.

Validation

  • Forced-GC worker regression: 64 completed runs with 16 MiB of independent task/result text retain less than 6 MiB, including sliced visible replies. Both catalog policies pass; durable reads, later writes, and compact restart restoration preserve payloads.
  • Focused memory, worker, scoped-read, async-state, and executor/reservation-liveness tests pass.
  • CI-driven focused repairs pass: lifecycle 227, completion store 13, requester wake 35, registry seam 103, task replacement 15, cancellation publication 7, announcement cancellation 13, sessions.send 4, replay harness 16, projection 5, affected cron/restart cases 2, sessions-reset cleanup 18, swarm integration 1, historical cancellation 22, owner counts 3, and real Gateway startup/recovery WebChat 1.
  • Fixtures persist acknowledged payloads, assert full text through durable readers, and publish immutable replacements. Existing behavior assertions remain intact. A readiness fix separates payload hydration from catalog preparation in the existing catalog-disabled test mode.
  • Export-name guard, two script-closure files (21 tests), changed-file formatting/lint, and diff checks pass. Mock-baseline generation removes two obsolete exceptions and adds none.
  • Independent subagent review (autoreview route unavailable): all actionable findings addressed; final P0/P1/P2 review clean.
  • Final exact-head PR CI run passed on 8dda2ed52038a9849597869c1644638d74b13687, including PostgreSQL conformance, changed tests, typechecks, lint, and the combined CI/security gate. The last review repair replaces a broad partial mock with an explicit isolated factory; all seven scoped-read cases and the mock-export ratchet pass. Earlier runs exposed the repaired fixture/readiness issues and one GitHub download timeout during setup; none are described as passing evidence. No Testbox/Crabbox lease was allocated under this lane's validation policy.

@clawsweeper

clawsweeper Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: M labels Oct 15, 2026
@steipete
steipete marked this pull request as ready for review October 15, 2026 23:24
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 2026 •

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-16T00:06:11.484141Z 8aa841d New commits
ℹ️ 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3f19f828f0

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: L and removed size: M labels Oct 15, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cfed1522ad

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8aa841db28

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@steipete
steipete merged commit f4f4b19 into main Oct 16, 2026
136 checks passed
@steipete
steipete deleted the steipete/perf-micro-completed-run-text-retention-20260919 branch October 16, 2026 00:33
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 16, 2026
* perf(subagents): release settled run text from memory

* test(subagents): cover sliced terminal reply retention

* fix(subagents): preserve compact read ownership and hydration readiness

* test: prune obsolete mock export allowances

* test(subagents): preserve durable payloads in integration fixtures

* test(subagents): isolate scoped registry read fixtures
steipete added a commit that referenced this pull request Oct 17, 2026
The lifecycle fixture gained durable persistence in f4f4b19 (#173548). Its first write starts SQLite idle-retirement and WAL-maintenance timers, contaminating the fresh-yield test fake clock even though the requester retry timer is cleared correctly.

Initialize fixture storage before enabling fake timers. Preserve every timer-count and duplicate-wake assertion; no product behavior changes.

Validation: reproduced the original failure under Bun and Node; all 291 lifecycle, retry, and requester-yield tests pass under each runtime. Targeted type-aware lint, format, diff checks, and Codex review pass.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 18, 2026
The lifecycle fixture gained durable persistence in 1b8b54b (openclaw#173548). Its first write starts SQLite idle-retirement and WAL-maintenance timers, contaminating the fresh-yield test fake clock even though the requester retry timer is cleared correctly.

Initialize fixture storage before enabling fake timers. Preserve every timer-count and duplicate-wake assertion; no product behavior changes.

Validation: reproduced the original failure under Bun and Node; all 291 lifecycle, retry, and requester-yield tests pass under each runtime. Targeted type-aware lint, format, diff checks, and Codex review pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant