fluentui-blazor
fluentui-blazor copied to clipboard
fix: High CPU usage in FluentDataGrid
🐛 Bug Report
I stress tested Aspire and had a grid with many rows that updated once a second. I noticed very high CPU usage. I profiled and found uncached usage of Expression.Compile()
.
Profile:
Likely offender: https://github.com/microsoft/fluentui-blazor/blob/4516f9567354f6d721ac9f78c5ec5e055b7868ef/src/Core/Components/DataGrid/Columns/TemplateColumn.cs#L26-L27
Which is called from RenderRow
:
https://github.com/microsoft/fluentui-blazor/blob/4516f9567354f6d721ac9f78c5ec5e055b7868ef/src/Core/Components/DataGrid/FluentDataGrid.razor#L89-L106
💻 Repro or Code Sample
Create a big grid with tooltips. Have it update often.
🤔 Expected Behavior
Renders quickly.
😯 Current Behavior
Very high CPU usage.
💁 Possible Solution
Cache compiled expression.
🔦 Context
🌍 Your Environment
- OS & Device: [e.g. MacOS, iOS, Windows, Linux] on [iPhone 7, PC]
- Browser [e.g. Microsoft Edge, Google Chrome, Apple Safari, Mozilla FireFox]
- .NET and Fluent UI Blazor library Version [e.g. 8.0.2 and 4.4.1]