Skip to content

Speed up ESLint #16962

@mdjermanovic

Description

@mdjermanovic

This is an issue to define tasks to improve ESLint performance per the recommendations from the "Speeding up the JavaScript ecosystem - eslint" blog post:

https://marvinh.dev/blog/speeding-up-javascript-ecosystem-part-3/

I was able to extract five recommendations from the blog post that relate to eslint core or eslint dependencies. Please add more if I missed something.

  1. Token store's utils.search should use a binary search algorithm.

    We could implement our own, or find a library. In fact, this used to be a binary search before Chore: Remove lodash #14287. The performance impact of switching to Array#findIndex was discussed in Chore: Remove lodash #14287 (comment), but at the time performance tests did not show significant differences. Regardless, I think we should reintroduce binary search here.

  2. Refactor the code to avoid calling the mentioned utils.search / instantiating BackwardTokenCommentCursor millions of times.

    This suggestion requires further analysis. I'm not sure if the premise that we can avoid this because "we should know exactly where we are" applies here because BackwardTokenCommentCursor is used by methods that take an arbitrary node/token, such as SourceCode#getTokensBefore.

  3. Several points on improving esquery performance.

    This has already been implemented in Optimize hot code paths estools/esquery#134. Our Single File and Multi Files performance tests show ~8% overall performance improvement. 🚀

  4. Fast path for simple selectors ("Bailing out early" section in the blog post).

    The suggestion is to handle the simplest selectors in the form of "NodeType" manually, without using esquery. We could definitely give this a try.

  5. "Rethinking selectors" section in the blog post.

    I'm not sure what is the recommendation here, is it to drop declarative selectors in favor of js functions that would be provided by rules?

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedThere is consensus among the team that this change meets the criteria for inclusionarchived due to ageThis issue has been archived; please open a new issue for any further discussioncoreRelates to ESLint's core APIs and features

    Type

    No type

    Projects

    Status

    Complete

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions