[GH-ISSUE #174] fix(native): avoid reparsing lipo output in list_architectures #122

Closed
opened 2026-10-15 18:21:20 +00:00 by bsakaguchi · 0 comments
Owner

Originally created by @morluto on GitHub (Jul 14, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/174

Problem

In NativeMacOSProvider.#listArchitectures, the lipo output is parsed twice:

  • once for items
  • once again to compute total

This doubles parsing work for every list_architectures call.

Location

src/native/NativeMacOSProvider.ts:204-205

Why this is a bug

parseLipoArchitectures() does full tokenization and schema-validated transforms. Re-running it is redundant and can become an unnecessary CPU cost for large lipo -detailed_info outputs.

Impact

  • Extra latency in architecture enumeration on multi-architecture binaries.
  • Duplicate work in a hot utility path used by every contract that inspects native architectures.

Proposed fix

Cache parsed architectures once and reuse:

const architectures = parseLipoArchitectures(capture.value.stdout);
const result = listArchitecturesSchema.parse({
  architectures: {
    items: architectures,
    total: architectures.length,
    exhaustive: true,
    limitations: [],
  },
  ...
});
Originally created by @morluto on GitHub (Jul 14, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/174 ### Problem In `NativeMacOSProvider.#listArchitectures`, the lipo output is parsed twice: - once for `items` - once again to compute `total` This doubles parsing work for every `list_architectures` call. ### Location `src/native/NativeMacOSProvider.ts:204-205` ### Why this is a bug `parseLipoArchitectures()` does full tokenization and schema-validated transforms. Re-running it is redundant and can become an unnecessary CPU cost for large `lipo -detailed_info` outputs. ### Impact - Extra latency in architecture enumeration on multi-architecture binaries. - Duplicate work in a hot utility path used by every contract that inspects native architectures. ### Proposed fix Cache parsed architectures once and reuse: ```ts const architectures = parseLipoArchitectures(capture.value.stdout); const result = listArchitecturesSchema.parse({ architectures: { items: architectures, total: architectures.length, exhaustive: true, limitations: [], }, ... }); ```
bsakaguchi 2026-10-15 18:21:20 +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#122
No description provided.