TASEmulators / BizHawk

BizHawk is a multi-system emulator written in C#. BizHawk provides nice features for casual gamers such as full screen, and joypad support in addition to full rerecording and debugging tools for all system cores.
http://tasvideos.org/BizHawk.html
Other
2.09k stars 377 forks source link

Trimming Support #3767

Open CasualPokePlayer opened 10 months ago

CasualPokePlayer commented 10 months ago

Something to look at wrt .NET6 (see #2261). One benefit of .NET6 is the ability to do a "self-contained" build which packs in all the framework and runtime (so no need for a prereq installer) (see also #1415). This however makes the build much larger. One way to reduce this size is to enable trimming, which removes unused code. (perhaps this might even give us an overall size reduction compared to a framework deployed build?)

However, trimming comes with several limitations:

YoshiRulz commented 10 months ago

Worth noting that trimming is configurable; you can explicitly include symbols you know will be used.

I have some notes re: reflection, publishing/packaging, and Wasm.

Morilli commented 10 months ago

WinForms projects can't be trimmed (BizHawk.Client.EmuHawk [...]

So this means it cannot be enabled AT ALL until we move away from winforms, right?

CasualPokePlayer commented 10 months ago

I assume trimming can be controlled on a per project basis here? I assume regardless however we can't go enable AOT until the entirety of BizHawk is trimmable.

Morilli commented 10 months ago

Yeah I don't think trimming is gonna happen any time soon. Reflection is just one example of many patterns that are not compatible with trimming and are extremely hard to fix at the very least. If you haven't you could try to enable trimming on the .NET6 targeting branch and see how many errors you get.

YoshiRulz commented 1 month ago

I tried adding

<EnableAotAnalyzer>true</EnableAotAnalyzer>
<EnableSingleFileAnalyzer>true</EnableSingleFileAnalyzer>
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
<TrimmerSingleWarn>false</TrimmerSingleWarn>

but it just gave me the NETSDK1210 "not supported for .NET Standard" warnings and nothing else. Not that I think it would have brought up anything actionable.

CasualPokePlayer commented 1 month ago

The trimming is somewhat weirdish. For each project you want to manually specify it in, you need to have at least .NET 6 targeted. However, in reality this isn't really needed per se (unless you're doing partial trimming and probably for warnings), since if you perform full trimming (the default), then specifying that for the exe project (assuming that is targeting .NET 6+) is enough for all assemblies used to be trimmed (even .NET Standard/.NET 5 and below ones).