perf: detect Mach-O via magic bytes and parallelize test suite#180
Merged
MarshallOfSound merged 4 commits intomainfrom Mar 16, 2026
Merged
perf: detect Mach-O via magic bytes and parallelize test suite#180MarshallOfSound merged 4 commits intomainfrom
MarshallOfSound merged 4 commits intomainfrom
Conversation
Runtime improvements: - Replace `file --brief --no-pad` spawn-per-file with direct magic byte reads in getAllAppFiles. Adds isMachO() helper with disambiguation between Mach-O fat binaries and Java .class files (both 0xCAFEBABE; bytes 4-7 are nfat_arch for Mach-O, major/minor version for Java). - Try APFS copy-on-write clone (cp -cR) when staging the x64 template, falling back to cp -R on non-APFS volumes. - Resolve appPath through realpath before walking to avoid symlink edge cases. Test suite improvements: - Run fixture templateApp setup in parallel (globalSetup). - Convert makeUniversalApp suite to describe.concurrent with per-test mkdtemp output dirs; pass ExpectStatic through helpers so snapshots attribute to the right test under concurrency. - Extract Electron zip into a unique tmpdir in templateApp to avoid races on the intermediate Electron.app path. - Use mkdtemp for staging app dirs instead of random-suffix collision avoidance. - Cap maxConcurrency at 4.
@electron/get is not safe for concurrent downloads of the same artifact. On CI with a cold cache, the parallel templateApp calls in globalSetup raced writing to the same cache path and produced a corrupt/missing zip. Warm the cache for both archs serially in globalSetup before any parallel work starts; all subsequent templateApp calls (in globalSetup and in the concurrent test suite) then hit the cached zip.
a6b2915 to
43801fb
Compare
erickzhao
approved these changes
Mar 13, 2026
|
🎉 This PR is included in version 3.0.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two related performance passes — one on
makeUniversalAppitself, one on the test suite.Runtime
getAllAppFileswas spawningfile --brief --no-padfor every file in the bundle. Replaced with a direct 8-byte header read +isMachO()check. Includes a disambiguation against Java.classfiles, which share the0xCAFEBABEmagic with Mach-O fat binaries — Mach-O storesnfat_archin bytes 4-7 (small int), Java storesmajor_version >= 45.cp -cRfor the x64→tmp staging copy (near-instant CoW on APFS), fall back tocp -Rif it fails.appPathviarealpathbefore walking.Tests
globalSetupbuilds fixture apps in parallel.makeUniversalAppsuite is nowdescribe.concurrent; each test gets its ownmkdtempoutput dir (cleaned inafterAll), andexpectis threaded throughverifyApp/verifyFileTree/ensureUniversalso snapshots stay attributed correctly.templateAppextracts into a unique temp dir to avoid concurrent races on the sharedElectron.appintermediate path.createStagingAppDirusesmkdtempinstead ofMath.random()*100suffixes.maxConcurrency: 4to keep the disk/CPU thrash bounded.Test plan
yarn testpasses locally