You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem?
Strings are omnipresent and recent discussions and profiling have shown that improvements can be made here that may be applicable to other parts of the ecosystem.
Describe the solution you'd like
Several options have come forward and are up for discussion:
Find cases where StringBuilder is used and investigate if improvements are viable with StringBuilderCache (currently private in BCL, uses thread-local storage)
Where heavy string-copying is used locally, investigate use of ArrayPool, possibly cherry-picking from System.Buffer. The advantage here is that zeroing of memory is skipped. This cannot be used for shared instances of SB or strings.
On hot paths, check if using ReadOnlySpan and/or String.Create can help. This is .NET Standard 2.1, so we can only do that in FCS and tooling, I think
Where high GC pressure and/or LOH pressure is recognized we should perhaps consider using fixed, similar to how BCL does it. For string scenarios this can bring pressure down by 2x.
Improve array manipulations by dipping into the ArrayPool technique and/or by speeding up array creation and copying in scenarios similar to Array.map/collect.
Investigate if we can use cpblk or initblk in certain scenarios. These have recently been highly improved in the CLR
Additional context
My idea is to discuss/brainstorm perf ideas (please check the prev. discussions) and the scope and then, where applicable, use separate issues for defined targets. One I've been working on silently has been Array.xxx functions, which are already highly optimized, but some measurements suggest there's room for further improvement.
Is your feature request related to a problem?
Strings are omnipresent and recent discussions and profiling have shown that improvements can be made here that may be applicable to other parts of the ecosystem.
I've created this issue to discuss some options.
StringBuilderCache: String map performance improvement #9470 (comment) and String map performance improvement #9470 (comment)Describe the solution you'd like
Several options have come forward and are up for discussion:
StringBuilderis used and investigate if improvements are viable withStringBuilderCache(currently private in BCL, uses thread-local storage)ArrayPool, possibly cherry-picking fromSystem.Buffer. The advantage here is that zeroing of memory is skipped. This cannot be used for shared instances of SB or strings.ReadOnlySpanand/orString.Createcan help. This is .NET Standard 2.1, so we can only do that in FCS and tooling, I thinkfixed, similar to how BCL does it. For string scenarios this can bring pressure down by 2x.ArrayPooltechnique and/or by speeding up array creation and copying in scenarios similar toArray.map/collect.cpblkorinitblkin certain scenarios. These have recently been highly improved in the CLRAdditional context
My idea is to discuss/brainstorm perf ideas (please check the prev. discussions) and the scope and then, where applicable, use separate issues for defined targets. One I've been working on silently has been
Array.xxxfunctions, which are already highly optimized, but some measurements suggest there's room for further improvement.