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

Use of CPU recently became too high #431

Closed
memeplex opened this issue Feb 16, 2020 · 15 comments
Closed

Use of CPU recently became too high #431

memeplex opened this issue Feb 16, 2020 · 15 comments
Labels

Comments

@memeplex
Copy link

As soon as I turn on spell checking for a workspace my laptop gets hot and my battery starts to drain.

Both my system process exporer and vscode process explorer show this extension process permanently using a high percentage of CPU:

image

At this point I only have one moderately sized python file open in my editor. Even if I turn off spell checking, CPU usage stays high until I kill the offending process.

extension version

1.7.23

vscode version

Version: 1.42.1
Commit: c47d83b293181d9be64f27ff093689e8e7aed054
Date: 2020-02-11T14:50:36.977Z
Electron: 6.1.6
Chrome: 76.0.3809.146
Node.js: 12.4.0
V8: 7.6.303.31-electron.0
OS: Linux x64 5.3.0-29-generic

@Jason3S
Copy link
Collaborator

Jason3S commented Feb 16, 2020

@memeplex Thank you.

Below is the comment I left in #393 . The behavior seems to most like #1. You might need to quit all copies of VS Code and kill any Code Helper processes. Just restarting VS Code won't make them go away.

@memeplex I would like to find out the issue.
In regular usage, this does not happen.

Common causes:

  1. Incomplete install / update - this occasionally happens when VS Code installs / updates the extension. For some reason, it does not manage to download the entire extension and VS Code goes into a infinite loop trying to load the extension. The fix in this case is to uninstall the extension and to erase the cached copy from VS Code before reinstalling it.
  2. A runaway regex in the include / ignore section see Runaway Regular Expressions: Catastrophic Backtracking
  3. A very large file
  4. Something else - this is where I need your help.
  • Can you include a copy of your cspell.json file or the cSpell.* sections of the VS Code settings.json file.
  • Please let me know the programming language and approximate size of the file.
  • What OS are you using?
  • Please include a copy of the VS Code About dialog.
  • If you happen to have a public repository that exhibits this behavior, please send me a link.

@Jason3S
Copy link
Collaborator

Jason3S commented Feb 16, 2020

See also:
#388
#278

@memeplex
Copy link
Author

memeplex commented Feb 16, 2020

I've killed all code processes and restarted vscode many times. After a time of using cspell the problem always reoccurs.

I've also reinstalled the extension to no avail.

I'm testing this with a python file < 1000 LOCs.

OS is Ubuntu 19.10.

vscode about:

Version: 1.42.1
Commit: c47d83b293181d9be64f27ff093689e8e7aed054
Date: 2020-02-11T14:50:36.977Z
Electron: 6.1.6
Chrome: 76.0.3809.146
Node.js: 12.4.0
V8: 7.6.303.31-electron.0
OS: Linux x64 5.3.0-29-generic

User level cspell configuration:

    "cSpell.languageSettings": [
        {
            "languageId": "*",
            "includeRegExpList": [
                "CStyleComment",
                "strings",
                "/#.*/",
            ]
        },
        {
            "languageId": "python",
            "includeRegExpList": [
                "/#.*/",
                "/\"\"\"(.*?\\n?)+?\"\"\"/g",
                "/'''(.*?\\n?)+?'''/g",
                "strings",
            ]
        },
    ],
    "cSpell.ignorePaths": [
        "**/Projects/Venvs/**",
        "**/lib/python*/**"
    ],
    "cSpell.userWords": [
        "noqa",
    ],

Workspace level cspell configuration:

		"cSpell.words": [
			"Bugfixes",
			"Duchi",
			"FTRL",
			"GLMs",
			"Gloval",
			"MAPE",
			"Mahan",
			"RMSE",
			"Recurse",
			"Safiro",
			"Vectorize",
			"WAPE",
			"bytea",
			"ctypes",
			"cython",
			"daat",
			"deserialize",
			"dloss",
			"ffit",
			"fmodeler",
			"fstore",
			"hids",
			"ilink",
			"imul",
			"ints",
			"invid",
			"ipow",
			"jsonified",
			"libjampp",
			"linearities",
			"mtable",
			"napps",
			"nobss",
			"nprobes",
			"nrejects",
			"nworkers",
			"psycopg",
			"pyhive",
			"pylint",
			"rkind",
			"sprobes",
			"struct",
			"structs",
			"unsubscriptable",
			"vals",
			"vectorizes"
		],
		"cSpell.enabled": true,

@Jason3S
Copy link
Collaborator

Jason3S commented Feb 16, 2020

It is your regex for detecting python strings. As soon as you try to type in a new """ in the middle of your document, it will go into Catastrophic Backtracking

Try replacing:

"/\"\"\"(.*?\\n?)+?\"\"\"/g",
"/'''(.*?\\n?)+?'''/g",

with

"/('''|\"\"\")[^\\1]+?\\1/g",

See the old one fail here:
https://regex101.com/r/mvIuBw/4

Try out the new one here:
https://regex101.com/r/mvIuBw/3

@memeplex
Copy link
Author

Thank you very much @Jason3S! I took the regex from #107, so you might want to warn there about the consequences.

@Jason3S
Copy link
Collaborator

Jason3S commented Feb 16, 2020

Looks like I wrote the bad expression! Thank you for the heads up!

@memeplex
Copy link
Author

The string "/('''|\"\"\")[^\1]+?\\1/g" is showing an "Invalid escape character in string" error. Could it be that an additional backslash is missing before the first \1?

@Jason3S
Copy link
Collaborator

Jason3S commented Feb 16, 2020

Exactly.

@memeplex
Copy link
Author

At the risk of bothering you too much, could you explain a bit more about the differences between both approaches regarding the problem reported here?

@Jason3S
Copy link
Collaborator

Jason3S commented Feb 16, 2020

@memeplex
Copy link
Author

Ahh ok I see, it's quite clear now. Thank you again!

@kwmlodozeniec
Copy link

I have a similar issue with this extension on macOS. Occasionally, after I quit VS Code, the extension process lingers around and uses a lot of CPU (high 90s). Starting VS Code again does not resolve the issue and the only way is to kill said process using the command line or through system monitor. last time I caught it this is the execution path reported by ps utility.

12:32.19 /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Renderer).app/Contents/MacOS/Code Helper (Renderer) /Users/krzysztof/.vscode/extensions/streetsidesoftware.code-spell-checker-1.7.22/server/server.js --node-ipc --clientProcessId=85640

@Jason3S
Copy link
Collaborator

Jason3S commented Feb 17, 2020

@kwmlodozeniec, please open a new issue.
Then add the same information that memeplex added from your own configuration.
Memeplex's issue was a runaway regex.

@kwmlodozeniec
Copy link

@Jason3S done under #432

@github-actions
Copy link
Contributor

github-actions bot commented Feb 8, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants