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

"Extension causes high cpu load" warning at startup for slow filesystems and large folders #1819

Closed
jordanlesson opened this issue Jun 24, 2019 · 12 comments
Milestone

Comments

@jordanlesson
Copy link

  • Issue Type: Performance
  • Extension Name: dart-code
  • Extension Version: 3.1.0
  • OS Version: Darwin x64 17.7.0
  • VSCode version: 1.35.1

⚠️ Make sure to attach this file from your home-directory:
⚠️/Users/jordanlesson/Dart-Code.dart-code-unresponsive.cpuprofile.txt

Find more details here: https://github.com/Microsoft/vscode/wiki/Explain:-extension-causes-high-cpu-load

@DanTup
Copy link
Member

DanTup commented Jun 25, 2019

⚠️ Make sure to attach this file from your home-directory:
⚠️/Users/jordanlesson/Dart-Code.dart-code-unresponsive.cpuprofile.txt

Thanks for the report, but you need to attach this file for this to be investigated.

If you saw the issue at startup, I suspect it's #1628 which is fixed for the next version (which you can try out a beta release of from https://github.com/Dart-Code/Dart-Code/releases).

@DanTup DanTup added the awaiting info Requires more information from the customer to progress label Jun 25, 2019
@Ero-Raghav
Copy link

@DanTup
Copy link
Member

DanTup commented Jul 8, 2019

@Ero-Raghav how many folders are in the top 3 levels of your project? And how fast is your machine/disk?

Your profile shows it sometimes taking 100ms to check a folder on disk, and we do this quite a lot while scanning looking for Dart/Flutter projects. It quickly adds up to 3 seconds, which causes VS Code to show this message (which is slightly misleading - it's not high CPU, it's time spent blocking the thread on I/O).

@DanTup
Copy link
Member

DanTup commented Jul 9, 2019

I did some testing on a folder that contains 1088 projects in the top 3 levels, but my times are so fast it's hard to optimise. I tried several other options (including making the search parallel/async and using the glob package) but they were all much slower.

I'll investigate removing some exists checks which did have an improvement, but I'll need more info about your setup to do much more (things that are likely to be a factor are the number files/folders in the top 3 levels of the folder you opened in VS Code, the speed of your filesystem, and whether the filesystem may have been under load while this was happening).

Screenshot 2019-07-09 at 11 51 51 am

DanTup added a commit that referenced this issue Jul 9, 2019
@Ero-Raghav
Copy link

@DanTup

It may be possible that it's because of slow HDD, because i never got this problem on my other system which have relatively faster HDD.

@DanTup
Copy link
Member

DanTup commented Jul 10, 2019

What sort of disk is in the one this occurred on? Is the machine generally really slow to use? I'd like to support as many machines as possible, but the numbers in that trace seem particularly slow (in my test above I scanned thousands of folders to find 1088 projects in 88ms, but your trace shows individual file-exists checks taking over 100ms).

@Ero-Raghav
Copy link

Ero-Raghav commented Jul 10, 2019

its ATA Hitachi HTS72503 320GB HDD, and Yes its Generally slow to use (mostly when i am using vs-code) because of CPU bottleneck.

@DanTup
Copy link
Member

DanTup commented Jul 10, 2019

And how big is the folder you're opening? (how many folders at the top, 2nd, 3rd levels?).

@Ero-Raghav
Copy link

around 1.3 GB and there are 16 folder at top level and level 2 and 3 have variable number of folders ranging from 4 to 40

@DanTup
Copy link
Member

DanTup commented Jul 10, 2019

Ok, it does at least seem like it may have had a lot of folders to scan. I'd prefer not to make this code async just to avoid this warning (since it gets slower for everyone) if it's only on slow machines and large folders. I think either you could ignore the message (it's not causing any harm - and despite the text, it's not using high CPU) or try to open smaller portions of your tree.

I will try to eliminate some of the redundant exists checks though, that should help a little.

@DanTup DanTup changed the title Extension causes high cpu load "Extension causes high cpu load" warning at startup for slow filesystems and large folders Jul 10, 2019
@DanTup DanTup added this to the v3.3.0 milestone Jul 10, 2019
@DanTup DanTup added is performance and removed awaiting info Requires more information from the customer to progress labels Jul 10, 2019
DanTup added a commit that referenced this issue Jul 10, 2019
@DanTup DanTup closed this as completed in 5b8bcb0 Jul 10, 2019
@DanTup
Copy link
Member

DanTup commented Jul 10, 2019

I managed to shave around a third of the time off (on my machine) by using withFileTypes to avoid the extra exists+stat checks:

Screenshot 2019-07-10 at 11 53 25 am

This should improve things but if you (or anyone else) seems to hit this on reasonable disks and/or with fairly small folders, please do shout!

@Ero-Raghav
Copy link

@DanTup Thank You

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants