[PR #2466] [MERGED] perf(native): run independent Mach-O slice commands concurrently #5249

Closed
opened 2026-10-31 01:05:08 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/2466
Author: @kaoru0822-kitauji
Created: 10/13/2026
Status: ✅ Merged
Merged: 10/13/2026
Merged by: @kaoru0822-kitauji

Base: main ← Head: perf/macho-concurrent-slice-commands


📝 Commits (1)

  • 7b4b2c6 perf(native): run independent Mach-O slice commands concurrently

📊 Changes

2 files changed (+78 additions, -13 deletions)

View changed files

📝 src/native/NativeMachoInspection.test.ts (+65 -1)
📝 src/native/NativeMachoInspection.ts (+13 -12)

📄 Description

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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/2466 **Author:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Created:** 10/13/2026 **Status:** ✅ Merged **Merged:** 10/13/2026 **Merged by:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Base:** `main` ← **Head:** `perf/macho-concurrent-slice-commands` --- ### 📝 Commits (1) - [`7b4b2c6`](https://github.com/morluto/rea/commit/7b4b2c6b2800cef3d191ce2a8268168831b00a26) perf(native): run independent Mach-O slice commands concurrently ### 📊 Changes **2 files changed** (+78 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `src/native/NativeMachoInspection.test.ts` (+65 -1) 📝 `src/native/NativeMachoInspection.ts` (+13 -12) </details> ### 📄 Description ## 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](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:05:08 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#5249
No description provided.