Skip to content

perf(native): run independent Mach-O slice commands concurrently - #2466

Merged
kaoru0822-kitauji merged 1 commit into
mainfrom
perf/macho-concurrent-slice-commands
Oct 13, 2026
Merged

kaoru0822-kitauji merged 1 commit into
mainfrom
perf/macho-concurrent-slice-commands

Conversation

@kaoru0822-kitauji

@kaoru0822-kitauji kaoru0822-kitauji commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

inspect_macho ran its six per-slice commands (otool -h -l, nm -gjU, dyld_info -imports, dyld_info -exports, dwarfdump --uuid, optional vtool -show-build) one after another. Each command also resolves its tool through xcrun --find first, so a warm call made 16 supervised process launches in series (about 46 ms per command on this Mac).

The six commands only read the selected artifact and don't depend on each other. They now start together after lipo selects the slice. No behavior changes:

  • Captures, and so provenance, stay in declared order.
  • If several commands fail, the first failure in declared order is reported, as before. Siblings are not aborted, so no cancellation caused by REA can be reported in place of the real failure.
  • Every launch settles before the result returns. The caller's signal still reaches every command.
  • file and lipo stay serial because slice selection depends on them.

Measurements

macOS 26 (Apple silicon), Node 26.5.0, local build, MCP stdio client. Each run is a fresh server: open_binary, then inspect_macho called 4 times. Cold is the first inspect_macho call per run (median of 3 runs). Warm is calls 2–4 (median of 9 calls across the 3 runs).

Target Before, cold After, cold Before, warm After, warm
/bin/ls (universal, 20.9k chars of output) 755 ms 567 ms (−25%) 347 ms 166 ms (−52%)
Calculator.app executable (293.6k chars of output) 812 ms 596 ms (−27%) 368 ms 182 ms (−51%)

The result text is the same size before and after. A field-by-field diff of the /bin/ls result, ignoring IDs and timestamps, showed no differences.

Tests

  • New in src/native/NativeMachoInspection.test.ts: a runner that finishes later-launched commands first. It checks that all six slice commands are in flight together, that provenance stays in declared order, and that with nm and dwarfdump both failing (dwarfdump finishing first) the nm failure is reported. Before the change the first test fails (max in flight 1).

Checks

  • Run: npm run check (pass) and npm run test:focused on the 23 test files that mention inspect_macho or NativeMacOSProvider (356 tests, pass).
  • Not run: npm run check:pr, the full test suite, and docs:check (no contract or schema change).
  • Real-tool scope: real Xcode Command Line Tools on macOS (no full Xcode). The benchmark used the real xcrun, otool, nm, dyld_info, dwarfdump and vtool.

AI agent note

An AI agent (Claude Code) wrote this PR during a scheduled maintenance loop. A human did not review the diff or the measurements before submission.

🤖 Generated with Claude Code

inspect_macho launched otool, nm, two dyld_info reads, dwarfdump and
vtool one at a time. Each launch also resolves the tool through
`xcrun --find`, so a warm call spent about 350 ms in eight serial
supervised launches. The slice commands only read the selected
artifact, so launch them together. Every launch still settles before
the result, and declared order still fixes provenance and which
failure is reported.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@kaoru0822-kitauji
kaoru0822-kitauji merged commit 2c7240c into main Oct 13, 2026
34 checks passed
@kaoru0822-kitauji
kaoru0822-kitauji deleted the perf/macho-concurrent-slice-commands branch October 13, 2026 04:12
@morluto morluto mentioned this pull request Oct 13, 2026
3 tasks done
@morluto morluto added performance Performance regressions, scaling limits, and bounded-resource work area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior performance Performance regressions, scaling limits, and bounded-resource work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants