Skip to content

improve(tooling): reduce commit formatting resource use - #152297

Merged
steipete merged 1 commit into
mainfrom
codex/perf-staged-format-workers-7006
Sep 19, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/perf-staged-format-workers-7006

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

The commit hook can exhaust a constrained host's task limit while formatting a small staged change that includes Markdown.

User Impact

Developers get substantially lower commit-hook CPU, memory and task demand. The measured four-file batch finished faster; the forty-file batch took about 115 ms longer (+16.9%). There is no OpenClaw runtime behavior change.

Why This Change Was Made

Use the same single-worker formatting policy already used by format, format:fix and format:diff. The staged hook previously let oxfmt select all available workers; on this host, formatting one Markdown document could initialize a 32-process external formatter pool. The existing stdin path for partially staged files already uses one worker and is unchanged.

Evidence

  • Real git-hooks/pre-commit entry point on Linux, Node 24.19.0 and installed oxfmt 0.67.0. Fixed B1/C1/C2/B2 order for each batch, fresh fixture/index/HOME/cache for every arm, identical 2 GiB/no-swap/1024-task limits, no retries.
  • Complete staged contents, working-file contents and Git index entries matched across all four arms in each batch. A separate B/C control preserved both partially staged working files byte-for-byte while formatting their staged blobs and excluding unstaged remainders.
  • Four-file mean wall time: 0.500→0.370s (−26%); CPU: 1.775→0.450s (−74.6%). Forty-file mean wall time: 0.680→0.795s (+16.9%); CPU: 4.265→1.210s (−71.6%). Unit peak memory fell about 71%, and peak tasks about 75%, in both batches.
  • All ten supervised invocations exited 0 with dead process groups, empty final scoped censuses, absent systemd units and unchanged source/install pins. Independently rechecked 140 raw artifact hashes.
  • Fresh maintained review: no actionable P0–P2 findings. All 81 tests in both existing hook test files passed, with no failures or skipped tests. Scoped formatting, lint of both changed test files (zero warnings/errors), and git diff --check passed. Source/dependency/index fences and process cleanup checks passed. The changed-check planner also passed; this is not a full local check:changed pass. Full exact-head hosted gates remain required before native prepare/merge.
Batch Arm Hook wall (s) CPU user+system (s) Unit peak (MiB) Peak tasks
3 TypeScript + 1 Markdown B1 0.51 1.77 552.523 331
3 TypeScript + 1 Markdown C1 0.37 0.44 155.852 83
3 TypeScript + 1 Markdown C2 0.37 0.46 158.441 83
3 TypeScript + 1 Markdown B2 0.49 1.78 542.438 331
32 TypeScript + 8 Markdown B1 0.66 4.13 850.355 330
32 TypeScript + 8 Markdown C1 0.83 1.24 244.047 82
32 TypeScript + 8 Markdown C2 0.76 1.18 246.605 82
32 TypeScript + 8 Markdown B2 0.70 4.40 859.836 330

CPU is GNU time's child-inclusive user+system time. Unit memory/task peaks include fixture preparation and the common supervisor; Linux tasks include threads. These are two observations per variant on one host, not a universal latency improvement. The earlier 256-task EAGAIN failure and subsequent 1024-task successful commit are historical resource-control evidence, not the timing comparison above.

@clawsweeper

clawsweeper Bot commented Sep 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.

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: XS maintainer Maintainer-authored PR labels Sep 19, 2026
@steipete
steipete marked this pull request as ready for review September 19, 2026 00:19
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 19, 2026
@clawsweeper

clawsweeper Bot commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 18, 2026, 8:23 PM ET / September 19, 2026, 00:23 UTC.

ClawSweeper review

What this changes

The PR limits staged-file formatting to one worker and updates existing hook tests to expect that limit.

Merge readiness

✅ Ready for maintainer review

Keep open: this remains a useful, narrowly scoped improvement absent from current main and the latest release. No actionable correctness or security findings were identified.

Priority: P2
Reviewed head: 2bd92ea3ed71faf2708148218fa72a910ef1d7e0

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, correct tooling change with unusually detailed controlled performance evidence and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The supplied measurements exercise the real commit-hook entrypoint and installed formatter after the change, showing reduced resource demand with matching staged output and preserved partial edits; the Linux-only scope and larger-batch slowdown are disclosed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The supplied measurements exercise the real commit-hook entrypoint and installed formatter after the change, showing reduced resource demand with matching staged output and preserved partial edits; the Linux-only scope and larger-batch slowdown are disclosed.
Evidence reviewed 8 items Verified introduced change: The pinned merge-base-to-head diff adds --threads=1 to the existing batch formatter invocation and adjusts two existing expectations; file selection, staging, partial-file handling, and content checks are unchanged.
Current main still needs the change: The fetched main revision still invokes batch oxfmt without a worker limit.
Latest release comparison: The supplied latest release, v2026.9.4, also lacks the batch worker limit.
Findings None None.
Security None None.

How this fits together

OpenClaw’s local commit hook checks staged content, formats eligible files, and updates the Git index. Fully staged files use batch formatting; partially staged files retain a separate path that preserves unstaged edits.

flowchart TD
  A[Git commit] --> B[Staged content guard]
  B --> C{Fully staged file?}
  C -->|Yes| D[Single-worker batch formatting]
  C -->|No| E[Format staged blob only]
  D --> F[Update Git index]
  E --> F
  F --> G[Final content check]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests 0, Other 0. Total 0 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 2 2 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 3 3 3 0

Review metrics

Metric Value Why it matters
Measured resource tradeoff CPU −71.6–74.6%; forty-file wall time +115 ms The reported controlled Linux runs quantify substantial resource savings while explicitly disclosing the larger-batch latency cost.

Technical review

Best possible solution:

Use the existing single-worker formatter policy in the batch commit-hook path while retaining staged-byte preservation and content checks.

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

The resource-use mechanism is clear from source and the supplied controlled hook runs; reproducing task-limit exhaustion remains host-dependent and was not independently rerun in this read-only review.

Is this the best way to solve the issue?

Yes. Applying the already-supported worker limit at the existing batch invocation is a narrow repair that preserves formatter configuration, file selection, and staging behavior.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This addresses commit-hook resource exhaustion on constrained development hosts with a limited tooling-only change.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The supplied measurements exercise the real commit-hook entrypoint and installed formatter after the change, showing reduced resource demand with matching staged output and preserved partial edits; the Linux-only scope and larger-batch slowdown are disclosed.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The supplied measurements exercise the real commit-hook entrypoint and installed formatter after the change, showing reduced resource demand with matching staged output and preserved partial edits; the Linux-only scope and larger-batch slowdown are disclosed.

Label justifications:

  • P2: This addresses commit-hook resource exhaustion on constrained development hosts with a limited tooling-only change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The supplied measurements exercise the real commit-hook entrypoint and installed formatter after the change, showing reduced resource demand with matching staged output and preserved partial edits; the Linux-only scope and larger-batch slowdown are disclosed.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied measurements exercise the real commit-hook entrypoint and installed formatter after the change, showing reduced resource demand with matching staged output and preserved partial edits; the Linux-only scope and larger-batch slowdown are disclosed.

Evidence

What I checked:

  • Verified introduced change: The pinned merge-base-to-head diff adds --threads=1 to the existing batch formatter invocation and adjusts two existing expectations; file selection, staging, partial-file handling, and content checks are unchanged. (scripts/pre-commit/format-staged.sh:98, 2bd92ea3ed71)
  • Current main still needs the change: The fetched main revision still invokes batch oxfmt without a worker limit. (scripts/pre-commit/format-staged.sh:98, 2cbef434846a)
  • Latest release comparison: The supplied latest release, v2026.9.4, also lacks the batch worker limit. (scripts/pre-commit/format-staged.sh:98, 3a9d69db306c)
  • Established formatter policy: format, format:fix, and format:diff already use --threads=1; package.json pins oxfmt 0.67.0. The hook executes this formatter directly, establishing the relevant dependency contract. (package.json:1752, 2bd92ea3ed71)
  • Pinned formatter supports the flag: The oxfmt_v0.67.0 tag resolves to this commit. RuntimeOptions defines the threads argument and documents 1 as single-core operation; the separately inspected stdin runner already fixes its worker count at one. (apps/oxfmt/src/cli/command.rs:168, b4da00b621ec)
  • Real hook performance evidence: The complete supplied PR body reports real git-hooks/pre-commit runs on Linux with Node 24.19.0 and oxfmt 0.67.0, controlled baseline/candidate ordering, identical staged/index/working contents, and a partial-staging control. Reported CPU fell 71.6–74.6%; the forty-file batch took 115 ms longer. These are contributor-recorded observations, not executions performed during this review. Captured context sourceRevision: a8104a13f065f94ae50ac416549dfb6c02774ae6cd59666a9c9955cfee9aa95a. (2bd92ea3ed71)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit 452689c into main Sep 19, 2026
135 of 136 checks passed
@steipete
steipete deleted the codex/perf-staged-format-workers-7006 branch September 19, 2026 01:01
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 19, 2026
* commit '912b21b98581c0be3baad87fe3686b64d69fffeb': (191 commits)
  perf(process): reduce allocation while processing command output (#152261)
  fix(ui): collapse duplicate previews when a page opens in multiple tabs (#152281)
  fix(test): run local Gateway tests behind protected exec egress (#152318)
  fix(node-host): avoid blocking configuration reads (#151411)
  fix(qa-lab): prevent Evidence Archive filters from overflowing (#152123)
  test: stabilize Docker scheduler signal fixtures on macOS (#152301)
  fix(ui): close stuck submenus when moving between menu rows (#152317)
  fix(ui): preserve question drafts and pending submissions (#152096)
  fix(release): recognize 7.34 fs-safe contract (#152326)
  chore: retire CLAUDE.md files
  fix(ui): release queued input after completed chat runs (#152299)
  improve(tooling): reduce commit formatting resource use (#152297)
  feat: show mentioned sessions in Involving me (#152083)
  perf(tasks): reuse prepared audit summaries (#152294)
  fix(daemon): preserve LaunchAgent rollback bytes and modes (#152195)
  fix: stop chat layout changes from loading extra history (#151726)
  perf(gateway): streamline config reload comparison (#152279)
  fix(xai): reject invalid UTF-8 OAuth responses (#111737)
  fix(release): accept waived advisory performance evidence for stable publication (#152290)
  fix: deliver watcher results while other sessions are busy (#152287)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: XS 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