Closed TimLariviere closed 2 years ago
That is an awesome data. Let me tinker about this for a little bit. I feel like this is an important one, because it can impact public API and architecture.
I think there is a world where Attributes and Widgets carry explicit reference to a definition (plus maybe some other metadata). If that is architecturally sound and efficient that might be a way to make it tree shakable.
@TimLariviere do you know what happens if you do this:
// Attributes.define is a pure function, does not modify any global state
let definitionA = Attributes.define<string> (....)
let definitionB = Attributes.define<string> (....)
// but use only "A"
let attrA = definitionA.WithValue(...)
If Attributes.define
is pure will definitionB
be linked out?
If Attributes.define is pure will definitionB be linked out?
Not 100% sure, but it should be
I updated the sizes data. Found it odd we manage to shave off 20% of the package size just by improving tree shaking in F.XF. Turns out it's not that impressive anymore.
Guess I misconfigured the main branch and it was not using the linker.
But we still get a respectable 0.5 MB off the package size. Which is closer to the relative size of Fabulous vs Xamarin.
Decompiler sources show that unused code is deleted 🥳
From what I understand, when we'll be able to target .NET 6.0, we'll benefit from the linker being able to remove FSharpOptimizationData
and FSharpSignatureData
from the F# dlls.
Which will give us a noticeable drop in dll size.
Downloading from decompiler.com, it gives me:
So knowing Fabulous.XamarinForms.dll is 330 KB, it would be only 13 KB at the end 😱 (That's surely a gross oversimplification, given it's most likely compressed but it still think it would be a major reduction)
It seems that investing more time in here might be not worth it at the moment, right?
I will tinker if we can remove "Key" concept in the background, if that is indeed possible then we can tree shake unused widgets and attributes.
It seems that investing more time in here might be not worth it at the moment, right?
Yes, it's not being a major improvement. But I still want to see where I'm allocating more because I need it for #42
Fixes #26
Short explanation (proper explanation to come later): Following @twop's advice in #26, I made the creation of
AttributeDefinitions
andWidgetDefinitions
lazy by putting them in get-only static properties instead oflet
in modules. This was how Don Syme did it in Fabulous v1. The definitions are created only the first time we access that get-only property. Any subsequent access will only do a lookup in a cache.Preliminary results
I published a version of CounterApp closer to the one in v1 with
Ad-Hoc|iPhone
configuration andLink All
enabled.Estimated package sizes
Compiled file sizes
Benchmarks for branch main
Benchmarks for branch improve-linking
This allocates way more than I expected