perf(zip)!: don't access the filesystem from wasm #5178
Merged
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.
Depends on #5179.
What's the problem this PR addresses?
This PR makes
ZipFS
read the archive directly inside the constructor from Node and passing a buffer to libzip instead of making libzip read it with a shimmed FS.Consequently,
ZipFS
now only accesses the filesystem twice for each archive (first time in the constructor and second time insaveAndClose
) and therefore doesn't have to keep an fd handle to the archive while it is open.This means that now:
This could have the consequence of allowing us to increase the fetcher and linker concurrency limits, but I haven't tested it yet.
Fixes #5172.
Fixes #4488.
How did you fix it?
This has the advantage of greatly reducing the bundle size since libzip doesn't have to bundle the FS shims anymore:
It also seems to bring performance improvements on
yarn install
(though earlier I saw some mixed results when benchmarking the time of accessing many archives so if anybody wants to run more benchmarks feel free, but I'd say that it's good enough since I could consistently reproduce the Yarn speedup):Checklist