Skip to content

100% CPU usage with AlternateNumberFormat plugin #2490

Closed
@Philonous

Description

@Philonous

After upgrading haskell-language-server to b7949aa I noticed that it used 100% CPU while staying otherwise responsive. I found this in the logs

2021-12-14 13:33:11.542240523 [ThreadId 8807] INFO hls:	finish: AlternateNumberFormat.CollectLiterals (took 1m32s)
2021-12-14 13:33:11.542255151 [ThreadId 975] DEBUG hls:	"Literals: [IntLiteral SrcSpanOneLine \"/home/phil/projects/nejla/app/backend/src/Handlers/Job.hs\" 173 27 34 \"1000000\" 1000000,IntLiteral SrcSpanOneLine \"/home/phil/projects/nejla/app/backend/src/Handlers/Job.hs\" 259 13 14 \"0\" 0,IntLiteral SrcSpanOneLine \"/home/phil/projects/nejla/app/backend/src/Handlers/Job.hs\" 260 55 56 \"1\" 1]"
  • The mentioned line is just a 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.
  • It's a 350 line module in a medium-sized project (14kloc)
  • Light use of Template Haskell and QuasiQuotes (some $logDebugs and quotes for string interpolation)
  • No NumericalUnderscores

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 your logs here>

Paste the logs from the lsp-client, you can check instructions about for VS Code here

LSP logs:
<paste your logs here>

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: hls-alternate-number-format-pluginperformanceIssues about memory consumption, responsiveness, etc.type: bugSomething isn't right: doesn't work as intended, documentation is missing/outdated, etc..

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions