Skip to content

Commit 7b9d55d

Browse files
tracing: service file cleanup
1 parent c5e8a72 commit 7b9d55d

File tree

4 files changed

+46
-6
lines changed

4 files changed

+46
-6
lines changed

README.md

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,27 @@ This is a performance issue and we are investigating it as a critical bug for v8
5353

5454
See [typescript-eslint/typescript-eslint#9571 Performance: parserOptions.projectService no longer outperforms parserOptions.project](https://github.com/typescript-eslint/typescript-eslint/issues/9571)
5555

56-
## Notes
56+
### Result Measurement Notes
5757

5858
- Example measurements taken on an M1 Max Mac Studio with Node.js 22.4.1
5959
- These results are similar across TypeScript versions: 5.0.4, 5.4.5, and 5.5.3
6060

61-
### Tracing Measurements
61+
## Traces
62+
63+
The `traces/` directory contains more specific traces for investigations.
64+
65+
> ✨ You might consider using [0x](https://github.com/davidmarkclements/0x) for nice flamegraph visuals.
66+
67+
### Comparison: Project and Project Service
68+
69+
This is a preliminary trace to start debugging.
70+
It was run a common shape of linting: 1024 files with the "even" (triangle-shaped) imports layout.
71+
72+
See `traces/Project 1 - Service 2.cpuprofile`.
73+
74+
- Trace #1: `parserOptions.project`
75+
- Trace #2: `parserOptions.projectService`
6276

63-
See example `traces/Project 1 - Service 2.cpuprofile`.
6477
It was generated with:
6578

6679
```shell
@@ -77,7 +90,31 @@ Comparing equivalent code paths:
7790
| All `verifyText`s | 2040ms | 2859ms |
7891
| `parseForESLint` | 993ms | 1090ms |
7992

80-
You might consider using [0x](https://github.com/davidmarkclements/0x) for nice flamegraph visuals.
93+
### Comparison: Project Service Client File Cleanups
94+
95+
This trace shows the cost of the TypeScript project service calling `cleanupProjectsAndScriptInfos`.
96+
It also was run a common shape of linting: 1024 files with the "even" (triangle-shaped) imports layout.
97+
98+
See `traces/service-file-cleanup/`:
99+
100+
- `baseline.cpuprofile`: Baseline measurement with no changes
101+
- `skipping.cpuprofile`: Commenting out the contents of TypeScript's `cleanupProjectsAndScriptInfos`
102+
103+
They were generated with:
104+
105+
```shell
106+
cd files-1024-layout-even-singlerun-true-types-service
107+
node --cpu-prof --cpu-prof-interval=100 --cpu-prof-name=baseline.cpuprofile ../../node_modules/eslint/bin/eslint.js
108+
# clear ../../node_modules/typescript/lib/js > cleanupProjectsAndScriptInfos
109+
node --cpu-prof --cpu-prof-interval=100 --cpu-prof-name=skipping.cpuprofile ../../node_modules/eslint/bin/eslint.js
110+
```
111+
112+
Hyperfine measurements show a ~15-20% improvement in lint time:
113+
114+
| Variant | Measurement | User Time |
115+
| -------- | ----------------- | --------- |
116+
| Baseline | 3.215 s ± 0.041 s | 4.483 s |
117+
| Skipping | 2.501 s ± 0.017 s | 3.758 s |
81118

82119
## Contributors
83120

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"prettier-plugin-sh": "^0.14.0",
6868
"sentences-per-line": "^0.2.1",
6969
"tsx": "^4.16.2",
70-
"typescript": "^5.5.3",
70+
"typescript": "5.5.3",
7171
"typescript-eslint": "8.0.0-alpha.44"
7272
},
7373
"engines": {
@@ -77,6 +77,7 @@
7777
"provenance": true
7878
},
7979
"overrides": {
80-
"@typescript-eslint/utils": "8.0.0-alpha.44"
80+
"@typescript-eslint/utils": "8.0.0-alpha.44",
81+
"typescript@*": "5.5.3"
8182
}
8283
}

traces/service-file-cleanup/baseline.cpuprofile

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

traces/service-file-cleanup/skipping.cpuprofile

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)