dotnet / DataGridExtensions

Modular extensions for the WPF DataGrid control
MIT License
811 stars 103 forks source link

Performance: Optimize DataGridFilterColumn.GetCellContentData for simple properties #52

Closed siegfriedpammer closed 3 years ago

siegfriedpammer commented 3 years ago

I use DataGridExtensions for the metadata tables in ILSpy. However, on larger tables filtering sometimes takes a long time (3-5 seconds) even for less than 10k entries. When profiling I discovered that a major chunk of the time is spent in DataGridFilterColumn.GetCellContentData to establish and clear the binding to evaluate the SortMemberPath.

Would it be possible to add a setting/option to limit SortMemberPath to simple property names, so that reflection could be used instead of bindings? What else could I do to improve the speed of filtering?

If you are interested in testing this yourself, you can download a nightly build of ILSpy at https://github.com/icsharpcode/ILSpy/actions/runs/622200394 and open the attached ICSharpCode.Decompiler.zip. As a last step navigate to CustomDebugInformation and filter the "Kind" column as shown below:

image

I would be interested in contributing a fix for this problem, if this is an accepted solution.

tom-englert commented 3 years ago

ILSpy is a cool tool, I'm already using it 😄 I tried the steps above, and didn't experience such a huge delay. I also tried to do some optimization by reusing the existing binding, but it only made it worse. (see https://github.com/dotnet/DataGridExtensions/tree/issue%2352) I wonder if using plain reflection would really improve the speed, but you could give it a try...

tom-englert commented 3 years ago

P.S. tried it with reflection, at least that's not slower. Can you test it on the machine where you have experienced the delay?

siegfriedpammer commented 3 years ago

I wonder if using plain reflection would really improve the speed, but you could give it a try...

Is there some way to customize/change this part of the code while still sticking to the Nuget package of DataGridExtensions?

siegfriedpammer commented 3 years ago

P.S. tried it with reflection, at least that's not slower. Can you test it on the machine where you have experienced the delay?

Yes, I changed the method to use reflection and directly referenced that instead of using the nuget package. This improved the performance and that's why I opened this issue to discuss the possibilities of getting the improvement included in the nuget distribution.

tom-englert commented 3 years ago

This is now deployed

siegfriedpammer commented 3 years ago

Wow... I didn't expect to get this into the nuget this fast! Thank you very much!