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

nimsuggest devours CPU usage #11679

Open
s0kil opened this issue Jul 7, 2019 · 14 comments
Open

nimsuggest devours CPU usage #11679

s0kil opened this issue Jul 7, 2019 · 14 comments

Comments

@s0kil
Copy link

s0kil commented Jul 7, 2019

nimsuggest is consuming too much of CPU, fans have not stopped since I installed it via choosenim. In fact it uses more CPU than any other process.
Screenshot from 2019-07-06 21-03-42

Nim Compiler Version 0.20.0 [Linux: amd64]
Compiled at 2019-06-06
Copyright (c) 2006-2019 by Andreas Rumpf

git hash: e7471cebae2a404f3e4239f199f5a0c422484aac
active boot switches: -d:release
@dom96
Copy link
Contributor

dom96 commented Jul 7, 2019

Are you using VS Code? If so that's the fault of the VS code Nim extension. It spawns Nimsuggest far too aggressively.

@sinkingsugar
Copy link
Contributor

I don't think VS Code has anything to do, I mean it might be aggressive but here we are talking of full CPU spinning.. there has to be something wrong.

@mratsim
Copy link
Collaborator

mratsim commented Jul 7, 2019

There are multiple issues with nimsuggest.

  1. Like OP said, in some cases, nimsuggest just keep spinning, and eat all CPU and need to be killall regularly. I've noticed it happened often while I'm in a middle of a macro. Worse, on Windows that will lock the file and causes issues with git.

  2. Like dom96 the VScode Nim extension is very aggressive because it spawns one nimsuggest per file instead of per module which means that combined with 1 multiple instances of nimsuggest can be stuck at 100%

@cooldome
Copy link
Member

cooldome commented Jul 7, 2019

The only way to make nimsuggest work for me in the large project is to spawn nimsuggest as aggressively as possible and then kill it every 3 minutes. Only them I can get any suggestions out of nimsuggest.
Nowadays, VSCode nim plugin comes with useful setting: nimssugestResetTimeout.

Patterns when nimsuggest eats up a lot of memory or CPU time when left alive for sometime I have seen countless times.

@dom96
Copy link
Contributor

dom96 commented Jul 8, 2019

Just to be clear: I'm not excusing nimsuggest here. But the way the VS Code extension launches nimsuggest is incredibly infuriating.

We should move to a Language Server that can manage nimsuggest instances in a sane manner.

@sinkingsugar
Copy link
Contributor

btw for some reason it's not happening anymore lately!
(I pull devel quite often.)

@moigagoo
Copy link
Contributor

moigagoo commented Aug 5, 2019

JFYI setting nim.project in the workspace config helps:

{
  "nim.project": [
    "src/norm.nim"
  ]
}

@anurbol
Copy link

anurbol commented Aug 23, 2019

Hi, nimsuggest (spawned by vscode-nim) just ate 4 GB of RAM on my Windows 7 and constantly uses 100% of one of the cores. So is there some memory leak, that should be fixed?

@mratsim
Copy link
Collaborator

mratsim commented Aug 24, 2019

@sinkingsugar might be related to #11849. That caused infinite loop in macros.

@anurbol, it's probably not a memory leak as CPU usage is high as well, probably loop that keeps burning CPUs and allocating, in a similar vein to #11849. Anyway that's what this issue is tracking.

@s0kil
Copy link
Author

s0kil commented Nov 19, 2019

This issue still persists, I have noticed when working with HTTP server, if there is an issue in the code the nimsuggest process responsible for that file won't get killed even after the code has been fixed, I end up killing it manually.

@mratsim
Copy link
Collaborator

mratsim commented Nov 21, 2019

Yes, I have it quite often as well, and I'm not working with macros or a heavy generics codebase.

@shirleyquirk
Copy link
Contributor

nimsuggest uses 100% cpu for me very regularly. here's one way to replicate:

proc bar(k:static bool):SomeNumber = (when k: 3, else: 3.0)

running nim check on that file also causes an infinite loop, printing:
Error: expression expected, but found ','

i thought nim check was supposed to give up after some number of errors, no?

@arthurrasmusson
Copy link

I am also experiencing this issue in VSCode on MacOS. I believe I am on the latest version of the VSCode Nim plugin, VSCodium (open source vscode), and Nim.

@omentic
Copy link
Contributor

omentic commented May 14, 2022

I also see the nimsuggest and nim check processes eating up 100% of my CPU.

2022-05-14-152820

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests