-
Notifications
You must be signed in to change notification settings - Fork 83
Executable generated with pyinstaller is slower than cx_freeze #232
Comments
That's very surprising - but very interesting! I'd have expected the performance to be exactly the same. Can you please generate a build with both PyInstaller as well as cx_freeze and then perform a rebuild with a hot cache while having This should explain why there's such a huge difference in execution speed. For what it's worth, there's also Nuitka which seems interesting. I wonder how that works for you (never tried it myself). |
Here are the results of the profiling, direct mode with 268 targets: cx_freeze.txt took 8.62s An interesting fact is that the python code executes faster with pyinstaller. It would also make sense that the start up time dominates the timings for clcache. |
Thanks, interesting results! You mention that the cx_freeze build took 8.62 seconds and the one with PyInstaller took 17.52 seconds. In Did you maybe mix up the file names? Based on the log files, it seems that the cx_freeze build is actually slower. Interestingly, the time difference is about the same as what you mention (9 seconds) but the absolute values are much larger. Maybe you are measuring CPU time whereas the profiling output is measuring wall time? To me, it seems as if the tool used to build the version which generated the output in |
I am quite sure I didn't mix with the names and it matches with my timings. I can explain a bit more: I am using ninja with 12 jobs in parallel, I am measuring wall clock time and the profiler measures CPU time. I think the difference in timings between the profiler and the wall time relies in the startup time. Maybe pyinstaller has more overhead before it starts executing the python code? I am assuming that the startup time does not appear in the profiling. |
I really wonder why def main():
pass using both PyInstaller as well as cx_freeze, and comparing them? I can imagine that if the startup overhead of PyInstaller is so big, then it's indeed an issue for projects with many smaller files. In this case, I would love to hear how Nuitka works for how, I imagine that since it compiles Python to C, it has an even lower overhead. |
Exactly, it makes a big difference:
I tried nuitka already in the past and couldn't make it work with clcache, here is the error message:
Nuitka timings with the simple main.py:
|
This is kind of an unfair comparison as My build time on cold caches drops from |
@siu It would be interesting to see how PyInstaller without |
It was noted (in GitHub issue #232) that using the --onefile argument with pyinstaller significantly slows down launching the generated binary. Indeed, the PyInstaller documentation explains: The one executable file contains an embedded archive of all the Python modules used by your script, as well as compressed copies of any non-Python support files (e.g. .so files). The bootloader uncompresses the support files and writes copies into the the temporary folder. This can take a little time. That is why a one-file app is a little slower to start than a one-folder app. Startup time of clcache is relevant for common use cases, so let's make sure that this overhead is avoided by not recommending to use this switch.
It was noted (in GitHub issue #232) that using the --onefile argument with pyinstaller significantly slows down launching the generated binary. Indeed, the PyInstaller documentation explains: The one executable file contains an embedded archive of all the Python modules used by your script, as well as compressed copies of any non-Python support files (e.g. .so files). The bootloader uncompresses the support files and writes copies into the the temporary folder. This can take a little time. That is why a one-file app is a little slower to start than a one-folder app. Startup time of clcache is relevant for common use cases, so let's make sure that this overhead is avoided by not recommending to use this switch.
I will try next time I boot on windows, hopefully today or tomorrow. |
@siu Thanks, much appreciated! |
I run some tests now, these are the timings of the current master with a hot cache with 1328 targets: "cxfreeze clcache.py" 88.86s The code base is different so the numbers should not be compared to the ones I reported when I created the issue. The difference between the two is minimal, this issue can be closed after the changes in the README. |
We found that cx_freeze generates faster executables.
For example, with a hot cache of 1248 targets:
The downside is that cx_freeze cannot generate single file executables but the speedup is well worth it.
The text was updated successfully, but these errors were encountered: