normcap icon indicating copy to clipboard operation
normcap copied to clipboard

Possibly further binary file size reduction

Open thecoder-001 opened this issue 3 years ago • 1 comments

Hello! I gave another try to reduce normcap's binary size further, this time trying to find smaller unneeded stuff. My testing method is the same crude way as before, deleting files, checking if normcap launches (& functions) and if not, replacing the file back. I tried to target the file size of about >700K to ensure that we get meaningful results and was able to trim about 51.9M. Unfortunately I was only able to test on macOS for now. Also, I left stuff related to networking (I was scared that I might break the update notification, should have probably re-read the codebase) and dbus (which isn't needed on macOS but is required on linux).

In the end, these files can possibly be removed. I have tried my best to ensure everything is working properly, but its highly likely that things might actually be on fire behind the scenes and might break in use cases which I have missed. This issue might end up wasting your time without giving anything in return, and if you guess that's the case, please close the issue. I would reopen it later with more testing and a better understanding of the codebase. Also, all of this might become irrelevant after the addition of Nuitka.

$  tree --du -h /Applications/NormCap\ copy.app/Contents/Resources | grep bak
│   │   │   │   ├── [994K]  Qt3DInput.framework.bak
│   │   │   │   ├── [1.2M]  QtPositioning.framework.bak
│   │   │   │   ├── [8.7M]  QtQml.framework.bak
│   │   │   │   ├── [1.4M]  QtQmlModels.framework.bak
│   │   │   │   ├── [7.7M]  QtShaderTools.framework.bak
│   │   │   │   ├── [5.5M]  assetimporters.bak
│   │   │   │   ├── [4.4M]  imageformats.bak
│   │   │   │   ├── [2.7M]  qmltooling.bak
│   │   │   │   ├── [3.3M]  renderers.bak
│   │   │   ├── [1.6M]  qml.bak
│   │   │   └── [6.5M]  translations.bak
│   │   ├── [1.1M]  QtPositioning.abi3.so.bak
│   │   ├── [1.1M]  QtPrintSupport.abi3.so.bak
│   │   ├── [1.7M]  QtQml.abi3.so.bak
│   │   ├── [958K]  QtScxml.abi3.so:bak
│   │   ├── [740K]  QtXml.abi3.so.bak
│   │   ├── [2.3M]  qmllint.bak
Full file paths (relative to `/Applications/NormCap\ copy.app/Contents/`):
./Resources/app_packages/PySide6/qmllint
./Resources/app_packages/PySide6/QtPositioning.abi3.so
./Resources/app_packages/PySide6/Qt/plugins/assetimporters
./Resources/app_packages/PySide6/Qt/plugins/qmltooling
./Resources/app_packages/PySide6/Qt/plugins/imageformats
./Resources/app_packages/PySide6/Qt/plugins/renderers
./Resources/app_packages/PySide6/Qt/translations
./Resources/app_packages/PySide6/Qt/lib/QtShaderTools.framework
./Resources/app_packages/PySide6/Qt/lib/QtQmlModels.framework
./Resources/app_packages/PySide6/Qt/lib/QtQml.framework
./Resources/app_packages/PySide6/Qt/lib/QtPositioning.framework
./Resources/app_packages/PySide6/Qt/lib/Qt3DInput.framework
./Resources/app_packages/PySide6/Qt/qml
./Resources/app_packages/PySide6/QtPrintSupport.abi3.so
./Resources/app_packages/PySide6/QtXml.abi3.so
./Resources/app_packages/PySide6/QtQml.abi3.so

Thanks a lot for maintaining Normcap. Cheers!

thecoder-001 avatar Aug 04 '22 16:08 thecoder-001

That's super cool, @thecoder-001, those experiments are quite valuable! Yeah, testing is a delicate thing, sometime I have the feeling it also depends on the system, if it works (e.g. if a lib is already present on the system, Qt might be able to fall back to those.). But nevertheless, I think it's worth a try. I'm quite confident that removing Qt3DInput or the Qml things won't break anything. Same for PrintSupport.

Not sure, when I find time to look into it (focusing on bugs at the moment.)

If you want to give it a try, package/platform/utils.py would be the right place: The strings inPACKAGES_EXCLUDES are used to remove files from the NormCap.app/ directory (which gets created during the build process). This is happening here. Because the filenames are slightly different on the various platforms, the function which is actually deleting the files (rm_recursive()), just checks if any string of the PACKAGES_EXCLUDES-Lists is part of the lowercased filepath of any file. If that's true, it deletes the file.

dynobo avatar Aug 04 '22 18:08 dynobo

I exclude most the packages you proposed from the release v.0.3.8, which led to ~10-15% reduction of the package sizes. Thanks a lot, @thecoder-001 !

Even if there are some packages more to be removed, I'd like to go with the current reductions for a few months to check if some unexpected issues get reported. But I'll keep this issue in mind and try another reduction in winter! :-)

dynobo avatar Aug 21 '22 13:08 dynobo