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

Windows Installer Size and Speed Optimization #171

Merged
merged 3 commits into from
May 3, 2024

Conversation

xyloflake
Copy link
Collaborator

@xyloflake xyloflake commented May 2, 2024

Overview

This pull request addresses optimizations to app-builder-lib, a pivotal component within the electron-builder monorepo.

Enhancements

  • Specifically tailored for version 24.13.3 of app-builder-lib, this patch introduces a novel custom compression level dubbed ultra. On platforms other than Windows, ultra is internally set to maximum. Conversely, on Windows, a bespoke high-compression algorithm has been utilized to optimize the size efficiency of the NSIS target. This measure was necessitated by issues encountered on non-Windows platforms, as evidenced by the failed build.

  • Electron builder internally resets the compression configuration option to normal for Windows, albeit without explicit rationale. Consequently, this patch intervenes to prevent the reset to normal exclusively for Windows systems, as the aforementioned algorithm cannot operate optimally on other platforms.

Impact

  • The adoption of maximum compression for ultra on macOS and Linux results in increased build times across all platforms. On Windows, there's a notable build time surge owing to the necessity to compile internal libraries post-patch, utilizing Visual Studio.

  • Overall, this enhancement culminates in a 7MB reduction in size.

  • However, it's important to note an 8% slowdown in installation speed, attributed to the heightened complexity of decompression.

Build Checks

For reference, the latest build checks can be viewed here.
Build Status: Passing ✅

@xyloflake xyloflake added enhancement optimisation: misc. Miscellaneous Optimizations (need description in PR/commit) labels May 2, 2024
@xyloflake xyloflake self-assigned this May 2, 2024
@xyloflake xyloflake enabled auto-merge (squash) May 2, 2024 18:56
Copy link
Collaborator

@gamersi gamersi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@staniel359
Copy link
Owner

@xyloflake Thanks for detailed description.
Have you considered contributing directly to electron-builder?
Or is it specifically for muffon?

@xyloflake
Copy link
Collaborator Author

It is specifically for muffon @staniel359

I did consider contributing directly to electron builder but I realised that they reset the compression config from literally anything to normal. Now I've only tested for Windows and have no idea about how it behaves on non-Windows platforms.

But I ran a CI build that failed (linked in the PR description), which tells me that it has problems on other platforms, therefore I had to apply the patch only for windows.

Also the reset is done with a goofy comment above it, which makes me doubt if they'd like to change.

Moreover the v25 alphas are broken, I and @gamersi have tried building electron-builder from main but windows throws a fatal node-gyp error VS installation not found. Also their CI builds fail as well at macos tests (check electron builder repo github actions).

Once it becomes stable, I'll try to contribute directly to electron-builder although I am 90% sure they'll straight up reject the PR.

But let's hope for the best I guess.

For now, this is the solution to reducing 7MB which may not sound like a big deal but it was quite complex to achieve such a feat.

Thanks.

@staniel359
Copy link
Owner

@xyloflake Got it.
Thank you for your work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement optimisation: misc. Miscellaneous Optimizations (need description in PR/commit)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants