Skip to content

test(perf): add steady Gateway memory-retention soak - #177548

Merged
steipete merged 3 commits into
mainfrom
steipete/perf-micro-retained-growth-diagnostic-buffers-20260919
Oct 19, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/perf-micro-retained-growth-diagnostic-buffers-20260919

Conversation

@steipete

@steipete steipete commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Retained-memory investigations need sustained Gateway traffic and survivor-only allocation profiles; the existing benchmark captures finite bursts and allocation churn.

User Impact

No production behavior changes. Developers can run a paced Gateway soak with real tool execution, streamed replies, WebSocket viewers, periodic memory samples, and a final retained-allocation profile.

Why This Change Was Made

Extend the existing driver and private benchmark IPC instead of adding a second Gateway launcher. Keep allocation-churn sampling as the default. The new memory-soak scenario records natural-GC heap/external/ArrayBuffer samples separately from settled endpoints, bounds intentional transcript growth with recorded session resets, and captures only allocations surviving the final profiling window. Optional snapshots are taken after profiling stops.

Evidence

  • Focused test/scripts/gateway-bench-profile.test.ts: 8 tests pass. The retained-only regression fails against the old sampler: discarded allocation bytes are 92,388,232 instead of zero; with the change they are zero while held allocations remain observable.
  • pnpm tsgo:scripts passes using the repository typechecker. Changed-file oxfmt, lint, and git diff --check pass. Lint uses the supported OPENCLAW_OXLINT_SKIP_PREPARE=1 mode to avoid local artifact builds.
  • Independent Codex autoreview is clean through P2, including follow-up fixes for synchronized baseline timing, the traffic-duration clock, and restrictive fixture plugin allowlists. No Testbox/Crabbox lease; PR CI owns broad validation.
  • Isolated Linux Gateway smoke completed three measured cohorts, six real read-tool calls/results, streamed turns, four memory samples, and a survivor-only profile. The sustained-memory investigation continues separately. No production memory improvement is claimed by this tooling change.

Final-head CI 39299720322 completed on 9e4eed27f2a9cbb548b76ed2898a0c4dd4b2ddbc. The only substantive failure is inherited formatting in src/agents/tools/nodes-tool-media.ts; its aggregate CI gate is consequently red. The file is byte-identical on the tested merge e04d10e5 and actual CI base 74a8a5af (blob 3753432b85d185a11a72de58191f8c0e7ac9375e). The single-file oxfmt check fails on the same unchanged base content in an isolated Linux sandbox. All docs content checks, types, lint, architecture, security, and test jobs passed; CI specifically ran all eight Gateway profiling tests successfully. No CI rerun was requested.

The acceptance rule is completed streaming/tool turns and consistent viewer delivery, with separate natural-GC timelines and settled heap/external/ArrayBuffer endpoints. Before/after performance decisions use concurrent identical fixtures, separate ports/state, an exclusive measurement lock, and swapped sixteen-core CPU allocations. The documented workload is five minutes of warmup plus sixty minutes of paced traffic and a final ten-minute survivor profile.

Production runtime LOC delta: zero. The added benchmark controls and one existing-test extension implement the measurement contract; no new cache, production export, configuration option, or retention policy is introduced.

@clawsweeper

clawsweeper Bot commented Oct 19, 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 October 19, 2026 17:41
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 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-19T18:08:34.519781Z 9e4eed2 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.

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: M labels Oct 19, 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: d9a59d471c

ℹ️ 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 force-pushed the steipete/perf-micro-retained-growth-diagnostic-buffers-20260919 branch from d9a59d4 to f51610f Compare October 19, 2026 17:48

@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: f51610fee0

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

@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 19, 2026
@clawsweeper

clawsweeper Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR adds a paced Gateway memory soak with periodic resource samples and survivor-only allocation profiling.

Example: Run eight viewers and four concurrent turns for 60 minutes after five minutes of warmup.

  • Before: The driver measures finite bursts and allocation churn.
  • After: The memory-soak scenario repeatedly executes read tools and streamed turns, records memory samples, and profiles surviving allocations during the final window.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Useful tooling with a meaningful native sampler regression, but workload activation and measurement timing remain incorrect.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored tooling PR is outside the ordinary contributor proof gate; its body reports an isolated Linux Gateway smoke with completed tool turns, viewer delivery, memory samples, and a survivor profile, while the inspected regression exercises the real V8 sampler.
Patch quality 🦪 silver shellfish (2/6) 2 actionable review findings remain.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: Developers investigating retained memory lack a sustained workload that separates surviving allocations from short-lived churn.
Reason: The maintainer-authored direction adds useful diagnostic capability through existing tooling without changing production behavior.

Merge readiness

⛔ Needs changes before merge - 2 items remain

Keep this useful, maintainer-authored PR open: two measurement defects need focused repairs before merge.

Priority: P2
Reviewed head: f51610fee049a1c65fbc84e2c1ffda9314e8c561

Before merge

  • Enable the global plugin switch for the soak fixture (P2) - The documented input generated by scripts/perf/team-shape-fixture.ts has plugins.enabled=false. This block enables the diagnostics-prometheus entry and adjusts the allowlist, but preserves that global disable. resolvePluginActivationStateShared rejects all plugins before checking entries, so the default soak silently excludes the Prometheus workload promised by the README. Set the global switch in the soak-specific generated configuration.
  • Start the traffic duration after baseline sampling (P2) - measurementStartedAt is recorded before awaiting forced collection and the initial memory sample, but controls both the duration loop and retained-profile threshold. On the large heaps this tool targets, collection time therefore consumes the requested traffic interval; paired processes with different GC costs run different amounts of traffic. For example, a 30-second smoke with a five-second baseline has only about 25 seconds left for cohorts. Preserve any barrier timestamp separately and establish the traffic deadline after baseline sampling completes.

Findings

  • [P2] Enable the global plugin switch for the soak fixture — scripts/perf/transcript-broadcast-measure.ts:233-238
  • [P2] Start the traffic duration after baseline sampling — scripts/perf/transcript-broadcast-measure.ts:1405-1409
Agent review details

How this fits together

The repository benchmark launches an isolated Gateway, sends synthetic model responses through real agent and WebSocket paths, and collects resource samples and V8 profiles through private child-process IPC.

flowchart LR
  A[Benchmark CLI] --> B[Isolated Gateway]
  C[Synthetic model server] --> B
  B --> D[Read tool and streamed turns]
  B --> E[WebSocket viewers]
  A --> F[Private profiling IPC]
  F --> B
  F --> G[Memory samples and profiles]
Loading

Technical review

Best possible solution:

Keep the existing benchmark and IPC owners, enable the promised plugin workload, and start the traffic clock after baseline sampling.

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

Both findings follow directly from the generated fixture, plugin activation precedence, and deadline calculations; runtime reproduction was not attempted under the read-only review.

Is this the best way to solve the issue?

Extending the existing driver and profiler is appropriately scoped; the added native sampler regression protects a distinct failure without introducing another launcher or production owner.

Full review comments:

  • [P2] Enable the global plugin switch for the soak fixture — scripts/perf/transcript-broadcast-measure.ts:233-238
    The documented input generated by scripts/perf/team-shape-fixture.ts has plugins.enabled=false. This block enables the diagnostics-prometheus entry and adjusts the allowlist, but preserves that global disable. resolvePluginActivationStateShared rejects all plugins before checking entries, so the default soak silently excludes the Prometheus workload promised by the README. Set the global switch in the soak-specific generated configuration.
    Confidence: 0.99
  • [P2] Start the traffic duration after baseline sampling — scripts/perf/transcript-broadcast-measure.ts:1405-1409
    measurementStartedAt is recorded before awaiting forced collection and the initial memory sample, but controls both the duration loop and retained-profile threshold. On the large heaps this tool targets, collection time therefore consumes the requested traffic interval; paired processes with different GC costs run different amounts of traffic. For example, a 30-second smoke with a five-second baseline has only about 25 seconds left for cohorts. Preserve any barrier timestamp separately and establish the traffic deadline after baseline sampling completes.
    Confidence: 0.97

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Private heap sampling keeps the original intent (9449a1a: The original allocation profiler deliberately included collected objects to expose churn; the later shared-profiler refactor retained that behavior.)
  • Completed-operation allocation accounting keeps the original intent (778a1b7: perf(diagnostics): measure allocated bytes per RPC and turn #171686 measures allocated bytes per completed operation rather than treating live-heap deltas as allocation estimates; this PR preserves the churn default.)
  • Session reset and settled-resource measurements keeps the original intent (1929324: fix(agents): release prompt history after completed runs #176804 added attempt-retention workloads and post-GC samples to distinguish temporary recovery payloads from intentional transcript history.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test test/scripts/gateway-bench-profile.test.ts --maxWorkers=1
  • pnpm tsgo:scripts
  • node scripts/run-oxlint.mjs --tsconfig tsconfig.scripts.json scripts/perf/transcript-broadcast-measure.ts
  • git diff --check
  • Run the documented short memory-soak CLI against an isolated generated fixture and verify Prometheus activation, completed tool turns, viewer delivery, and traffic timing measured after baseline sampling.

What I checked:

Likely related people:

  • Vincent Koc: Raw commit 50ea179 adds scripts/lib/gateway-bench-profile.ts:28 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 50ea1795fc80; files: scripts/lib/gateway-bench-profile.ts)

PR surface

Tests +33, Docs +39, Other +167. Total +239 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 36 3 +33
Docs 1 39 0 +39
Config 0 0 0 0
Generated 0 0 0 0
Other 3 194 27 +167
Total 5 269 30 +239

Review metrics

Metric Value Why it matters
Benchmark controls 6 new CLI options Duration, warmup, cohort pacing, memory cadence, retained-profile duration, and reset cadence are confined to developer tooling.

Labels

Label changes:

  • add P2: Incorrect workload activation and timing can mislead memory investigations, with impact confined to developer benchmarks.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: Incorrect workload activation and timing can mislead memory investigations, with impact confined to developer benchmarks.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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.

Reviewed October 19, 2026, 2:03 PM ET / 18:03 UTC.

@steipete
steipete force-pushed the steipete/perf-micro-retained-growth-diagnostic-buffers-20260919 branch from f51610f to 9e4eed2 Compare October 19, 2026 18:06
@steipete

Copy link
Copy Markdown
Contributor Author

CI on 9e4eed27f2a9cbb548b76ed2898a0c4dd4b2ddbc is complete. Landing under the operator-authorized inherited-failure exception: the only substantive failure is check-docs → pnpm format:check → src/agents/tools/nodes-tool-media.ts; the aggregate CI gate reflects that failure.

The exact tested merge is e04d10e54a4d62f661a1fa47c19f317d6c751c5c, based on 74a8a5af3374affdadc3004833cc456dd23d4ffc. Both contain the unchanged failing blob 3753432b85d185a11a72de58191f8c0e7ac9375e; a focused oxfmt check on that base content also fails. All other CI jobs passed, including the eight Gateway profiling tests and security checks. Independent review is clean, and review findings are resolved. No rerun or unrelated source change was used to obtain green. Evidence: https://github.com/openclaw/openclaw/actions/runs/39299720322 .

@steipete
steipete merged commit dc81220 into main Oct 19, 2026
122 of 125 checks passed
@steipete
steipete deleted the steipete/perf-micro-retained-growth-diagnostic-buffers-20260919 branch October 19, 2026 18:18
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 20, 2026
* test(perf): add steady Gateway memory-retention soak

* fix(perf): align soak baseline with synchronized start

* fix(perf): exclude baseline collection from soak duration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. scripts Repository scripts size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant