This is a migrated thread and some comments may be shown as answers.

Performance issue when adding items to collection

9 Answers 180 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Geoff Smith
Top achievements
Rank 1
Geoff Smith asked on 16 Jun 2010, 03:12 PM
I'm having some really bad performance when adding rows to the grid. I've got the grid items bound to an ObservableCollection. I'm then adding 7000 rows one-by-one to this collection. It basically freezes up for a couple of minutes.

I've done some profiling to try and find out what's holding things up and it seems to be spending about a 1/3 of the time in QueryableCollectionView:ProcessSynchronousCollectionChangedWithAdjustedArgs. Is there a way to set up the grid to avoid this call?

The main problem in that method is that it calls PropertyChangeInfo:GetChangedPropertyNames which compiles a linq expression foreach each propertyAccess. Any suggestions for improving the performance there?

Thanks!

9 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 16 Jun 2010, 03:16 PM
Hello,

 Can you verify if the grid is not measured with infinity height in your case? This will happen if the grid is inside StackPanel or ScrollViewer or in Grid.Row with Height set to Auto. In this case there will be no virtualization. 

Sincerely yours,
Vlad
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Geoff Smith
Top achievements
Rank 1
answered on 16 Jun 2010, 03:20 PM
Hmm that could be it. Does a RadPane count?

So is it just the immediate parent that counts or must no parent be a stackpanel etc?


0
Vlad
Telerik team
answered on 16 Jun 2010, 03:29 PM
Hello,

 Generally RadPane should not cause such problems. Can you send us small example project (via support ticket) to see what is going on?

Best wishes,
Vlad
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Geoff Smith
Top achievements
Rank 1
answered on 16 Jun 2010, 03:29 PM
Is there a way to check if the virtualization is working?

I tried to move my control so that it's not in one of the cases you mentioned, but I'm getting the same problem. It's not in a Page -> Grid (row height=500) -> UserControl -> RadGridView
0
Geoff Smith
Top achievements
Rank 1
answered on 16 Jun 2010, 03:48 PM
I've uploaded a sample project via a ticket. Thanks for the help!
0
Vlad
Telerik team
answered on 16 Jun 2010, 04:07 PM
Hello,

 I'm reposting my answer here as well.

 I've checked your project and I've noticed that you are using field instead property in the custom class. Bindings can work only with properties and in this case you will get an exception in the Visual Studio Output window for every invalid binding. The next problem is Dispatcher.BeginInvoke which is forcing the operation in the UI thread.

Please find attached modified version of the project and let me know how it goes.


Kind regards,
Vlad
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
TSRG - IT
Top achievements
Rank 1
answered on 30 Jul 2010, 04:36 AM
Hi dudes,

I'm getting a similar issue with my grid, however its only around 600 rows in size and has about 20 columns. The grids ItemsSource is bound to an ObservableCollection of business objects that consist of various properties. The performance of the grid is noticed when I update the the rows and cells in the grid, what happens when I update is I clear the collection, re-add the rows and then update the values in the row. I've noticed after profiling that mine also gets stuck in QueryableCollectionView:ProcessSynchronousCollectionChangedWithAdjustedArgs for a long time - is there anyway to make this process faster? The RadGridView is enclosed a grid with a hard-coded height of 500.

Cheers,

Tim.
0
Geoff Smith
Top achievements
Rank 1
answered on 30 Jul 2010, 07:58 AM
The most important performance related thing I did using the grid was to use RadObservableCollection, which essentially turns off INotifyCollectionChanged so that you can add a load of rows without the grid taking an absolute beating while doing it. Once the data is in though, I didn't have any problems (though turning off real-time scrolling is really good if you have a lot of rows).

As a side note, I didn't actually end up using RadObservableCollection, but my own proxy which automatically turns off notifications if you're trying to add a load of items at once, which is a bit easier to use as you don't have to manually enable / disable notifications.
0
TSRG - IT
Top achievements
Rank 1
answered on 06 Aug 2010, 07:02 AM
Hi Geoff,

I used the RadObservableCollection and it did improve performance however it was not sufficient for our needs, we ended up redesigned our method to obtain the data and as a result did not require to clear and re-add the ObservableCollection on every update and at the moment, is good enough for us! Thank you for your help.
Tags
GridView
Asked by
Geoff Smith
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Geoff Smith
Top achievements
Rank 1
TSRG - IT
Top achievements
Rank 1
Share this question
or