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

Very slow performance #445

Closed
NullVoxPopuli opened this issue Nov 11, 2021 · 8 comments
Closed

Very slow performance #445

NullVoxPopuli opened this issue Nov 11, 2021 · 8 comments

Comments

@NullVoxPopuli
Copy link

This issue is the successor to: #304
which was closed after #368.
But I don't think that's enough.

What version of eslint are you using?

❯ yarn eslint -v
v7.32.0

What version of prettier are you using?

❯ yarn list prettier
└─ prettier@2.4.1

What version of eslint-plugin-prettier are you using?

❯ yarn list eslint-plugin-prettier
└─ eslint-plugin-prettier@3.4.1

Please paste any applicable config files that you're using (e.g. .prettierrc or .eslintrc files)
n/a
( there also isn't a reasonable way to paste this here, cause I given up on simple lint configs, and gone with an overrides only approach: https://github.com/NullVoxPopuli/eslint-configs )

I don't have or use a .prettierrc, but have defined the following (in a local project) with the following config:

'prettier/prettier': [
        'error',
        {
          arrowParens: 'always',
          printWidth: 100,
          singleQuote: true,
          trailingComma: 'all',
        },
      ],

What source code are you linting?
Combination of JS, TS, and JSON, but only JS and TS have eslint-plugin-prettier enabled.

What did you expect to happen?

Not have > 20% of time spent on one plugin

What actually happened?

Rule                                                                  | Time (ms) | Relative
:---------------------------------------------------------------------|----------:|--------:
prettier/prettier                                                     | 22398.901 |    85.9%
no-redeclare                                                          |   276.436 |     1.1%
padding-line-between-statements                                       |   242.521 |     0.9%
ember/no-assignment-of-untracked-properties-used-in-tracking-contexts |   178.402 |     0.7%
@typescript-eslint/no-unused-vars                                     |   166.158 |     0.6%
no-unused-vars                                                        |   165.051 |     0.6%
ember/require-computed-property-dependencies                          |   159.632 |     0.6%
ember/no-actions-hash                                                 |   145.305 |     0.6%
ember/no-get                                                          |   129.990 |     0.5%
ember/no-on-calls-in-components                                       |    94.890 |     0.4%
@BPScott
Copy link
Member

BPScott commented Nov 11, 2021

Do you have any stats about how long prettier takes to run over all the files that you lint without going through the eslint bridge.

It is not currently clear if this speed is due to this plugin doing something wrong or because prettier just takes that long.

There's a very real chance that's just how long prettier takes to run over your files, which this bridge can do nothing about.

@NullVoxPopuli
Copy link
Author

yeah, prettier itself takes 15s on the same set of files.

I recently discovered https://github.com/XAMPPRocky/tokei
which is orthogonal to all of this. but it runs on many many many many more files, in < 3s.

So... I fear that the answer may be for prettier and eslint to start migrating to rust (or some other system language)

@lydell
Copy link
Member

lydell commented Dec 9, 2021

If you’re looking for a code formatter written in Rust that supports JS/TS, check out https://github.com/dprint/dprint

@haixiangyan
Copy link

haixiangyan commented Jan 15, 2022

ref: #304 (comment)

This said when using eslint to format codes with prettier, it's slow.

I come up with an idea:

{
  '**/*.{ts,tsx}': [
    (filenames) => {
      const files = [...filenames, ...declarationFiles];
      return `tsc ${files.join(' ')} --noEmit --skipLibCheck`;
    }, // typescript type checking
    "prettier --write", // use prettier to format your code
    `eslint --cache --fix --rule 'prettier/prettier: off'`, // turn off the prettier/prettier rule, make it faster
  ],
}

Not sure if this is the best one, but I think should make it faster. 🥸

@JounQin
Copy link
Member

JounQin commented Jun 27, 2022

Can you help to try latest v4.1.0?

@JounQin
Copy link
Member

JounQin commented Jun 30, 2022

This could be related to that we are running prettier.resolveConfig.sync and prettier.getFileInfo.sync for every file, I'll try to find a better solution for this case, for example cache support at least.

@JounQin
Copy link
Member

JounQin commented Jun 30, 2022

@fisker @sosukesuzuki

Do you think we can benefit from the new prettier's cache? I didn't find any cache content in node_modules/.cache/prettier.

@JounQin
Copy link
Member

JounQin commented Jun 30, 2022

close in favor of #485

@JounQin JounQin closed this as completed Jun 30, 2022
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

6 participants
@NullVoxPopuli @BPScott @lydell @JounQin @haixiangyan and others