-
Notifications
You must be signed in to change notification settings - Fork 551
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
py_binary launch performance problem on windows #2019
Comments
I am wondering if bazelbuild/bazel#22865 Could you also check if precompiling py files to pyc helps (that is a new feature in 0.32.2)? Other than that, #1653 could be also related. |
Ah, good thought! bazelbuild/bazel#22865 was opened by me, so I have the fix. Sadly the fixed bazel doesn't resolve this - launch time still 5+s Just to confirm that I have the fix, here are the files in my external dir: I don't think that #1653 is related because I am using system interpreter, and I have disabled legacy_external_runfiles I can't understand from the docs what I should change in my py_binary target to enable precompiling. Could you advise? Thanks, Chris |
Ok, I updated from 0.32.2 to 0.33.2, and the precompiling option started working. But unfortunately no improvement in speed:
|
Another datapoint: Using 7z to recursively extract the zip created by py_binary takes 0.64s |
What is the performance if you launch the the script directly? I.e. |
The main expensive operation that I can think of would be unzipping the binary. By default, a windows build creates a small native exe and a zip of the python program. All the exe really does is call To check this, you can just unzip the myscript.zip, and run If that is the cause, you can try explicitly passing HTH |
Thank you, this is very helpful. The measurements below are with rules_python 0.34. So with a larger python project, myscript.zip is 34MB - 95% python, 4.9% pip modules, 0.1% script code. Time to get help message is:
rules_python and bazel is still slower, but much closer. If I try --build_python_zip=false without --enable_runfiles, I get this error. Seems like whatever is calling the bootstrap template is not resolving the script location using the manifest. Is this the issue you mention?
It would be preferable if rules_python could perform on windows with OOTB flags. I can think of the following possible improvements:
|
I've just checked with rules_python@HEAD, nothing in my message above is fixed/improved there vs 0.34 |
Commenting on feasibility of the suggested fixes:
These are my opinions and maybe sometimes has more things to share here. |
On windows, with rules_python as module and system interpreter and a simple script:
Due to the 10x overhead, for such a regularly run tool, users are refusing to run via bazel. I'm guessing the overhead is unzipping, but am not sure. We would prefer to run without zipping if zipping has a 10x overhead.
Full output from bazel run:
Relevant options:
.bazelrc
Module.bazel
🐞 bug report
Affected Rule
py_binary
Is this a regression?
No
🔬 Minimal Reproduction
I can create this if it would help
🌍 Your Environment
Operating System:
Output of
bazel version
:Rules_python version:
Anything else relevant?
The text was updated successfully, but these errors were encountered: