Hi,
Not sure if this is of interest or not, but given all the current work with optimisations I'll query it:
I was recently doing some profiling on FSharpLint, and found that there were massive amounts of allocations of zero length arrays occurring when calling Array.collect with empty arrays as inputs - see fsprojects/FSharpLint#873 where FSharpLints own benchmark project was showing ~1.3 million allocations of each of a one dimensional and two dimensional arrays of warnings.
This seems particularly noticeable in collect() as it creates two zero length arrays per call - the intermediate one for collecting results and the final one that's returned to callers - so I wonder if it'd be worth doing something to avoid at least one of those? (I'm not sure if returning Array.empty would be permitted or not, but maybe the intermediate one can be improved).
There's a similar situation with Array.map creating a zero length array for empty inputs, though the documentation fort that does say Builds a new array so maybe that's technically expeted
Hi,
Not sure if this is of interest or not, but given all the current work with optimisations I'll query it:
I was recently doing some profiling on FSharpLint, and found that there were massive amounts of allocations of zero length arrays occurring when calling Array.collect with empty arrays as inputs - see fsprojects/FSharpLint#873 where FSharpLints own benchmark project was showing ~1.3 million allocations of each of a one dimensional and two dimensional arrays of warnings.
This seems particularly noticeable in collect() as it creates two zero length arrays per call - the intermediate one for collecting results and the final one that's returned to callers - so I wonder if it'd be worth doing something to avoid at least one of those? (I'm not sure if returning Array.empty would be permitted or not, but maybe the intermediate one can be improved).
There's a similar situation with Array.map creating a zero length array for empty inputs, though the documentation fort that does say
Builds a new arrayso maybe that's technically expeted