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

Excess CPU usage editing C file #28406

Closed
HankB opened this issue Jun 10, 2017 · 14 comments
Closed

Excess CPU usage editing C file #28406

HankB opened this issue Jun 10, 2017 · 14 comments
Assignees
Labels
freeze-slow-crash-leak VS Code crashing, performance, freeze and memory leak issues info-needed Issue requires more information from poster

Comments

@HankB
Copy link

HankB commented Jun 10, 2017

  • VSCode 1.13.0:
  • OS Version: Debian Stretch
    Linux yggdrasil 4.9.0-3-amd64 Open Source VS Code #1 SMP Debian 4.9.30-1 (2017-06-04) x86_64 GNU/Linux
    Extensions
  • C/C++ 0.11.4
  • Code Runner 0.6.18
  • go 0.6.62
  • Instant Markdown 1.1.0
  • markdownlint 0.9.1
  • Python 0.6.4
  • Rust 0.3.14

Steps to Reproduce:

1.Open code with no files.
2. Enter the following code and save as "hello.c"
#include <stdio.h>

int main(int argc, const char** argv)
'''
{
printf("Hello world\n");
}
'''
3. 'top' now shows:
'''
top - 22:06:28 up 36 min, 1 user, load average: 1.71, 1.84, 1.61
Tasks: 295 total, 2 running, 293 sleeping, 0 stopped, 0 zombie
%Cpu(s): 13.5 us, 1.6 sy, 0.9 ni, 83.4 id, 0.4 wa, 0.0 hi, 0.1 si, 0.0 st
KiB Mem : 16351232 total, 5953836 free, 6084328 used, 4313068 buff/cache
KiB Swap: 16777212 total, 16777212 free, 0 used. 9294920 avail Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
5985 hbarta 20 0 1280180 457924 8128 S 93.8 2.8 10:41.90 Microsoft.VSCod
5954 hbarta 20 0 2136680 797576 34736 R 12.5 4.9 4:46.08 code
1303 hbarta 20 0 392312 87068 38956 S 6.2 0.5 0:41.46 Xorg
2117 hbarta 20 0 1549332 415720 157608 S 6.2 2.5 2:47.64 chrome
6342 hbarta 20 0 978204 173588 73288 S 6.2 1.1 0:12.55 chrome
1 root 20 0 139296 7108 5320 S 0.0 0.0 0:01.42 systemd
.
.
.
'''
4. Exit code. 'top' now shows
'''
top - 22:07:39 up 37 min, 1 user, load average: 1.71, 1.82, 1.62
Tasks: 290 total, 1 running, 289 sleeping, 0 stopped, 0 zombie
%Cpu(s): 13.3 us, 0.9 sy, 0.0 ni, 85.2 id, 0.4 wa, 0.0 hi, 0.1 si, 0.0 st
KiB Mem : 16351232 total, 6651644 free, 5141652 used, 4557936 buff/cache
KiB Swap: 16777212 total, 16777212 free, 0 used. 10278940 avail Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
5985 hbarta 20 0 1280180 467888 8600 S 96.7 2.9 11:49.76 Microsoft.VSCod
2117 hbarta 20 0 1546260 417420 157568 S 3.3 2.6 2:50.20 chrome
2227 hbarta 20 0 953248 148904 77316 S 3.0 0.9 1:04.15 chrome
6342 hbarta 20 0 978204 174968 73284 S 3.0 1.1 0:14.87 chrome
2199 hbarta 20 0 764124 229220 134716 S 1.7 1.4 1:22.64 chrome
.
.
.
'''

Microsoft.VSCod continues to execute for a couple minutes and finally exits.

Possible duplicate of #28378

@HankB
Copy link
Author

HankB commented Jun 11, 2017

With all extensions disabled and no files open 'top' shows at minimum 1 core at 100% and up to three cores active:

'''
top - 19:29:24 up 21:58, 1 user, load average: 1.31, 0.75, 0.40
Tasks: 299 total, 2 running, 297 sleeping, 0 stopped, 0 zombie
%Cpu(s): 23.9 us, 4.4 sy, 0.0 ni, 71.6 id, 0.1 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 16351232 total, 795876 free, 6959320 used, 8596036 buff/cache
KiB Swap: 16777212 total, 16776544 free, 668 used. 8299908 avail Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
16221 hbarta 20 0 1984908 1.036g 34672 R 111.3 6.6 1:36.16 code
16167 hbarta 20 0 2325960 228372 66472 S 74.8 1.4 0:25.14 code
16135 hbarta 20 0 1580000 96244 73720 S 34.6 0.6 0:12.10 code
2929 hbarta 20 0 1282400 341232 108408 S 4.0 2.1 19:16.57 chrome
2117 hbarta 20 0 1637660 421892 116896 S 2.3 2.6 39:24.86 chrome
2641 hbarta 20 0 84.093g 18500 10908 S 1.0 0.1 7:09.46 nacl_helper
3087 hbarta 20 0 1114584 243484 69028 S 0.7 1.5 3:51.63 chrome
2227 hbarta 20 0 978204 159016 67776 S 0.3 1.0 18:05.28 chrome
'''

@HankB
Copy link
Author

HankB commented Jun 11, 2017

I have found that if code is allowed to run long enough (on the order of several minutes) the CPU load seems to go down. Opening a new file or reopening an existing file does not seem to provoke excess CPU usage.

As such I would classify this as a low priority bug.

@ramya-rao-a ramya-rao-a added freeze-slow-crash-leak VS Code crashing, performance, freeze and memory leak issues and removed freeze-slow-crash-leak VS Code crashing, performance, freeze and memory leak issues labels Jun 12, 2017
@bpasero
Copy link
Member

bpasero commented Jun 13, 2017

To find out more about this issue, we need to get at the process that is causing the high load. VS Code creates multiple processes, each with different tasks. Depending on your OS you can get at the full command line of the process and paste it here. On Mac, the Activity Monitor allows to find the PID of the process and from a terminal ps aux | grep <pid> reveals its arguments.

image

On Windows a tool like Process Explorer helps:

image

Once you have the information please update this issue with it. Thanks!

@bpasero bpasero added the info-needed Issue requires more information from poster label Jun 13, 2017
@bpasero bpasero added this to the Backlog milestone Jun 13, 2017
@bpasero bpasero added the freeze-slow-crash-leak VS Code crashing, performance, freeze and memory leak issues label Jun 13, 2017
@HankB
Copy link
Author

HankB commented Jun 13, 2017

code.txt
top.txt

I have attached two text files. 'code.txt' is the result of 'ps -ef' filtered for the processes with the name '/usr/share/code/code' and 'Microsoft.VSCod' which capture the processes of which I am aware. (The latter seems to relate to the C/C++ extension as it does not appear if that extension is disabled.)

'top.txt' is the output of 'top' at about the same time and which shows the processes that are using 100% CPU.

I'm using Linux and you explained how to collect the information for Windows and Mac OS. Does this provide the information you need?

thanks,
hank

@jrieken jrieken removed their assignment Jun 13, 2017
@jrieken
Copy link
Member

jrieken commented Jun 13, 2017

Yeah, two bad things happen here: FileWatcher going crazy and CPP tools going crazy. For the latter, please file a separate issue in their repo. Thanks

@HankB
Copy link
Author

HankB commented Jun 13, 2017

I've filed an issue against cpptools.
Since the issue seems file related I will add the following information:

  • Filesystem EXT4
  • Device SATA SSD (on a laptop with I7-4710HQ processor and 16MB RAM.)
  • Project is in a subdirectory of '~/Documents/C/c-txtutil/' where '/home/hbarta/Documents' is a symlink to '/mnt/home/hbarta/Documents'

@bpasero
Copy link
Member

bpasero commented Jun 13, 2017

@HankB is that a folder with lots of files you are opening?

@HankB
Copy link
Author

HankB commented Jun 13, 2017

I don't think so:
hbarta@yggdrasil:~/Documents/C/c-txtutil/cpputest-starter-project$ find . |wc -l
71

@HankB
Copy link
Author

HankB commented Jun 14, 2017

New useful information: I'm 'on the road' this morning and using a Toshiba chromebook converted to run Ubuntu 16.04. (H/W - Celeron N2840, 4GB RAM and running off a USB thumb drive.) Kernel is:
hbarta@swanky:~/Documents/C/c-txtutil/cpputest-starter-project$ uname -a
Linux swanky 4.4.0-79-generic #100-Ubuntu SMP Wed May 17 19:58:14 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
It is using the same VS code and CPP extension versions and fewer other extensions.
VS code 1.13.0
C/C++ 0.11.4
Rich Go language 0.6.62

This platform (opening files in a directory cloned from the project on the other laptop) does not exhibit the high CPU usage with either VS Code or the CPP extension (and running the same version of each.) It seems like there is something about the other PC that is provoking the problem. I would consider two possibilities:

  1. Something in files left behind in in the filesystem by previous versions of VS code or the CPP plugin causes this problem with the most recent iteration. If you would like, I can archive the entire project directory (or other directory where VS code stores information) and provide copies of that.
  2. Some race condition causes startup processing to not proceed normally. If I were tracking something like that down, I would run the program under a debugger and halt it (multiple times) to see where it was executing and perhaps step through some code to determine why. Unfortunately I have no experience with Javascript debugging. If you point me to some helpful information on that I'm willing to give this a try. If a debug build is required, I would need that as well.

Edit: There are differences in custom settings between the PCs and I will report those when I have access to both. (Both have minimap enabled and the problem PC has a custom dictionary which is now flagged as an error.)

@HankB
Copy link
Author

HankB commented Jun 14, 2017

On another PC Desktop) with a faster I7, more RAM and RAIDed SSDs I do not experience the excessive CPU issue so I am leaning toward the first possible cause in the previous comment.

Edit: Red Herring. CPU uisage on this third machine is high too.

@bpasero
Copy link
Member

bpasero commented Nov 15, 2017

Does it still reproduce?

@bpasero bpasero added info-needed Issue requires more information from poster and removed info-needed Issue requires more information from poster labels Nov 15, 2017
@bpasero bpasero removed this from the Backlog milestone Nov 15, 2017
@HankB
Copy link
Author

HankB commented Nov 15, 2017 via email

@bpasero
Copy link
Member

bpasero commented Nov 16, 2017

I wonder if this issue is being caused by an installed extension. Can you try to run VS Code without extensions? From the command line (NOT the integrated terminal in Code), execute: code --disable-extensions and try your steps again to see if it reproduces. If you see it is an issue with the extension, please file it against the extension repository itself.

@bpasero bpasero closed this as completed Nov 25, 2017
@HankB
Copy link
Author

HankB commented Nov 27, 2017 via email

@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 9, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
freeze-slow-crash-leak VS Code crashing, performance, freeze and memory leak issues info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

4 participants