Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TreeItem is too slow #56234

Closed
fabiospampinato opened this issue Aug 12, 2018 · 4 comments
Closed

TreeItem is too slow #56234

fabiospampinato opened this issue Aug 12, 2018 · 4 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug tree-views Extension tree view issues

Comments

@fabiospampinato
Copy link
Contributor

  • VSCode Version: 1.25.1
  • OS Version: 10.13.5

I've added the following view to Todo+:

screen shot 2018-08-13 at 00 58 43

I've been benchmarking it against magento2, which contains about 30k files and 2M lines of code. If the user has ag installed in his system the process of finding those todos is quite fast, its takes about 4s to do that on my laptop.

Quite surprisingly though the bulk of the time is spent on these lines, which are executed about 1k times, since the extension creates about 1k TreeItems under these circumstances:

screen shot 2018-08-13 at 01 05 42

  • Adding the tooltips requires about 500 extra milliseconds, I would expect that number to be near 0ms, I see basically nothing going on here that can justify that number.

  • Adding the commands requires about 4 extra seconds. 4 seconds for doing what? Creating those objects should be almost free, and until those TreeItems get clicked they don't even change anything as far as the user is concerned, I think.

  • Adding the icons requires about 14 extra seconds. There are less than 10 different images loaded, but for some reason loading them a few hundred times is that slow.

@sandy081
Copy link
Member

@fabiospampinato Is it possible to share the performance profile you created to come up with above numbers?

@sandy081 sandy081 added the info-needed Issue requires more information from poster label Aug 13, 2018
@fabiospampinato
Copy link
Contributor Author

fabiospampinato commented Aug 13, 2018

I don't know what you mean exactly by "performance profile", but I got the numbers this way:

  • Have Todo+ installed, I think it was v4.0.5, but any more recent release should have basically identical performance.
  • Have ag installed in my system.
  • Download magento2 and open it in the VSC window that gets created for debugging extensions.
  • Wrap this line in console.time('foo') and console.timeEnd('foo'), this is where the 4s figure for searching the files comes from
  • Put a if ( !item ) debugger; here, this gets hit right before creating any TreeItem object.
  • Start a stopwatch and continue debugging at the same time.
  • Stop the stopwatch when you see the view populated.

Now:

  • If these lines are commented out the whole thing takes an amount of time that I don't remember, let's call it X, to render the view.
  • If only this line is not commented out it takes about X + 500ms to do the work.
  • If only these lines are not commented out it takes about X + 4s to do the work.
  • If only these lines are not commented out it takes about X + 14s to do the work.
    • You might think that the problem here is actually the code that runs inside Item#setTypeIcon, but that's actually optimized enough to not really matter, and while benchmarking this thing I've replaced the body of the function with something like return '/path/to/my/icon.svg', so that's not the problem.

I've taken these measurements multiple times just to be sure. All those numbers aren't super precise of course. I've run the code on an early-2015 MBP.

I hope this answers your question, let me know if you need anything else.

@sandy081
Copy link
Member

Thanks for detailed explanation. I got it now.

Will investigate.

@sandy081 sandy081 added bug Issue identified by VS Code Team member as probable bug and removed info-needed Issue requires more information from poster labels Aug 14, 2018
@sandy081 sandy081 added this to the September 2018 milestone Aug 14, 2018
@sandy081 sandy081 modified the milestones: September 2018, October 2018 Sep 26, 2018
@sandy081 sandy081 modified the milestones: October 2018, November 2018 Oct 29, 2018
@sandy081 sandy081 modified the milestones: November 2018, December 2018 Dec 5, 2018
@sandy081 sandy081 modified the milestones: February 2019, March 2019 Feb 21, 2019
@sandy081 sandy081 modified the milestones: March 2019, On Deck Mar 27, 2019
@alexr00 alexr00 self-assigned this Oct 7, 2019
@sandy081 sandy081 removed their assignment Jun 10, 2020
@alexr00
Copy link
Member

alexr00 commented Dec 20, 2023

I can see a small slowdown when a command and tooltip are included, but it's 10s of milliseconds, it shouldn't depend on the number of items in the tree, only the number that start out visible, and I don't see an obvious way to bring this down. Since this issue was filed, we've swapped out the internal tree that the extension tree is built on top of. I expect this new tree is faster.

@alexr00 alexr00 closed this as completed Dec 20, 2023
@microsoft microsoft locked and limited conversation to collaborators Jun 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug tree-views Extension tree view issues
Projects
None yet
Development

No branches or pull requests

4 participants