-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
Performance: long print time in stylish formatter's text-table for long report strings #18709
Comments
I'd be in favor of extracting the relevant logic directly into the |
Got something in the works to resolve this issue, @nzakas could you assign this one to me? |
GitHub makes it hard to assign issues to external contributors. I'll assign to myself to hold the issue but let you send a PR @jonkoops. All you! 🙂 |
@jonkoops assigned. @JoshuaKGoldberg as long as someone has commented on the issue, you can assign it to them. :) |
Closes eslint#18709 Signed-off-by: Jon Koops <[email protected]>
Closes eslint#18709 Signed-off-by: Jon Koops <[email protected]>
When running
npx eslint
on a repository with many errors containing long descriptions and rule names, the stylish formatter can take a surprisingly long time to print results. @johnsoncodehk and I discovered this on https://github.com/johnsoncodehk/core/tree/d47d660758485c04dc26948b6ee9a42ac51a50df: more than half the command's time is spent inprintResults
!The problem is a very slow
/\s+$/
regex insidetext-table
on line 53. That regex is meant to remove all trailing whitespace in the string... which is now whatString.prototype.trimEnd
does.The following fix inside
text-table
reduces the stylish formatter's runtime to near-zero:Single example
time node node_modules/eslint/bin/eslint.js
measurements on my M1 Max Mac Studio, with screenshots of the equivalent attachednode --cpu-prof
traces:time
17.35s
8.70s
Here is one of the strings being trimmed...
' 972 5 \x1B[33mwarning\x1B[39m Unexpected nullable string value in conditional. Please handle the nullish/empty cases explicitly \x1B[2m@typescript-eslint/strict-boolean-expressions\x1B[22m '
The stylish formatter calls to
text-table
here:eslint/lib/cli-engine/formatters/stylish.js
Line 52 in aab1b84
Coincidentally, #18618 was filed last month to suggest replacing the not-updated-for-11-years
text-table
dependency. It was closed for lack of motivation. @jonkoops, I imagine this issue might help you feel vindicated a bit? 😄I went ahead and published a
text-table-fast
package that has roughly the same API astext-table
, but without the quadratic regular expression or support for the'.'
alignment (which ESLint doesn't use).Alternately, per #18618 (comment), maybe it'd make sense to extract the useful bits of
text-table
into stylish itself, and get rid of some overhead?Co-authored-by: @johnsoncodehk
The text was updated successfully, but these errors were encountered: