learningequality / kolibri

Kolibri Learning Platform: the offline app for universal education
https://learningequality.org/kolibri/
MIT License
755 stars 637 forks source link

Reduce the size of the wheel file #12361

Open rtibbles opened 5 days ago

rtibbles commented 5 days ago

Summary

This is an iterative PR to do more and more aggressive things to reduce the size of the whl file. Change Size Saved (MB)
Removes compression from woff and woff2 files, which had minimal effect on served asset size, but did make the file appear twice in the whl file 6
Runs strip --strip-unneeded on all .so files for the x64 architecture 8
Runs strip --strip-unneeded on all .so files for the aarch64 and arm 32bit architecture 9
Truncates all compressed files to prevent duplication of static assets 18.6
Total 41.6

These changes bring the whl file back below the 100MB mark.

The final fix here is a cherry-pick of the final unmerged parts of this PR: https://github.com/learningequality/kolibri/pull/8958

I have sidestepped the main issue with that PR:

The main consideration here is that if a device explicitly requests the identity Accept-Encoding header it will return an empty file instead of the actual file. The other alternative is to return a 406 status code if the identity header is passed for one of these files, but this seems to be explicitly disallowed.

By handling the identity Accept-Encoding header by dynamically ungzipping the compressed file when it is requested. As all of our supported browsers do allow gzip accept-encoding, this should be very much an edge case.

References

Fixes #12296

Reviewer guidance

Test built assets on multiple Linux architectures (x64, ARM, and aarch64) - the latter two may be a bit harder, but testing on a raspberry pi should hopefully suffice.

Ensuring static assets load in the frontend properly.


Testing checklist

PR process

Reviewer checklist

github-actions[bot] commented 5 days ago

Build Artifacts

Asset type Download link
PEX file kolibri-.pex
Windows Installer (EXE) kolibri-0.17.0a0.dev0+git.148.g12b1bd5f-windows-setup-unsigned.exe
Debian Package kolibri_0.17.0a0.dev0+git.148.g12b1bd5f-0ubuntu1_all.deb
Mac Installer (DMG) kolibri-0.17.0a0.dev0+git.148.g12b1bd5f-0.4.2.dmg
Android Package (APK) kolibri-0.17.0a0.dev0+git.148.g12b1bd5f-0.1.3-debug.apk
TAR file kolibri-0.17.0a0.dev0+git.148.g12b1bd5f.tar.gz
WHL file kolibri-0.17.0a0.dev0+git.148.g12b1bd5f-py2.py3-none-any.whl