Repository navigation
improve(tooling): reduce import-cycle check peak memory - #149266
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: needs maintainer review before merge. Reviewed September 15, 2026, 11:04 PM ET / September 16, 2026, 03:04 UTC (Revision 9). ClawSweeper reviewWhat this changesThe import-cycle checker avoids allocating fallback filenames when an import already matches a known source file or alias. Merge readiness✅ Ready for maintainer review This remains a useful, narrowly scoped optimization absent from current main. The resolver preserves existing behavior, the supplied measurements support the bounded memory claim, and no actionable defect was found. Priority: P3 Review scores
Verification
How this fits togetherOpenClaw’s development checks scan repository source imports and build a dependency graph. The import-cycle checker resolves those imports and reports runtime dependency cycles to developers and CI. flowchart TD
A[Repository source files] --> B[Runtime imports]
B --> C{Exact file or alias match}
C -->|Yes| E[Dependency graph]
C -->|No| D[Extension and index fallbacks]
D --> E
E --> F[Cycle report and exit status]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceOther +6. Total +6 across 1 file. View PR surface stats
Review metrics
Technical reviewBest possible solution: Retain the existing resolver and its ordering while avoiding unnecessary fallback allocation on successful direct lookups. Do we have a high-confidence way to reproduce the issue? Not applicable to a functional bug: this is a performance optimization. Source confirms the avoidable allocation, and the supplied real CLI measurements demonstrate the bounded Windows Node 24 improvement; this read-only review ran no target code. Is this the best way to solve the issue? Yes. Moving the existing first lookup ahead of fallback construction preserves lookup semantics without adding a cache, another resolver, or a public interface. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against c1c870a41755. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (8 earlier review cycles)
|
33b99e4 to
d3fa907
Compare
d3fa907 to
c8a83a0
Compare
|
Merged via squash.
|
What Problem This Solves
The import-cycle check constructs extension and index fallback paths even when an import already matches a known file or alias.
User Impact
Internal tooling only. In three fresh-process comparisons on Windows with Node 24.19.0, peak working set fell about 21% (roughly 64 MiB). Node 26.8.2 peak memory was effectively unchanged. This does not establish a CLI speedup: mean wall time changed +1.94% on Node 24 and -1.09% on Node 26; mean CPU time changed +1.50% and +0.97%, respectively.
Why This Change Was Made
Check the existing exact-file and alias matches before allocating the fallback candidates. The same resolver still owns extension/index priority, alias collisions, and unresolved imports. No cache, new interface, or persistent state is added.
Evidence
git diff --checkpassed. The required exact-head CI gate passed in run 35047779892.Three adjacent baseline/candidate pairs per runtime, with order BCCBBC on Node 24 and CBBCCB on Node 26. Positive deltas mean the candidate used more time or memory. All adverse samples are retained:
Each sample runs
node --import ./scripts/tsx.mjs scripts/check-import-cycles.tsagainst the same source base, 861766d, varying only this file. The publication base is57956a7c8e8061d0227d913002c380614d535fd9. The resolver baseline and measured patch remain byte-identical; the measurements above describe the original captured source base. These are fresh Node processes on a previously read filesystem; wall time includes startup. CPU and peak working set come from the retained Windows process handle and cover the direct process. Three pairs limit precision; no cold-cache, retained-heap, or universal platform claim is made.The original, unused 8 GiB host admission was revised to 6 GiB before any timing data, using the completed captures' 328–379 MB direct-process peaks. The 2 GiB process cap, twelve-run order, deadlines, and output assertions remained unchanged. Full source verification took longer under host load and is excluded from individual CLI timings.
Current integration: head
f038a9bd4ea52223bbfee3ec032dc8e8b4cf8e7brefreshes the unchanged patch onto57956a7c8e8061d0227d913002c380614d535fd9, including the landed cron synchronization repair #149412. The prior failed CI run 35007406393 remains retained and failed. Earlier native-fixture failures and their canonical repairs #149294/#149301 are also retained in the PR history. The exact-head required CI gate passed in run 35047779892; native landing gates remain required.The checker, shared graph helper, loader/shim/runtime sources and package.json are byte-identical to the measured inputs. Current lock/workspace changes concern the separate proxy-addr override; tsconfig adds an unrelated model-contract alias. Seventeen named retained TypeScript/tsx/esbuild files still match their recorded hashes. This is scoped source continuity, not a full dependency-closure or current-corpus equivalence claim. The Windows measurements above remain tied to frozen
861766ddc8ce334b3440f21c8089374de72a17ff; no benchmark was rerun for this refresh. Exact old/new patch comparison, range-diff, owner hashes andgit diff --checkpassed. Existing independent source review applies to the identical patch.