fluentui-blazor icon indicating copy to clipboard operation
fluentui-blazor copied to clipboard

fix: High CPU usage in FluentDataGrid

Open JamesNK opened this issue 5 months ago • 0 comments

🐛 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: image

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]

JamesNK avatar Mar 02 '24 09:03 JamesNK