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

Code Helper High CPU Usage #156810

Closed
fishcharlie opened this issue Aug 1, 2022 · 17 comments · Fixed by microsoft/vscode-js-debug#1378
Closed

Code Helper High CPU Usage #156810

fishcharlie opened this issue Aug 1, 2022 · 17 comments · Fixed by microsoft/vscode-js-debug#1378
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues verified Verification succeeded

Comments

@fishcharlie
Copy link

fishcharlie commented Aug 1, 2022

Does this issue occur when all extensions are disabled?: Yes

I thought this might have been due to an extension since I ran disable-extensions and it didn't happen that quickly, but after running Extension Bisect it happened, and gave me a message Extension Bisect is done but no extension has been identified. This might be a problem with Code.. As mentioned below this might have been because it attached to a process and was trying to debug a Node.js process. I noticed after I started Extension Bisect that the debugger attached only when I started Extension Bisect (I had an existing process running before that, that maybe failed to attach???).

  • VS Code Version: Version: 1.69.2 (Universal)
  • OS Version: 13.0 Beta (22A5311f)

Steps to Reproduce:

Unknown exactly how to reproduce this, but it happens pretty frequently. Shortly after launching VS Code the Code Helper process takes up a lot of CPU usage. It seems like this might be correlated to when I start debugging a Node.js process.

One more note, I'm running 2 processes: tsc --watch & nodemon.

Attached are some screenshots that might be helpful.

Please let me know what additional steps I can do to help debug/troubleshoot this.

Screenshot 2022-08-01 at 10 23 29 AM

Screenshot 2022-08-01 at 10 13 01 AM

Screenshot 2022-08-01 at 10 12 56 AM

@ZrowGz
Copy link

ZrowGz commented Aug 1, 2022

I just installed VSCode on a new MacStudio, everything up to date. I'm getting a similar issue, where Code Helper (renderer) is utilizing 100-500% of all 12 M1 Max cores, which seems absurd. The version I had on the macbook pro previously did not do this.

I have not installed any extension yet, nor changed any settings when this first started (as soon as vscode installed). And it has persisted since syncing it with the settings stored from the previous computer's installation.

Image of Activity Monitor:
Screen Shot 2022-08-01 at 1 12 19 PM

A close up of the highlighted process in the above image:
Screen Shot 2022-08-01 at 1 13 44 PM

A look at the running processes/extensions:
Screen Shot 2022-08-01 at 1 18 59 PM

Disabling all installed extensions doesn't change the CPU demand.

@fishcharlie
Copy link
Author

fishcharlie commented Aug 2, 2022

@ZrowGz Don't think Code Helper and Code Helper (Renderer) are the same thing. Might want to create a different issue...

@mjbvz
Copy link
Collaborator

mjbvz commented Aug 4, 2022

@fishcharlie Can you yay to get the full arguments of the process that have high cpu usage? You can do this in the terminal by getting the relevant process id (from activity monitory) and running:

ps aux PROCESS_ID | cat

This should print something like:

matb 76561   0.0  1.0 74176948 348152   ??  S     8:03AM  11:28.20 /Applications/Visual Studio Code - Insiders.app/Contents/Frameworks/Code - Insiders Helper.app/Contents/MacOS/Code - Insiders Helper --ms-enable-electron-run-as-node --max-old-space-size=3072 /Users/matb/projects/vscode/node_modules/typescript/lib/tsserver.js --useInferredProjectPerProjectRoot --enableTelemetry --cancellationPipeName /var/folders/5d/nlg411_s0570wmycdwkgqrf40000gn/T/vscode-typescript501/44b9312a5c2f3d8312ca/tscancellation-ecce3c5a346157b94edc.tmp* --logVerbosity verbose --logFile /Users/matb/Library/Application Support/Code - Insiders/logs/20220803T080057/exthost5/vscode.typescript-language-features/tsserver-log-RbSv7U/tsserver.log --locale en --noGetErrOnBackgroundUpdate --validateDefaultNpmLocation --useNodeIpc

@mjbvz mjbvz added the info-needed Issue requires more information from poster label Aug 4, 2022
@fishcharlie
Copy link
Author

@mjbvz Here you go:

ps aux 74126 | cat
USER          PID  %CPU %MEM      VSZ    RSS   TT  STAT STARTED      TIME COMMAND
charliefish 74126 107.4  0.8 479096624 505648   ??  R     8:49PM 425:32.72 /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper.app/Contents/MacOS/Code Helper --ms-enable-electron-run-as-node --inspect-port=0 /Applications/Visual Studio Code.app/Contents/Resources/app/out/bootstrap-fork --type=extensionHost --skipWorkspaceStorageLock

@mjbvz mjbvz assigned jrieken and unassigned mjbvz Aug 5, 2022
@panchi64

This comment was marked as off-topic.

@jrieken

This comment was marked as resolved.

@jrieken
Copy link
Member

jrieken commented Aug 15, 2022

When this happens please use this guide to profile the extension host: https://github.com/Microsoft/vscode/wiki/Performance-Issues#profile-the-running-extensions

@fishcharlie
Copy link
Author

@jrieken Thanks for the reply. As I mentioned in my original post:

I thought this might have been due to an extension since I ran disable-extensions and it didn't happen that quickly, but after running Extension Bisect it happened, and gave me a message Extension Bisect is done but no extension has been identified. This might be a problem with Code.. As mentioned below this might have been because it attached to a process and was trying to debug a Node.js process. I noticed after I started Extension Bisect that the debugger attached only when I started Extension Bisect (I had an existing process running before that, that maybe failed to attach???).

There is some strong evidence that this is not due to an extension.

I'd be curious to hear what evidence you have that it is due to an extension. Really trying to narrow this down, but based on my findings it's not due to an extension.

@jrieken
Copy link
Member

jrieken commented Aug 15, 2022

First, bisect doesn't blame built-in extensions so it might well be one of those. Second, the extension host process, which you identified, runs not just extensions but also stuff to run them in the first place. It might that. Any of those issues should become visible with the afore mentioned profiling of the extesion host process

@vscodenpa
Copy link

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

@vscodenpa vscodenpa closed this as not planned Won't fix, can't repro, duplicate, stale Aug 23, 2022
@fishcharlie
Copy link
Author

@jrieken Apologizes for the delay on this. Hopefully this can be reopened.

I have attached a screenshot and the profile. At first glance it looks like this might be due to the JavaScript Debugger.

Screenshot 2022-08-29 at 8 39 18 PM

CPU-20220830T023847.629Z.cpuprofile.txt

@jrieken
Copy link
Member

jrieken commented Aug 30, 2022

Yeah, looks like it. Reopening and forwarding to @connor4312 for investigation

Screenshot 2022-08-30 at 08 25 52

Screenshot 2022-08-30 at 08 25 45

@jrieken jrieken reopened this Aug 30, 2022
@jrieken jrieken removed the info-needed Issue requires more information from poster label Aug 30, 2022
@jrieken jrieken assigned connor4312 and unassigned jrieken Aug 30, 2022
@connor4312 connor4312 added this to the September 2022 milestone Aug 30, 2022
@connor4312 connor4312 added bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues labels Aug 30, 2022
@fishcharlie
Copy link
Author

@connor4312 @mjbvz Is there any chance this could be included in August 2022 Recovery 1 (#160335)?

@connor4312
Copy link
Member

This bug has been around for a couple years, so I don't feel it's a recovery candidate. However note you can switch to the nightly extension to get the fix.

@fishcharlie
Copy link
Author

@connor4312 Thanks! I'll give that a shot.

@mjbvz mjbvz added the author-verification-requested Issues potentially verifiable by issue author label Sep 29, 2022
@mjbvz
Copy link
Collaborator

mjbvz commented Oct 4, 2022

@connor4312 Can you please provides steps to verify this?

@connor4312
Copy link
Member

connor4312 commented Oct 4, 2022

Getting into this state requires some tricky timing that I wasn't able to hit naturally on my machine. Probably the best way is just debugging js-debug

  1. Clone js-debug, npm install, npm run watch in a terminal
  2. Run the "extension" launch config
  3. Set a breakpoint here: https://github.com/microsoft/vscode-js-debug/blob/d5770afd4a0e7648f4363854d09a845b96bce98a/src/cdp/webSocketTransport.ts#L31
  4. Attach to a Node.js process (e.g. run node --inspect in the terminal, and use the "Attach to Node Process") command
  5. Once that breakpoint is hit, kill the node process in the terminal
  6. Continue
  7. This loop should now be spinning (you can set a bp or logpoint to verify)
  8. Stop the attach debug config ⏹️
  9. Verify that the retry loop has also now topped

@rzhao271 rzhao271 added verified Verification succeeded and removed author-verification-requested Issues potentially verifiable by issue author labels Oct 6, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Oct 14, 2022
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 debug Debug viewlet, configurations, breakpoints, adapter issues verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants