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

[Bug]: Twice as slow when used as ESLint plugin #6999

Open
1 task done
screendriver opened this issue Mar 7, 2025 · 2 comments
Open
1 task done

[Bug]: Twice as slow when used as ESLint plugin #6999

screendriver opened this issue Mar 7, 2025 · 2 comments

Comments

@screendriver
Copy link
Contributor

screendriver commented Mar 7, 2025

Kind of Issue

Runtime - command-line tools

Tool or Library

cspell/eslint-plugin

Version

8.17.5

Supporting Library

Not sure / None

OS

All of them

OS Version

No response

Description

When running cspell as an ESLint plugin it is approximately twice as slow as running it directly from the CLI. Is there any particular reason why and anything we can improve here?

$ time npx cspell "source/**"
$ 4.70s user 0.91s system 70% cpu 7.996 total

compared to

eslint .
Rule                                    | Time (ms) | Relative
:---------------------------------------|----------:|--------:
@cspell/spellchecker                    | 10409.575 |    15.6%

Steps to Reproduce

Expected Behavior

No response

Additional Information

ESLint configuration:

'@cspell/spellchecker': [
    'warn',
    {
        autoFix: false,
        numSuggestions: 3,
        generateSuggestions: true,
        ignoreImports: true,
        ignoreImportProperties: true,
        checkIdentifiers: true,
        checkStrings: true,
        checkStringTemplates: true,
        checkJSXText: true,
        checkComments: true,
        cspell: {
            words: [],
            ignoreWords: [],
            flagWords: [],
            ignoreRegExpList: [],
            includeRegExpList: [],
            allowCompoundWords: true,
            import: [],
            dictionaries: []
        },
        customWordListFile: undefined,
        debugMode: false
   }
]

cspell.json

{
    "words": []
}

cspell.config.yaml

Example Repository

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@Jason3S
Copy link
Collaborator

Jason3S commented Mar 9, 2025

@screendriver,

This is expected. ESLint takes time to parse each file before sending the text to the spell checker.

ESLint expects all plugins to be single threaded. Meaning all file reads and checks happen serially, slowing everything down.

@screendriver
Copy link
Contributor Author

I'm not quite sure if this is really expected. ESLint is parsing the source files just one single time and then executes all plugins and rules on the generated AST. All other rules that I use are super fast and it is only cspell that is super slow. If you look at the flamegraph that I created you can see that cspell's walkTree() and walkNodes() is taking the most time over everything else. It is taking so much time that you barely can see all other ESLint plugins:

Image

Also the ESLint builtin profile rule performance check shows this:

Rule                                    | Time (ms) | Relative
:---------------------------------------|----------:|--------:
@cspell/spellchecker                    | 10412.607 |    15.7%
@typescript-eslint/no-unsafe-assignment |  7781.353 |    11.7%
@typescript-eslint/no-misused-promises  |  7059.576 |    10.6%
import/no-cycle                         |  6323.470 |     9.5%
prettier/prettier                       |  4912.290 |     7.4%
@typescript-eslint/no-floating-promises |  4550.338 |     6.9%
import/no-deprecated                    |  4532.762 |     6.8%
@typescript-eslint/no-unsafe-return     |  1984.953 |     3.0%
node/no-restricted-import               |  1482.559 |     2.2%
import/extensions                       |  1313.177 |     2.0%

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

No branches or pull requests

2 participants