Skip to content

perf: 5-7x faster packing, 15-20% faster extraction - #414

Merged
MarshallOfSound merged 7 commits into
mainfrom
perf/optimize-pack-extract
Mar 28, 2026
Merged

perf: 5-7x faster packing, 15-20% faster extraction#414
MarshallOfSound merged 7 commits into
mainfrom
perf/optimize-pack-extract

Conversation

@MarshallOfSound

Copy link
Copy Markdown
Member

Stacked on #413

Summary

  • Packing is 5-7x faster across all file counts and sizes
  • Extraction is 15-20% faster via bulk archive reads
  • Adds benchmark suite (yarn benchmark)

What changed

  • Buffer-based integrity hashing for files ≤2MB instead of stream pipelines
  • Batched file writes (single out.write instead of one per file)
  • Bulk readSync of entire data section in extractAll
  • Synchronous fast path in insertFile (no Promise per file)
  • Set-based lookups for ordering and unpackDirs
  • Parallel metadata resolution in createPackageFromFiles
  • Optimized crawl symlink filter

Benchmark results (10,000 × 256B files)

Operation Before After
Pack 2706ms 367ms
Pack (pre-crawled) 2743ms 287ms
Extract all 1707ms 1510ms

Test plan

🤖 Generated with Claude Code

@MarshallOfSound
MarshallOfSound requested a review from a team as a code owner March 23, 2026 09:27
@MarshallOfSound
MarshallOfSound force-pushed the perf/optimize-pack-extract branch 3 times, most recently from 1c54d50 to 3828e06 Compare March 23, 2026 09:59

@erickzhao erickzhao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

placeholder

@erickzhao
erickzhao marked this pull request as draft March 23, 2026 18:23
@erickzhao
erickzhao dismissed their stale review March 23, 2026 18:24

dismissing placeholder

@erickzhao
erickzhao marked this pull request as ready for review March 24, 2026 17:25
Base automatically changed from test/robustness-and-bugfixes to main March 24, 2026 17:32
MarshallOfSound and others added 6 commits March 26, 2026 11:03
… block boundary bugs

Added 81 robustness tests that uncovered three bugs:
- Pickle resize allocated wrong buffer size, causing RangeError on large headers
- writeFileListToStream/streamFilesystem didn't await stream flush before returning
- Integrity hash emitted spurious empty block when file size hit exact 4MB boundary

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ility

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Under Electron, node:fs intercepts .asar paths as virtual archives.
Tests that read/write raw .asar files need original-fs via wrappedFs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Key optimizations:
- Buffer-based integrity hashing for files ≤2MB (avoids stream setup overhead)
- Batched writes in writeFileListToStream (single write instead of per-file)
- Bulk archive read in extractAll (one readSync for entire data section)
- Synchronous fast path in insertFile (eliminates Promise allocation per file)
- Set-based lookups for ordering and unpackDirs (O(1) vs O(n))
- Parallel metadata resolution in createPackageFromFiles
- Optimized crawl symlink filter with early exit

Adds benchmark suite (yarn benchmark / yarn benchmark:quick).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@MarshallOfSound
MarshallOfSound force-pushed the perf/optimize-pack-extract branch from 3828e06 to e4cee09 Compare March 26, 2026 18:08
Comment thread test/robustness-spec.ts Outdated
@MarshallOfSound
MarshallOfSound merged commit 79686b6 into main Mar 28, 2026
6 checks passed
@MarshallOfSound
MarshallOfSound deleted the perf/optimize-pack-extract branch March 28, 2026 05:00
@electron-npm-package-publisher

Copy link
Copy Markdown

🎉 This PR is included in version 4.1.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2 participants