Change the 'run rule' functions to special case empty arrays, in orde…#851
Draft
Numpsy wants to merge 1 commit intofsprojects:masterfrom
Draft
Change the 'run rule' functions to special case empty arrays, in orde…#851Numpsy wants to merge 1 commit intofsprojects:masterfrom
Numpsy wants to merge 1 commit intofsprojects:masterfrom
Conversation
…r to reduce the number of allocated zero length arrays. As it stands, running the rules allocates a massive number of zero length arrays, which has quite a large effect on the amount of memory allocated. Many of these are from FSharp.Core functions which always create a new array, but which can be avoided with small local wrappers.
749e33e to
093f1c2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…r to reduce the number of allocated zero length arrays.
As it stands, running the rules allocates a massive number of zero length arrays, which has quite a large effect on the amount of memory allocated. Many of these are from FSharp.Core functions which always create a new array, but which can be avoided with small local wrappers.
Just trying to get back to looking at some perf tests I started some time back, and found this one.
Running the Visual Studio memory profiler on the functions in the benchmarks project shows the allocations of massive numbers of zero length arrays (over 4 million in total). e.g.
If I run the benchmarks project with memory diagnosis enabled, I get this with the current code
Down to this with this change
If I enable all of the extra checks that are enabled in the 'run self checks' leg of the CI then the differences are even larger.
Before
After
These allocations are caused by FSHarp.Core liking to always create new arrays in various
Arrayfunctions, but to me it looks like it's a big enough gain to special case it locally?...Note: There are other places that could maybe be changed as well, and a similar situation with Array.collect, but I left it just doing one thing to get comments.