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

Performance tips #1173

Closed
ejongejans opened this issue Jun 8, 2022 · 4 comments
Closed

Performance tips #1173

ejongejans opened this issue Jun 8, 2022 · 4 comments

Comments

@ejongejans
Copy link

Hi,

This is not really an issue; but a list of performance points in case others can use this. Of course if there is more I would be happy to hear. Some of this comes from stackoverflow; converted in how to use it programmatically.

Starting point was a self contained .NET Core app of around 180mb in size. Of which 170mb is .NET Core libs
Doing a programmatic Compiler.BuildMsi took around 44 seconds.
Publishing 30 msi installers from the same code base, this is to long.

1. disable validation when building the .msi:
Compiler.LightOptions += "-sval ";
This saves around 8-9 seconds. Not sure this is best practice.. but when building the installers programmatically you could add your own validation.

2. Using multiple cabinets (by setting a max size of 2mb) further speeds around 20 seconds.

wixproject.Media.Clear(); // clear default media as we will add it via MediaTemplate
            wixproject.WixSourceGenerated += document =>
            {
                document.Select("Wix/Product")
                        .AddElement("MediaTemplate", "CabinetTemplate=cab{0}.cab; CompressionLevel=mszip; EmbedCab=yes; MaximumUncompressedMediaSize=2 ");
            };

3. Using the cabinet caching will greatly improve speed.

Compiler.LightOptions += "-reusecab "; //doesn't delete them.. 
Compiler.LightOptions += "-cc \"" + CabinetCacheDir + "\" "; //your directory here.

This saves another 40% of your time. When in case of i.e. a .NET Core Self contained app all the .NET Core stuff is already compressed into cabinets and doesn't change over time.

4. Compression
Tried different versions of the compression. High doesn't seem to make a difference. Low/None results in a 180mb file; and for a small performance penalty mszip yields +/- 80mb .msi installers. Which is a considerable save.

5. Building multiple installers parellel

  • Make sure the C# script building the wix installer is running in a seperate process.
  • Also make sure the cabinet cache dir is not shared accross any processes (it will yield read exceptions)
  • Building 30 msi installers in a standard Parrelel.Foreach, starting each build as a new Process yielded a speed up of 3x compared to running everything in serie.

In the end for 30 installers without cache it hits 148 seconds. So that is 5 seconds per MSI
With caching (for any build after the first one) it gets down to 95 seconds. So that is 3 seconds per MSI. (instead of 44)

Elco

@oleg-shilo
Copy link
Owner

oleg-shilo commented Jun 9, 2022

Excellent. Thank you. I will test it and consider making the safest/practical options it into defaults.

Marking the issue as an 'enhancement' as well

@oleg-shilo
Copy link
Owner

Added the link to your article: https://github.com/oleg-shilo/wixsharp/wiki#documentation

And indeed the biggest performance hit is validation.
And, you are also right, removing the validation is a decision that only user can decide to do.

@ejongejans
Copy link
Author

Cool thx for confirming the tests.

@oleg-shilo
Copy link
Owner

The content of this issue is still valid but since a dedicated Wiki page has been created: https://github.com/oleg-shilo/wixsharp/wiki/Tips'n'Tricks I am closing it.

Note the wiki still references this issue page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants