dotnet / dotnet/aspnetcore

[Blazor] Consider changing the renting strategy for RenderTreeFrame arrays

Open
#65,191 1 comment 0 reactions 0 assignees View on GitHub
area-blazor
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.

Image

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.