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

Speed up lint-everything #1468

Closed
1 task
samreid opened this issue Sep 20, 2024 · 6 comments
Closed
1 task

Speed up lint-everything #1468

samreid opened this issue Sep 20, 2024 · 6 comments
Assignees

Comments

@samreid
Copy link
Member

samreid commented Sep 20, 2024

lint-everything slowed down in #1356 since (a) project references per-repo adds overhead, and (b) couldn't fit all sims in memory at once. Let's see if we can speed it up again. Parts like #1467 and #1466 may help too.

also:

  • grunt lint-everything --disable-eslint-cache prints "cache file deleted" over and over. Instead, just delete the cache file once, then let everything run.
@samreid samreid self-assigned this Sep 20, 2024
samreid added a commit to phetsims/perennial that referenced this issue Sep 20, 2024
@samreid
Copy link
Member Author

samreid commented Sep 20, 2024

ESLint does not have good support for project references. I tried the proposal in https://github.com/typescript-eslint/typescript-eslint/issues/2094 and https://github.com/typescript-eslint/typescript-eslint/pull/6754 for adding

  parserOptions: {
    EXPERIMENTAL_useProjectService: true,
  },

but I could not get it to work. Running multiple repos with different parserOptions.projects overwhelms the memory and in #1356 I split it up into worker threads, but it takes 5+ minutes even when little has changed.

At the moment, we could specify an eslint-specific tsconfig.json that allows multiple repos to fit in memory and use shared type information. The main problem with this is it would be redundant with our modular project references tsconfigs. Furthermore, when we start specifying different behavior (node vs browser), we would need a way to accommodate that in the eslint-specific tsconfig.

Running grunt lint --disable-eslint-cache in density with the specific tsconfig takes about 4 seconds. With the full one it is about 12 seconds. A cached one with no changes is about the same for each. A project-references one may also be slow. With the way our linting is set up, I don't see a practical way to say "when linting one repo, use the repo-specific tsconfig, when linting more than one repo in the same unit, use the combined config". We could likely make that happen if we used .eslintrc.js files which can dynamically check what's happening. But that is more complex. And we may want to do that after switching to the flat config.

I also experimented with coming up with a config file dynamically that would be for the lint-everything, but paths were messy and difficult to match the rules with the files.

So to speed up lint-everything and lint-all, and to restore prior behavior to lint-everything such as --chip-away and better behavior for disable-eslint-cache, the recommendation for this issue is:

  • revert changes to perennial/Gruntfile/lint-everything
  • restore the prior chipper/tsconfig/all/tsconfig.json as chipper/tsconfig/eslint/tsconfig.json and point to it from parserOptions.project.

Let's consult with @zepumph soon.

@samreid
Copy link
Member Author

samreid commented Sep 20, 2024

I implemented the recommendation here and in #1470 since I already had it in my working copy. But I left a placeholder in each package.json to make it easy to experiment or revert in the future.

samreid added a commit that referenced this issue Sep 20, 2024
@samreid
Copy link
Member Author

samreid commented Sep 21, 2024

samreid added a commit to phetsims/perennial that referenced this issue Sep 23, 2024
@samreid
Copy link
Member Author

samreid commented Sep 26, 2024

We used projectService and rewrote lint.ts so that a cached lint-everything takes around 8 seconds on my machine. However, with --disable-eslint-cache it is more like 7 minutes, but in that case we are fighting with a memory limit. I feel this issue is covered by TODOs in #1451, so let's close and continue there.

@samreid samreid closed this as completed Sep 26, 2024
samreid added a commit to phetsims/perennial that referenced this issue Oct 21, 2024
@phet-dev phet-dev reopened this Nov 5, 2024
@phet-dev
Copy link
Contributor

phet-dev commented Nov 5, 2024

Reopening because there is a TODO marked for this issue.

samreid added a commit to phetsims/perennial that referenced this issue Nov 5, 2024
@samreid
Copy link
Member Author

samreid commented Nov 5, 2024

Fixed in the branch, will be merged with #1484, closing.

@samreid samreid closed this as completed Nov 5, 2024
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