-
-
Notifications
You must be signed in to change notification settings - Fork 372
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
100% CPU usage with AlternateNumberFormat plugin #2490
Comments
Does the CPU abuse go away if you disable the plugin? |
I wanted to try that but I couldn't find a way to accomplish it; apparently the only way to disable plugins is by changing a setting in the client. However, emac's |
@Philonous You can disable the plugin somewhat manually as in this issue or this PR. You need to change |
Many thanks for the report, would be good to fix it before release the plugin (if we confirmed the plugin is the responsible) // @drsooch |
This is new for me. The Created a new file and was greeted with this: EDIT: I'd for now assume it's the plugin. I'm in the process of trying to track down any delta. If I had to guess the In the meantime, @Philonous, do you see something similar happening for |
So taking a look, it seems as though it is related to the @fendor I'm not sure how well versed you are with SYB, but if you know of any tricks to possibly speed this up. That would be great. I was unable to replicate the 100% cpu usage for hours at a time, I imagine if I was coding full time maybe I'd experience it but, wasn't able to duplicate. |
The Tactics plugin also uses SYB, even HLS itself uses SYB for various things, so I'm not convinced this is the problem.
|
Thanks for looking into this! |
In the commit I referenced, it is technically half-working. That SYB parser only captures a small portion of Literals. I still am not sure why it does that, but I updated it to look for more patterns and that seemed to do the trick (at the cost of performance). collectLiterals' :: (Data ast, Typeable ast) => ast -> Set Literal
collectLiterals' = everything (<>) (mkQ2 (S.empty :: Set Literal) traverseLExpr traverseLPat)
-- Located Patterns for whatever reason don't get picked up when using `(mkQ (S.empty :: Set Literal) traverseLExpr)
-- as such we need to explicit traverse those in order to pull out any literals
mkQ2 :: (Typeable a, Typeable b, Typeable c) => r -> (b -> r) -> (c -> r) -> a -> r
mkQ2 def left right datum = case cast datum of
Just datum' -> left datum'
Nothing -> maybe def right (cast datum) You'll notice the use of a Set as with the addition of the second pattern duplicates began showing up (a lot of duplicates) I should've realized that would case a performance drop... I feel silly for not really noticing it earlier. |
After upgrading haskell-language-server to b7949aa I noticed that it used 100% CPU while staying otherwise responsive. I found this in the logs
threadDelay 1000000
and haskell-language-server seems to produce one of these log lines every few minutes for a different literal in my code base.$logDebug
s and quotes for string interpolation)Unfortunately I can't link the code since it's proprietary.
Your environment
Which OS do you use:
NixOS
Which lsp-client do you use:
emacs with lsp-mode
Describe your project (alternative: link to the project):
stack.yaml
Steps to reproduce
Run haskell-language-server on my project as normal
Expected behaviour
0% CPU usage after initial setup
Actual behaviour
100% CPU usage permanently (or at least multiple hours)
Include debug information
I don't have access to the machine right now but I'll reproduce them if required.
Execute in the root of your project the command
haskell-language-server-wrapper --debug .
and paste the logs here:(if you are using the vscode extension check the executable location here)
Debug output:
Paste the logs from the lsp-client, you can check instructions about for VS Code here
LSP logs:
The text was updated successfully, but these errors were encountered: