extract-stream: use file mapping on Windows #8
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.
This makes pacote take advantage of writing files using a file mapping on Windows when available, which can be significantly faster. Support landed in libuv in libuv/libuv#2295 and in Node.js in nodejs/node#29260. This PR has no effect unless a node-tar includes isaacs/node-tar#227.
Using a file mapping is only an advantage in some situations which are hard to determine and vary widely from machine to machine. However, it is always better or similar when making a short number of writes to a file and the file is not too large (less than about 1MB). Extracting npm packages matches these conditions, and using a file mapping here seems to always be an advantage. On my tests, running npm with this change is often faster, up to almost half the time in some cases.
This PR does not include a test because the feature is always enabled and there is no API to know if a write operation was actually performed using a file mapping.