[Blazor] Consider changing the renting strategy for RenderTreeFrame arrays
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
RenderTreeBuilder uses the SharedArrayPool to rent arrays. In many cases having everyone drawing from the same pool results in a lot of rents and returns to the pool, which involves into synchronization consts.
As an alternative strategy we should consider tying the pool to the renderer, so we keep a private per renderer pool that we use before we rent/return arrays to the shared pool.
When we need to grow an array, it's very possible that another component will be able to use the current array, so we don't have to pay the cost of returning it.
Whenever we are done rendering (the renderer is being disposed) or when we finish a render batch, we have the opportunity to decide whether or not we trim the collections of arrays for that renderer or we can choose to make the arrays available as a "pool" to another renderer.
Instead of renting once per array, we can "reuse" an existing lease of arrays with another renderer. We should first do #65190 and then measure afterwards if we still benefit from doing this.
Contributor guide
Assessment
This issue has not been assessed yet.