SourceGrid performance boost

June 13, 2009

Yesterday i’ve worked on SourceGrid. The goal was to create a new sample to show how SourceGrid.DataGrid performs with a data set of 1000000 (one million) rows.

I had to create an asyncrhonyous data loader. I’ve measured that 200k rows are added to System.Data.DataTable in around 4 seconds on my computer.  You can check sample number 53 and see what is the result.

Initially, there a was performance problem with selection drawing code. The problem was that if you select many rows, for example, 900k, then the selection code called the function which calculated the drawing region for it.  I used dotTrace to track down the problem. My observation was that while there were 18 calls to method “Draw”, there where almost 400k calls to get DataRowView from DataTable.

The solution was to clip the selection region with the visible area region. After that, once the DataGrid is finished populating with data, selection and drawing works like a charm.

There are still problems which asynchronous loading, however. If you try to sort a column while the grid has not finished populating, you will get an exception.

I hope this will be a nice feature for somebody ;)


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: