Repository navigation
perf(nodeenv): unpack the node.js zip archive in parallel - #459
Merged
Merged
Conversation
On Windows, scanners that check every new file made the one by one extractall of the node.js zip take hours. The zip branch of download_node_src now extracts the files with 32 threads, after creating every directory in the main thread: before Python 3.13 zipfile fails when two threads create the same directory. The first failing file stops the extraction and the files that have not started are dropped, and so does Ctrl+C. The main thread waits with a timeout, since before Python 3.14 Ctrl+C does not interrupt waiting on a lock on Windows. Tar archives are extracted as before. Fixes #366
--no-parallel-extract, or parallel_extract = False in the [nodeenv] section of a config file, extracts the node.js zip archive with the old one by one extractall. --parallel-extract, the default, turns it back on over the config. The config also reaches pre-commit, which runs nodeenv with its own arguments. Tar archives are not affected.
5 tasks done
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.
See CONTRIBUTING.md for the rules behind this checklist.
On Windows the node.js zip archive is extracted one file at a time, and
scanners that check every new file make that slow: in #366 the 1971 files
of
node-v22.4.1-win-x64.ziptake three hours, and three minutes with 100threads. pre-commit is hit hardest, as it creates an environment per node
hook and runs nodeenv with its own fixed arguments.
The zip branch of
download_node_srcnow extracts the files with 32threads (
extract_workers, a module constant):entries and the parents of the files. Before Python 3.13 zipfile fails
when two threads create the same directory.
not started are dropped. Ctrl+C does the same: the main thread waits with
a 0.1 s timeout, since before Python 3.14 Ctrl+C does not interrupt
waiting on a lock on Windows.
ZipFile.extract, which sanitizes thenames. Tar archives are extracted as before.
--no-parallel-extract, orparallel_extract = Falsein the[nodeenv]section of
~/.nodeenvrc, turns this off and extracts the zip with theold
extractall, one file at a time.--parallel-extract, the default,turns it back on over the config. The config also reaches pre-commit.
The real
node-v22.4.1-win-x64.zipgives the same 1971 files and 500directories, with the same hashes, as
extractall. CI cannot reproduce aslow scanner, so the speedup can only be confirmed in the issue.
Fixes #366
toxpasses: the tests and flake8CHANGEShas an entry underVersion [unreleased], if nodeenv'sbehavior changes
README.rstis updated, if the change affects what it documentstype(scope): subject