When extracting a wheel, do not recheck parent directories
Hello,
Can i offer you a patch to make pip install ~5% faster? Counting 5% faster in average. Closer to 10% faster on slow disks or network volumes, closer to 1% faster on fast SSD.
The fix is pretty trivial. When extracting a wheel, do not recheck/recreate the parent directory before extracting each file.
Profiling a run of pip install plotly --prefix ./testdir
PROFILER ON MASTER:
PROFILER WITH THIS FIX:
Notice the 14425 calls to ensure_dir() taking 512ms total or ~5% of the runtime. Notice it's a lot less with the fix.
Total runtime 10.268 -> 9.414 seconds, thanks to all the calls removed + a few hundreds of ms of variance between pip runs.
Regards.
FYI, the Windows CI failings are unrelated to your PR
Hi, just a heads up that we just cut pip v24.1 so the core team's resources are being focused on making sure that release is handled smoothly. This PR looks simple so I'll try to take look tomorrow, but in the meanwhile, could you add a NEWS entry? Thank you!
Thanks, I added a NEWS entry.
Builds is failing after rerunning, there are issues with windows builds and 3.13? trying to pickup changes on master for windows but then it's failing even earlier with new ruff rules?
src/pip/_internal/operations/install/wheel.py:418:5: C901 `_install_wheel` is too complex (34 > 33)
src/pip/_internal/operations/install/wheel.py:418:5: PLR0915 Too many statements (139 > 134)
All green, should be good to merge now.
this PR is ready to merge
I'm going to schedule this PR for 24.2 as it seems like a small low-risk performance tweak. Feel free to remove the PR from the milestone if you object.
Thanks @morotti! ^.^
Thank you very much @pradyunsg