Skip to content
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

.appimage is slow to start — include .pyc into the bundle #9184

Open
ValdikSS opened this issue Sep 5, 2024 · 4 comments
Open

.appimage is slow to start — include .pyc into the bundle #9184

ValdikSS opened this issue Sep 5, 2024 · 4 comments
Labels
build/packaging 📦 OS-linux 🐧 probably-easy 🍰 pull-request wanted 📣 Help would be much appreciated if you have expertise and time.

Comments

@ValdikSS
Copy link
Contributor

ValdikSS commented Sep 5, 2024

AppImage (Linux) version of electrum is rather slow to start, it takes about 3 seconds on my modern Intel 1340P machine.
This is because Python bytecode (.pyc files) are not included into .appimage, and since appimage could not be updated, Python compiles them every run.

If .appimage is exctracted with ./electrum-4.5.5-x86_64.AppImage --appimage-extract and ran from the directory (so it could update itself), subsequent runs are vastly faster.

$ time ./electrum-4.5.5-x86_64.AppImage daemon --help
…
real    0m1,597s
user    0m1,201s
sys     0m0,075s

$ time ./electrum-4.5.5-x86_64.AppImage daemon --help
…
real    0m0,640s
user    0m0,380s
sys     0m0,052s

Please run the application once in your building process, and include all the built .pyc files into .appimage.`

@ValdikSS
Copy link
Contributor Author

ValdikSS commented Sep 5, 2024

The other appimage-related optimization is to use zstd compression.
Current "stable" version of AppImageKit does not support it, so new appimagetool should be used
https://github.com/AppImage/appimagetool/

@SomberNight
Copy link
Member

Sounds like it might be worth trying including the .pyc files indeed. In fact in the android apk I think we are only including the .pyc files for the same (startup speed) reasons.

Hopefully there is a nicer approach than actually "running" the application. There should be, as we are not doing that for Android.

@ValdikSS
Copy link
Contributor Author

ValdikSS commented Sep 6, 2024

Yes, seems there's compileall module.
python -m compileall ., something like that.

@SomberNight SomberNight added probably-easy 🍰 pull-request wanted 📣 Help would be much appreciated if you have expertise and time. labels Oct 12, 2024
@SomberNight
Copy link
Member

SomberNight commented Oct 16, 2024

Note: I've just spent a day fixing reproducibility of our apks due to apparently .pyc files not being reproducible. (ref spesmilo/python-for-android@0ab0d87)

The cherrypicked patches are part of cpython 3.11 fortunately:
python/cpython#27926
python/cpython#8226

However I read through lots of discussions and patches, and these comments from core developers are not exactly reassuring:
python/cpython#78274 (comment)

Since this is no longer needed by CPython, I recommend closing the issue (and PR).

Do you mean that the initial issue was fixed? PYC are now reproducible?

No. I mean that they don't need to be reproducible.

Ok, but this issue is about making PYC files reproducible to reproducible builds.

Wheel doesn't contain pyc files. So Python ecosystem around PyPI doesn't need reproducible pyc.

It makes me somewhat uncomfortable with putting pycs in binaries...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build/packaging 📦 OS-linux 🐧 probably-easy 🍰 pull-request wanted 📣 Help would be much appreciated if you have expertise and time.
Projects
None yet
Development

No branches or pull requests

2 participants