Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

⚡️ Performance: Overhead of populateGlobalsFromLib in scope-manager #9575

Copy link
Copy link
@JoshuaKGoldberg

Description

@JoshuaKGoldberg
Issue body actions

Overview

I'm investigating performance traces of typescript-eslint work in preparation for v8 (#9571). You can find some preliminary traces in https://github.com/typescript-eslint/performance/blob/c5e8a725ad5338a3dca5cebcd69f5a802df8c8d6/README.md#tracing-measurements -> https://github.com/typescript-eslint/performance/blob/main/traces/Project%201%20-%20Service%202.cpuprofile.

If you look at the call stack in an example project with a large number of simple files, quite a few of them are spending anywhere from ~0.3ms to ~2ms in populateGlobalsFromLib, sometimes including garbage collection:

Screenshot of a linked stack trace zoomed into several files parseForESLint. Each has a populateGlobalsFromLib taking up most of its call tree.

Most rules don't actually use the scope manager, and sometimes only conditionally. So this function is unnecessary for many projects!

I tried commenting it out and lint times for ~1024 .ts files, even layout, parserOptions.project went from ~3.8s to ~2.8s. That's a great savings!

Even in projects where it is necessary, it seems exceptionally long to spend over a ms on it. I wonder if switching the data structures around to a more performant loop style (e.g. from an object to an array) would be helpful.

Both parserOptions.project and parserOptions.projectService are showing this behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issuelocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.performanceIssues regarding performanceIssues regarding performance

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.