Jump to content
Sign in to follow this  
Mike Torrettinni

Slow PgUp in TVirtualStringTree

Recommended Posts

Did anybody encounter a very slow PgUp from the bottom to the top of the TVirtualStringTree?

 

I have 200K+ lines and PgDn from the top scrolls fast. But then I go to the bottom and try PgUp and is really slow... if it's all virtual, why is it slow?

 

I recorded a video on Demo example that comes with Virtual Treeview installation - to make sure it's not my code, and it has the same problem.  If anybody is interested, the video is less than 1 min and you will see the difference from PgDn scrolling from the top and PgUp scrolling from the bottom. Well, it's screencast, so it looses some frames, but the difference is noticeable. In this demo I just changed RootNodeCount to 100000.

 

Is there something I can do to improve this?

 

https://drive.google.com/open?id=1DtFHXLrux0Gnap7DMchlqg0ez8mxoU5k

 

Delphi 10.2

VTVersion = '7.0.0';

Share this post


Link to post
Posted (edited)

I can't exactly remember but I can see in my sources that I'm caching (also calculating myself, only once)

the Nodeheight's and returning it in VSTMeasureItem event for VT.

 

This would not make any sense if it wasn't too slow for me too, back to the days.

 

Can't remember.

Edited by Attila Kovacs

Share this post


Link to post

Try a later VT version; I think 7.2.1 is the latest.  I have noticed several speed enhancements mentioned in the changes/fixes.

Share this post


Link to post
3 hours ago, timfrost said:

Try a later VT version; I think 7.2.1 is the latest.  I have noticed several speed enhancements mentioned in the changes/fixes.

Thanks for suggestion, but the results are the same. Strange, annoying.

 

Maybe it needs descending index defined, as we had to do decades ago on some databases for scrolling descending to work 🙂

Share this post


Link to post

Just tried the exact same demo with 7.2.1 and 1million root nodes, it's fast as lightning in both directions.

Share this post


Link to post
2 hours ago, Attila Kovacs said:

Just tried the exact same demo with 7.2.1 and 1million root nodes, it's fast as lightning in both directions.

Thanks, but things are getting even stranger... I restarted my computer and demo project got better.

 

Then I created a new project and reproduced behavior and then I started commenting out and now I have this very odd situation:

 

If I use this code in FormCreate - it slows down the PgUp scrolling... and if I use it in Button click, it doesn't!

 

SetLength(TestArray, 1000000);
  for i := Low(TestArray) to High(TestArray) do
  begin
    TestArray[i].Text := 'Text ' + inttostr(i);
    TestArray[i].Text2 := 'Text2 ' + inttostr(i);
  end;

 

And I don't use this TestArray at all, I just fill up the data and nothing else. The Virtual Treeview is not connected to this array at all.

 

The definition:

 

TTestRec = record
  Text: string;
  Text2: string;
end;

var TestArray: TArray<TTestRec>;

 

It could be my system memory is corrupt or dying, because this makes absolutely no sense and I wasted the whole day on this... very frustrating. It feels like I'm going crazy....

 

If anybody has any idea, I would appreciate any advice! Thanks!

Share this post


Link to post

If anybody would be so kind to take 2 minutes to see if the behavior is replicated, I would appreciate any feedback!

I attached a simle project with this behavior.

 

1. See commented lines in FormCreate, so no array created: - run and scroll down with PgDn... see it goes fast, now jump to the end (cltr+end) and scroll up with PgUp... also fast. OK!

2. Now uncomment code in FormCreate and do the same.. you will see PgUp from the bottom is not fast as PgDn from the top, anymore!

3. Comment the code in FormCreate, run project and now click Button1 to execute same code as in FormCreate... you will see PgUp is again fast as PgDn!

 

Delphi 10.2

Virtualtree View 7.2.1

PgUp scrolling.zip

Share this post


Link to post
Posted (edited)

Yup. App takes over 200MB RAM and windows starts swapping, you can see the Page Faults in the task manager.

Also thats why backwards is slower.

 

I have no clue how can one influence that, never had a problem like that.

Edited by Attila Kovacs

Share this post


Link to post

Thanks, I'm glad I'm not going crazy! 🙂 or that I need new PC...

 

Did you notice this issue only when running code in FormCreate and not in Button1 click?

Share this post


Link to post

In the first case VT nodes are getting its memories after the TestArray, and they will be swapped.

 

Share this post


Link to post
Posted (edited)

No. Memory will be remapped from X in Y length. Now, that you are scrolling backwards, it remaps every time a X-rowcount+Y chunk.

Maybe you could read something from X-Y+rowcount but how would you know that the memory will be mapped and what Y is.

But as I said I have no experience with this. Maybe somebody has some other thoughts on it too.

 

 

Edited by Attila Kovacs

Share this post


Link to post

I tried using ProDelphi to see which method uses most time in VirtualTrees.pas and the ones that do are related to Cache... so you are right, definitely something to do with memory access. Still doesn't make sense, but I guess it's one of those 'accept it and let it go' features/behaviors.☹️

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×