-
-
Notifications
You must be signed in to change notification settings - Fork 199
Use FSharp.Core.Extended #3164
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
base: main
Are you sure you want to change the base?
Use FSharp.Core.Extended #3164
Conversation
Yeah, fair. I will look at the fantomas codebase and see what it can benefit from. |
Does it need a
A quick attempt at profiling suggests that a version of Seq.tryHead using ValueOption might shave off some Option allocations in a few places fwiw |
That's on my list, however on latest runtime, reference types which do not escape the stack frame can be lifted to be allocated on stack. So this might be an improvement even without that change. |
Does the automatic stack allocation require tryHead to be inline to remove the allocations in .NET 9? A small obervation when I ran the VS memory profiler on the 'Format' benchmark in case it's of interest - it says there are 67781 allocations of 0 length arrays of TriviaNode - Those all appear to be from creating Queues with an explicit 0 capacity at fantomas/src/Fantomas.Core/SyntaxOak.fs Line 34 in bc7402c
155.09 MB to 153.53 MB
|
On the related thought, would the fantomas/src/Fantomas.Core/Trivia.fs Line 161 in d21ab68
Array.tryPick ?
|
Probably, would accept a PR, but I doubt it will have much impact. |
Saves 0.37MB of memory allocations in the benchmark project according to BDN, which is admitedly small compared to 155MB overall |
Before
After
It didn't really do anything for this repo.
Maybe I missed something in setting this up, although we probably don't use any of the optimized APIs.
//cc @vzarytovskii