Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Row caching and vertical scroll performance

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support
View previous topic :: View next topic  
Author Message
jkempner



Joined: 03 Sep 2008
Posts: 17

PostPosted: Thu Aug 11, 2011 6:19 pm    Post subject: Row caching and vertical scroll performance Reply with quote

I have a very large List that I'm using as the data source for a VirtualTree. I'm using VirtualTree 3.14.

The problem that I'm having is that it doesn't seem to create the row cache after I add a number of rows to the List and call UpdateRows. The result is that scrolling is painfully slow (many seconds to scroll down by a single page) until each row has been displayed once. Once all the rows have been displayed, and presumably the row cache has been build, scrolling is reasonably quick.

The long delay in adding to the row cache is because the backing data comes from a database hosted over the LAN, and accessing large numbers of records from that database can be slow.

Is there a way to force all the rows to be cached when the data are loaded so the scrolling performance will be usable? The VirtualTree control is in a dialog where the data are loaded when the dialog itself loads, with suitable feedback to the user about the load time progress, so if caching the data adds to the dialog load time, that's perfectly acceptable.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Thu Aug 11, 2011 10:34 pm    Post subject: Reply with quote

Normally you would to make use of the virtual paging capability in this sort of scenario - otherwise your customer will have to wait much longer for all the data to load. However it you really want to force loading upfront you should be able to do this. Depending on your data source you can either do this yourself (ie fetch all the data into local memory before binding the data to Virtual Tree). Alternatively you could force Virtual Tree to enumerate all the rows by calling:

Code:
 _tree.GetRows(_tree.FirstRowIndex, _tree.LastRowIndex);


Another option to consider is keeping the virtual paging but implement a background fetching strategy - so that when the dialog is opened you start fetching the all the data into local memory on a background thead. This would still allow the dialog to open quickly but when the user scrolled the required data would then hopefully be available.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
jkempner



Joined: 03 Sep 2008
Posts: 17

PostPosted: Fri Aug 12, 2011 11:34 am    Post subject: Reply with quote

The good news is that calling GetRows(), even on the main thread, doesn't add appreciably to the dialog's load time. The bad news is that it doesn't seem to help - scrolling through the tree the first time is still painfully slow. For whatever reason, GetRows() doesn't appear to build the row cache.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Mon Aug 15, 2011 12:18 am    Post subject: Reply with quote

What is the value of the LastRowIndex property when call GetRows. You need to call GetRows after the DataSource has been set so that this has been evaluated. Calling GetRows like this forces VirtualTree to create the Row objects and call IList[index] to get the item at each index of the bound data source. How this affects your application depends on how you have implemented the datasource. Have you build a custom datasource that implements IList to get virtual loading?
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
jkempner



Joined: 03 Sep 2008
Posts: 17

PostPosted: Mon Aug 15, 2011 10:29 am    Post subject: Reply with quote

LastRowIndex is equal to the number of rows that should be loaded into the control at the time GetRows is called. I made sure of that before posting my follow-up question. Smile

Unfortunately, the data source doesn't implement IList. It might be possible to tweak it so that it does - would this be expected to solve the problem?
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Mon Aug 15, 2011 12:11 pm    Post subject: Reply with quote

Virtual Tree requires the DataSource to implement the IList interface so I'm pretty sure it already does - but it just depends on how this is implemented. What is the data source you are binding to? How does the data get marshalled over the network?
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
jkempner



Joined: 03 Sep 2008
Posts: 17

PostPosted: Mon Aug 15, 2011 1:27 pm    Post subject: Reply with quote

I've simplified the programmatic data binding to be more efficient. There were two columns with CheckBox editors where OnGetCellData wasn't using the DataSource, and that's now fixed. So yes, DataSource implements IList - it's just a List<T>, where the data type is a custom type that's database-backed.

It seems that the best solution is to force the local cached copy of the backing database to be used instead of trying to marshal the data over the network. Doing this seems to solve the problem for all intents and purposes.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group