Closed cipherstream closed 5 years ago
Requested Attachment: salesforce.salesforcedx-vscode-core-unresponsive.cpuprofile.txt
@cipherstream Can you share more information on what operation you were performing when you observe the high cpu load? Is it during loading a new project or editing a file or applying a refactoring? Does the cpu load come down after sometime or does it just continue to stay high?
It is possible that the Apex LSP which is a Java process might be the source of high CPU. In that case, can you also share a thread dump that would help us identify the problem. You can use jstack to collect this information. Here is some info on taking thread dumps:
https://blog.fastthread.io/2016/06/06/how-to-take-thread-dumps-7-options/
I've updated the extension to the latest version (45.3.0), but still have the same problem I posted about in issue #968.
Nothing in particular, just normal editing, syntax highlighting, autocomplete, references and definitions, etc..
CPU usage ~300%.
Below is the cpuprofile and thread dump of the Java process that causes extreme CPU usage when editing a .cls file:
This might not be related to the above example, but might also be helpful. Upon starting VS Code, while "Scanning user-defined types", there seems to be a spike in the CPU usage, but then falls back down when the scanning ends. Below is a gif of the ALS output & CPU usage and the cpuprofile:
VS Code Version: Version 1.31.1 (1.31.1) SFDX CLI Version: sfdx-cli/6.54.4-c01dcc69db (darwin-x64) node-v8.9.4 OS and version: macOs Mojave Version 10.14.3
@nkadis Thank you for uploading the thread dump. Apex LSP does some work in the background to process the edits that you are making to a doc that would result in a CPU spike which is expected. Do you see the CPU spike and then fall down a few seconds after your edit is complete? One of the issues we were seeing previously was that the CPU spikes and stays high for much longer (more than a couple of minutes) on an edit and the fix we released recently addressed that. Note that we are also continuing to make some tweaks to handling edits more efficiently so you should continue to see some improvements in the coming few weeks.
The spike in CPU usage when starting VS Code is also expected since we start off by compiling and indexing all the classes and triggers. CPU usage should fall once the scanning/indexing is complete though.
@praksb Thank you for the quick reply and detailed explanation.
Regarding your comment:
Do you see the CPU spike and then fall down a few seconds after your edit is complete?
Unfortunately, the CPU spike doesn't fall while I'm editing. From what I've experienced, and based off of your reply, I can say that once I start making a few consecutive edits I get errors about unmatched cancel notifications like the one below, and the CPU usage cranks up to spikes between ~120% and ~300%. I haven't tried leaving it do its thing to see if it actually stops because the laptop heats up really fast to the point where you could cook an egg where the CPU is.
org.eclipse.lsp4j.jsonrpc.RemoteEndpoint handleCancellation WARNING: Unmatched cancel notification for request id 636
the CPU spikes and stays high for much longer (more than a couple of minutes) on an edit and the fix we released recently addressed that
It does still stay high for more than a couple of minutes. I would say I've left it spiked for ~10 mins with no signs of going down.
Note that we are also continuing to make some tweaks to handling edits more efficiently so you should continue to see some improvements in the coming few weeks.
Thank you so much, I'll keep an eye out for any changes. Will these tweaks come as an update to the extension?
CPU usage should fall once the scanning/indexing is complete though.
On startup, CPU usage does indeed fall after those tasks are complete.
Thanks again for the help. If you need any other information, I'll be glad to provide it asap.
@nkadis We are actively working on performance improvements to the editing experience. The changes I mentioned will come as incremental updates to the extension. I'll update this thread when the next change is released.
Having the same issue
@cipherstream @nkadis @paul-drozd-itechart We just released our latest Apex extension update which has fixes to improve the performance of Apex editing experience. Please upgrade to v45.5.0 and let us know if you still run into any issues.
Performance
salesforcedx-vscode-core
45.3.0
Windows_NT x64 10.0.17763
1.31.1
:warning: Make sure to attach this file from your home-directory:
C:\Users\chadh\salesforce.salesforcedx-vscode-core-unresponsive.cpuprofile.txt
:warning:Find more details here: https://github.com/Microsoft/vscode/wiki/Explain:-extension-causes-high-cpu-load