-
-
Notifications
You must be signed in to change notification settings - Fork 122
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
Reduce allocations #805
Reduce allocations #805
Conversation
/azp run full build |
Azure Pipelines successfully started running 1 pipeline(s). |
for updateIncremental would be worth take a look at #780 to reduce unneccessary allocations, i think |
@vshapenko For now, I'm currently looking at reducing allocations in |
Ok, I managed to reduce allocations in So to avoid having those returned F# lists, I preallocated an array from the Also made sure that all local functions were not implicitly capturing variables to avoid allocations. I will need to clean up this algorithm before merging. |
Looks very promising. Looking forward to try this merge in real action |
@vshapenko Yes! I will surely publish a preview release. |
Fabulous has to box struct to store them in ViewElement because it stores any kind of value as Also I've been bit by dotnet/fsharp#526 when trying to reduce struct boxing. |
Fabulous.CodeGen/src/Fabulous.CodeGen/Generator/CodeGenerator.fs
Outdated
Show resolved
Hide resolved
Fabulous.XamarinForms/src/Fabulous.XamarinForms.Core/ViewUpdaters.fs
Outdated
Show resolved
Hide resolved
Fabulous.XamarinForms/tests/Fabulous.XamarinForms.Tests/Collections/AdaptDiffTests.fs
Outdated
Show resolved
Hide resolved
Fabulous.XamarinForms/tests/Fabulous.XamarinForms.Tests/Collections/DiffTests.fs
Outdated
Show resolved
Hide resolved
This time, I changed the way we update Attached Properties to avoid passing an overload dictionary each time we update a ViewElement. This removed instantiations of the 5th and 7th most instantiated types, but with apparently little effect on the global memory allocation. |
@TimLariviere , preview is ready to try? |
It's almost ready. Just need to fix the few comments I made and then I'll merge this PR and push the preview package to NuGet. I'll continue working on allocations in a next PR. |
/azp run full build |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run full build |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run full build |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run full build |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run full build |
Azure Pipelines successfully started running 1 pipeline(s). |
It's a concurrent PR to #802 because I'm testing a different approach.
Ultimately only one PR will be merged, containing the best of the 2.
I have been profiling FabulousContacts (slightly modified version) on Windows, in an Android emulator.
Here's the list of changes I made
ViewBuilders.Update...
when comparing old/new values withmatch ... with
Collections.Operation
printf
inViewUpdaters.updateNavigationPages
(should use Program.withConsoleTrace instead in a future version)Array.tryFind (fun x -> ...)
by a simple recursive function to avoid lambda context captureHere's the result as of today (left: Fabulous 0.57, right: this PR)
By allocations
By methods
By assemblies
Top allocations