question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

UnusedPatternVariable diagnostic is very slow on big files

See original GitHub issue

Continuation from #484.

When my project contains files like this (Utilities.elm) it makes my fans spin indefinitely, because a process running elm-language-client-vscode/server/out/index.js runs 100% on one core.

I’m running the elm-language-client-vscode master (https://github.com/elm-tooling/elm-language-client-vscode/commit/7532d7fc0caf9a6590b15f817272337f09bc0704).

I’ve checked that tree-sitter-elm can parse this file and it’s just fine.

Turning off the ElmLS Diagnostics setting fixes the problem (but is unfortunate, obviously).

I have created a .cpuprofile, but I doubt it’s helpful. I think when I’m profiling a language server extension, I basically only profile the client part, but not the server part. This results in a profile that contains only native code, as 99% of the time its waiting for messages on sockets (this is my hypothesis). If you know any other way to profile this, I’d be happy to try it.

I would love input in how to further test this issue. Can anyone else reproduce this issue? Maybe it’s related to file size (and it’s just running reeeeally long), as the file is almost 33kLOC, but it has never run to completion, even after hours. This is incorrect! It finishes after ~10 minutes. It seems I got the impression it never finishes, because the process gets restarted once I save any other Elm file?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
jmbockhorstcommented, Feb 5, 2021

Yeah, there’s just not a fast way of doing it like this. I was thinking about switching unused diagnostics into the type checker, which would use references from type inference to determine what is unused.

1reaction
matheus23commented, Feb 5, 2021

Ok. I’ve done some delta debugging.

I’ve enabled the ElmLS Diagnostics again, and systematically turned settings in elm-analyse.json on and off.

With these settings, there’s no issue:

{
    "checks": {
        "BooleanCase": true,
        "DropConcatOfLists": true,
        "DropConsOfItemAndList": true,
        "NoUncurriedPrefix": true,
        "MapNothingToNothing": true,
        "SingleFieldRecord": true,
        "UnnecessaryListConcat": true,
        "UnnecessaryPortModule": true,
        "UnusedImport": true,
        "UnusedImportAlias": true,
        "UnusedImportedVariable": true,
        "UnusedPatternVariable": false,
        "UnusedTopLevel": true,
        "UnusedTypeAlias": true,
        "UnusedValueConstructor": true,
        "UnusedVariable": true,
        "UseConsOverConcat": true
    }
}

However, these settings do make my fans spin for >2 minutes (at least. I interrupted it):

{
    "checks": {
        "BooleanCase": false,
        "DropConcatOfLists": false,
        "DropConsOfItemAndList": false,
        "NoUncurriedPrefix": false,
        "MapNothingToNothing": false,
        "SingleFieldRecord": false,
        "UnnecessaryListConcat": false,
        "UnnecessaryPortModule": false,
        "UnusedImport": false,
        "UnusedImportAlias": false,
        "UnusedImportedVariable": false,
        "UnusedPatternVariable": true,
        "UnusedTopLevel": false,
        "UnusedTypeAlias": false,
        "UnusedValueConstructor": false,
        "UnusedVariable": false,
        "UseConsOverConcat": false
    }
}

So it seems like UnusedPatternVariable is the culprit.

Read more comments on GitHub >

github_iconTop Results From Across the Web

reportUnusedVariable ignore pattern · Issue #1118 - GitHub
But at present, it appears that reportUnusedVariable can only be toggled entirely on or off.
Read more >
Stata I/O with very large files
In our case, this is a huge difference. The workaround is to split the -using- file into pieces, merge them individually, save and...
Read more >
Warning Options (Using the GNU Compiler Collection (GCC))
Warnings are diagnostic messages that report constructions that are not inherently erroneous but that are risky or suggest there may have been an...
Read more >
NoUnused.Patterns - elm-review-unused 1.1.29
This rule looks within let..in blocks and case branches to find any patterns that are unused. It will report any useless patterns as...
Read more >
The Best and Worst GCC Compiler Flags For Embedded
GCC and Clang have several warning flags which will enable a collection of ... of the variable are being operated on within each...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found