vscode icon indicating copy to clipboard operation
vscode copied to clipboard

High CPU usage while typing (plain text)

Open ogmios-voice opened this issue 3 years ago • 20 comments

Issue Type: Performance Issue

Quick typing causes noticeable high CPU usage even in case of plain text w/o any extension. The larger the file the more visible, but it's already happens w/ an empty file.

Steps:

  1. create a new plain text document w/ e.g. 50k lines of: The quick brown fox jumps over the lazy dog.
  2. in a new line press and keep pressing any letter (= simulate quick typing)
  3. in a few seconds CPU usage will jump up (regardless of the word wrap setting)

VS Code version: Code - Insiders 1.65.0-insider (bb221a61d29deabd99ee9431736d04f2175cb596, 2022-02-11T05:19:13.554Z) OS version: Windows_NT x64 10.0.19043 Restricted Mode: No

System Info
Item Value
CPUs Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz (8 x 2600)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) undefined
Screen Reader no
VM 0%
Process Info
CPU %	Mem MB	   PID	Process
    0	   106	 16392	code-insiders main
    0	    43	  7540	   utility-network-service
    0	   129	 13004	   gpu-process
    0	   236	 13188	   extensionHost
    0	    80	  7032	     "R:\VSCode-win32-x64-1.65.0-insider\Code - Insiders.exe" --ms-enable-electron-run-as-node r:\VSCode-win32-x64-1.65.0-insider\resources\app\extensions\css-language-features\server\dist\node\cssServerMain --node-ipc --clientProcessId=13188
    0	    25	 13464	   crashpad-handler
    0	   353	 13864	   window (a.txt - Visual Studio Code - Insiders)
    1	    85	 18828	   issue-reporter
    0	   100	 21816	   shared-process
    0	    74	 14764	     ptyHost
    0	    74	 18348	     fileWatcher
Workspace Info
;
Extensions: none
A/B Experiments
vsliv695:30137379
vsins829:30139715
vsliv368cf:30146710
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
pythonvspyl392:30422396
pythontb:30258533
pythonvspyt551cf:30291413
pythonptprofiler:30281269
vshan820:30294714
pythondataviewer:30285072
vscod805:30301674
pythonvspyt200:30323110
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
pythonvs932:30404738
wslgetstartedc:30421358
vsclayoutctrt:30405800
dsvsc009:30436273
pythonvsnew555cf:30426299
vsbas813:30436447
vscscmwlcmc:30428972
azactmsalcf:30432849
vscgsvid1:30433757

ogmios-voice avatar Feb 12 '22 05:02 ogmios-voice

@ogmios-voice I've done a CPU profile while keeping Enter pressed but I could not spot anything problematic. A typical handling of a keypress takes <2ms and rendering also takes 5-6ms which looks normal:

image

Could you please try to create a CPU profile and share it here?

alexdima avatar Feb 22 '22 20:02 alexdima

Could you please retry while keeping e.g. a pressed? (This was my original test, and I also think Enter would trigger some other behaviour.) If it is still not visible, I'll create a CPU profile.

ogmios-voice avatar Feb 23 '22 03:02 ogmios-voice

I see this as well. I disabled all extensions and restarted vscode but the same behaviour remains. It's not just adding characters either, deleting text 1 character at a time causes the same issue.

VSCode info

Item Value
Version 1.64.2 (user setup)
Commit f80445acd5a3dadef24aa209168452a3d97cc326
Date 2022-02-09T22:02:28.252Z
Electron 13.5.2
Chromium 91.0.4472.164
Node.js 14.16.0
V8 9.1.269.39-electron.0
OS Windows_NT x64 10.0.19043

I'm on AMD (Ryzen 9 5950X 16-Core Processor @ 3.40 GHz) and typing causes heavy usage across a number of cores. So much so that the system fans all spin up and the cpu temp spikes from 40 to 70 degrees C.

In this image I started typing at the green line and stopped at the blue line: image

Russ-K avatar Feb 23 '22 08:02 Russ-K

@ogmios-voice @Russ-K Can you please attach CPU profiles? I am happy to take a look and see if there's something we can improve.

alexdima avatar Feb 23 '22 14:02 alexdima

@alexdima CPU profile attached...

CPU-20220224T085833.885Z.cpuprofile.txt

Thanks for looking into it

Russ-K avatar Feb 24 '22 09:02 Russ-K

It also seems to happen when switching between different files in the same project.

CPU profile for switching files attached...

CPU-20220225T085055.345Z.cpuprofile.txt

Russ-K avatar Feb 25 '22 08:02 Russ-K

Hey @alexdima, this issue might need further attention.

@ogmios-voice, you can help us out by closing this issue if the problem no longer exists, or adding more information.

vscodenpa avatar May 16 '22 11:05 vscodenpa

I can confirm this is still an issue.

VSCode info

Item Value
Version 1.67.1 (user setup)
Commit da15b6fd3ef856477bf6f4fb29ba1b7af717770d
Date 2022-05-06T12:37:03.389Z
Electron 17.4.1
Chromium 98.0.4758.141
Node.js 16.13.0
V8 9.8.177.13-electron.0
OS Windows_NT x64 10.0.19043

Russ-K avatar May 16 '22 12:05 Russ-K

Also having the same issue, but on Linux. Didn't manage to get the CPU Profile report.

Version: 1.67.1 Commit: da15b6fd3ef856477bf6f4fb29ba1b7af717770d Date: 2022-05-06T12:39:22.915Z Electron: 17.4.1 Chromium: 98.0.4758.141 Node.js: 16.13.0 V8: 9.8.177.13-electron.0 OS: Linux x64 5.11.0-49-generic

System Info

  • Code: 1.67.1 (da15b6fd3ef856477bf6f4fb29ba1b7af717770d)
  • OS: linux(5.11.0-49-generic)
  • CPUs: Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz(8 x 3499)
  • Memory(System): 19.34 GB(11.96GB free)
  • Memory(Process): 286.16 MB working set(158.02MB private, 26.62MB shared)
  • VM(likelihood): 0%
  • Initial Startup: true
  • Has 0 other windows
  • Screen Reader Active: false
  • Empty Workspace: false

Note: I dual boot win11 and Ubuntu, this only happens in the ubuntu version, same version of vs code runs smoothly on windows.

Kayo-b avatar May 17 '22 22:05 Kayo-b

UPDATE: Issue has been solved after VS Code updated to version 1.67.2

Kayo-b avatar May 19 '22 16:05 Kayo-b

On windows it is still present in v1.67.2. The CPU usage increase is visible also in the Performance monitor of Developer Tools. But I can also see in Task Manager / Process Explorer most likely another Code.exe thread running at 90-100%... Is there a way to monitor all the threads from VSCode?

ogmios-voice avatar May 21 '22 02:05 ogmios-voice

same here

nezzzumi avatar May 21 '22 21:05 nezzzumi

same

Russ-K avatar May 21 '22 23:05 Russ-K

I opened the vscode process manager and found that the problem was eslint.

nezzzumi avatar May 22 '22 01:05 nezzzumi

Hey @alexdima, this issue might need further attention.

@ogmios-voice, you can help us out by closing this issue if the problem no longer exists, or adding more information.

vscodenpa avatar Aug 25 '22 11:08 vscodenpa

This no longer appears to be an issue on the latest version. This is with various extensions enabled as well (ESLint, Prettier, GitLens, indent-rainbow)

VSCode info

Item Value
Version 1.70.2 (user setup)
Commit e4503b30fc78200f846c62cf8091b76ff5547662
Date 2022-08-16T05:35:13.448Z
Electron 18.3.5
Chromium 100.0.4896.160
Node.js 16.13.2
V8 10.0.139.17-electron.0
OS Windows_NT x64 10.0.19043

Russ-K avatar Aug 26 '22 08:08 Russ-K

I do have some extensions running but I have this exact problem. I'm version 1.73.1 (Mac - Monterey v12.6). Minimal CPU usage on idle, but as soon as I start typing, it goes up to 90%+ and vscode becomes laggy.

seunggs avatar Nov 11 '22 20:11 seunggs

@Russ-K I think things have improved here due to an Electron update, perhaps with the Electron 18 update from June, because the CPU profiles you attached did not contain a lot of time spent in JS, but contained time spent in "(program)" which might indicate time spent in the native part of the renderer process.

@seunggs Could you please create a separate issue? I think this might have been a problem specific to Electron on Windows.

@ogmios-voice Are you still experiencing this issue? Can you please attach a CPU profile?

alexdima avatar Dec 08 '22 11:12 alexdima

@alexdima - I'm not on Windows. I was on Mac - Monterey v12.6 but now I'm on Ventura v13.0.1 and still observing the same behavior. I think my issue is related to typescript.

seunggs avatar Dec 08 '22 14:12 seunggs

@seunggs Yes, it would be best to create a separate issue. Then, I can guide you through troubleshooting steps. Thanks!

alexdima avatar Dec 08 '22 14:12 alexdima

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 avatar Dec 16 '22 11:12 vscodenpa