Repository navigation
improve: speed up cold declaration builds with spare memory - #149592
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 15, 2026, 10:24 PM ET / September 16, 2026, 02:24 UTC (Revision 2). ClawSweeper reviewWhat this changesAllow independent declaration compiler stages to run two at a time when CPU and available memory permit, with updated scheduling tests and build documentation. Merge readiness⛔ Blocked before merge - 2 items remain The optimization remains useful: current main only overlaps the two SDK groups, and the earlier merged work does not cover the six-group build. No introduced correctness defect was found; the maintainer-protected PR should remain open. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s build tooling turns TypeScript sources into packaged type declarations. Its declaration writer restores cached groups, compiles missing groups in private directories, and validates the complete output before publication. flowchart TD
A[TypeScript sources and cached declarations] --> B[Identify missing declaration groups]
B --> C{CPU and memory sufficient?}
C -->|Yes| D[At most two private compilers]
C -->|No| E[Serial compilation]
D --> F[Join children and validate outputs]
E --> F
F --> G[Publish declarations and refresh caches]
Before merge
Agent review detailsSecurityNone. PR surfaceTests +29, Docs 0, Other -1. Total +28 across 5 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one declaration scheduler with conservative memory admission, private compiler stages, and complete validation before publication. Do we have a high-confidence way to reproduce the issue? Not applicable as a correctness bug: current main deliberately serializes non-SDK groups, and the supplied repeated runs measure the resulting performance opportunity. Is this the best way to solve the issue? Yes. Generalizing admission in the existing writer avoids a competing scheduler and preserves serial fallback, failure settlement, and publication validation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 57956a7c8e80. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
What Problem This Solves
Cold unified declaration generation compiles its six independently staged groups serially, even when CPU and available memory can support two compiler processes. The same declaration owner already permits the two SDK groups to overlap.
User Impact
On the measured six-group declaration miss, average wall time fell from 207.53s to 133.70s on Node 24 (-35.57%) and 206.40s to 130.19s on Node 26 (-36.92%). Every one of the six adjacent baseline/candidate pairs improved wall time.
This trades resources for latency: average unit CPU increased 14.45% / 13.12%, sampled summed peak RSS increased 65.02% / 64.77%, and cgroup peak increased 66.83% / 61.87% on Node 24 / 26. These are declaration-stage measurements, not a whole-build or Gateway speedup claim.
Why This Change Was Made
Generalize the existing staged-declaration admission helper to canonical, distinct declaration groups. The existing executor still admits at most two nonempty, single-compiler private stages, preserves FIFO scheduling, joins all work before publication, and retains failure settlement, input validation and cache ownership.
Admission uses the two largest compiler heap budgets plus existing per-child native headroom. With the default 12 GiB heaps, it requires 25.5 GiB of known available capacity and at least two CPUs. Insufficient or unresolved capacity remains serial. No new configuration, heap override or cache policy is introduced.
Evidence
35046581005passed, includingopenclaw/ci-gateand its artifact build.631898047319e5b7e80827fe801510d79cfe87ac: normalpnpm build, Node 26.8.2 on Linux/WSL, default heaps/profile, 306.316s. All six unified declaration groups and both SDK groups compiled on cache misses, with at most two compiler processes. SDK export, runtime postbuild and UI build checks passed; all children joined, zero OOM, source/tool pins unchanged. Initial resource refusals were retained; the unchanged original floors were met before launch. No remote lease was created. This closes the normal-build integration requests in the review; it is not a paired whole-build timing comparison. Receipt SHA-256:52e80ffff2aeef8e87d6c2f0b9549da03e67335ffa2509add0c3de40da483577.Fixed measurement protocol and all twelve results
Fixed measurement protocol
Pinned base
8384aaf0517c62c097cf39658b75db8fe9f6bedd, Node 24.19.0 and 26.8.2, native Linux under WSL. Four separate correctness captures precede twelve timing arms: Node 24 BCCBBC, Node 26 CBBCCB. Each arm restores the same declaration inputs and retained SDK cache, then invalidates the same six non-SDK groups. Default compiler heaps remain unchanged.All sixteen runs passed complete declaration output and consumed-input parity (paths, bytes, modes and links; only the volatile cache stamp signature excluded). Every timing arm passed process identity, complete child settlement, source/tool stability and zero-OOM checks. No measured workload was retried or excluded.
Eight prelaunch resource refusals were retained before arms 03–06. No workload started on those attempts. The unchanged manifests and original resource floors were resubmitted after capacity recovered. A 19-minute scheduling gap before arm 06 also contained separate correctness checks, which joined before timing resumed. Slower candidate arms 06 (145.29s) and 07 (140.77s) remain in every aggregate.
The three-pair wall reductions range from 29.59–39.63% on Node 24 and 33.19–39.53% on Node 26. CPU and memory increased in all six pairs. Shared-host load and warm filesystem state can affect timings; this is a small repeated sample, not a statistical-significance claim. Unit CPU includes the observer. Summed RSS sampling can double-count shared pages or miss short peaks; cgroup memory includes page cache and is not RSS.
The complete retained analysis rehashes every saved validation and parity receipt. Analysis SHA-256:
2a95cd055c835c21e2c9daddea5113c68a9448b05241dbc22084f1e55b74cd7f; measured four-file patch SHA-256:4b8104cc9cedd3bd64ea43b5dea08c2d3a9128d30ec5cb648ce7a24c5266d450. The documentation-only addition does not change the measured code. The published change was rebased onto main6cf521932af06af674a90e2319ccbd6212261e5d; the five changed files and dependency manifests were unchanged at baseline, and range-diff, stable patch ID and all five resulting file hashes match the reviewed candidate.