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

On linux or editor with canUseEvents to prefer immediate directory if its not in root or node_modules #58866

Merged
merged 2 commits into from
Jun 27, 2024

Conversation

sheetalkamat
Copy link
Member

@sheetalkamat sheetalkamat commented Jun 14, 2024

Experiment with what to watch with preferNonRecursiveWatch option on the host

Helps with #58319

@typescript-bot typescript-bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Jun 14, 2024
@typescript-bot
Copy link
Collaborator

Looks like you're introducing a change to the public API surface area. If this includes breaking changes, please document them on our wiki's API Breaking Changes page.

Also, please make sure @DanielRosenwasser and @RyanCavanaugh are aware of the changes, just as a heads up.

@sheetalkamat
Copy link
Member Author

cc: @dmichon-msft

@sheetalkamat
Copy link
Member Author

@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jun 14, 2024

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
pack this ✅ Started ✅ Results

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jun 14, 2024

Hey @sheetalkamat, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
    "devDependencies": {
        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/162257/artifacts?artifactName=tgz&fileId=AD496CF156DCB5278061745E27AFE41A2D675BC21A387FF89B00275293DBA4D002&fileName=/typescript-5.6.0-insiders.20240614.tgz"
    }
}

and then running npm install.


There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/[email protected]".;

@dmichon-msft
Copy link
Contributor

I'm working on pulling this down to test in my environment. I'll note that I find it useful to also have a toggle to disable watching any path that contains a node_modules element, since modifying the set of installed packages during a watch mode session is already not allowed by the processes in my repository (and I think this is fairly common for monorepos in general). I can approximate the latter with the new ${configDir} functionality though it gets tedious since the relative path depends on the project depth.

@dmichon-msft
Copy link
Contributor

Ah, right, I can't test this directly in my target repository, need to experiment with consuming it from heft-typescript-plugin and passing the necessary config option first. That'll take a bit longer to set up.

@dmichon-msft
Copy link
Contributor

Happy to see this, but it looks like I need to do some work to be compatible with the various changes that shipped in TypeScript 5.5 before I'll be able to test it E2E.

@sheetalkamat
Copy link
Member Author

Ran a experiment with watching packageDir instead of node_modules but that doesnt work out well because of all the node_modules lookups we do for resolution in the folders. It will end up creating more polling watches because say src/node_modules doesnt exist. If i add check of "whether it exists or not" to determine to watch node_modules or package dir, it goes into issue with just having one unresolved module will watch whole node_modules folder and then remove all those watches right after the module is installed. So this isnt performing well so this is the best of both worlds.

Users who dont want to watch node_modules can always ignore them through watchOptions or host.watchDirectory implementation whichever way the user is using tsserver or watch without API or not.

@sheetalkamat sheetalkamat marked this pull request as ready for review June 25, 2024 17:41
@sheetalkamat sheetalkamat changed the title [WIP] On linux or editor with canUseEvents to prefer immediate directory if its not in root or node_modules On linux or editor with canUseEvents to prefer immediate directory if its not in root or node_modules Jun 25, 2024
@sheetalkamat
Copy link
Member Author

@typescript-bot test it

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jun 25, 2024

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
test top400 ✅ Started ✅ Results
user test this ✅ Started ✅ Results
run dt ✅ Started ✅ Results
perf test this faster ✅ Started 👀 Results

@typescript-bot
Copy link
Collaborator

Hey @sheetalkamat, the results of running the DT tests are ready.

Everything looks the same!

You can check the log here.

@typescript-bot
Copy link
Collaborator

@sheetalkamat Here are the results of running the user tests with tsc comparing main and refs/pull/58866/merge:

Everything looks good!

@typescript-bot
Copy link
Collaborator

@sheetalkamat
The results of the perf run you requested are in!

Here they are:

tsc

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Compiler-Unions - node (v18.15.0, x64)
Errors 30 30 ~ ~ ~ p=1.000 n=6
Symbols 62,153 62,153 ~ ~ ~ p=1.000 n=6
Types 50,242 50,242 ~ ~ ~ p=1.000 n=6
Memory used 193,456k (± 0.92%) 192,186k (± 0.08%) ~ 192,079k 192,482k p=0.149 n=6
Parse Time 1.32s (± 0.42%) 1.31s (± 0.62%) ~ 1.29s 1.31s p=0.054 n=6
Bind Time 0.71s 0.71s ~ ~ ~ p=1.000 n=6
Check Time 9.43s (± 0.28%) 9.42s (± 0.23%) ~ 9.40s 9.45s p=0.570 n=6
Emit Time 2.75s (± 0.65%) 2.74s (± 0.38%) ~ 2.73s 2.76s p=0.366 n=6
Total Time 14.20s (± 0.25%) 14.18s (± 0.15%) ~ 14.16s 14.21s p=0.288 n=6
angular-1 - node (v18.15.0, x64)
Errors 5 5 ~ ~ ~ p=1.000 n=6
Symbols 944,114 944,114 ~ ~ ~ p=1.000 n=6
Types 407,050 407,050 ~ ~ ~ p=1.000 n=6
Memory used 1,218,310k (± 0.00%) 1,218,379k (± 0.00%) +69k (+ 0.01%) 1,218,362k 1,218,391k p=0.008 n=6
Parse Time 6.65s (± 0.61%) 6.66s (± 0.32%) ~ 6.63s 6.68s p=0.622 n=6
Bind Time 1.87s (± 0.28%) 1.86s (± 0.48%) ~ 1.85s 1.87s p=0.190 n=6
Check Time 30.58s (± 0.35%) 30.59s (± 0.36%) ~ 30.46s 30.70s p=1.000 n=6
Emit Time 13.58s (± 0.23%) 13.51s (± 0.59%) ~ 13.38s 13.60s p=0.060 n=6
Total Time 52.68s (± 0.24%) 52.61s (± 0.29%) ~ 52.48s 52.84s p=0.422 n=6
mui-docs - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,135,096 2,135,096 ~ ~ ~ p=1.000 n=6
Types 927,168 927,168 ~ ~ ~ p=1.000 n=6
Memory used 2,117,275k (± 0.00%) 2,117,276k (± 0.00%) ~ 2,117,196k 2,117,485k p=0.810 n=6
Parse Time 6.64s (± 0.53%) 6.64s (± 0.22%) ~ 6.63s 6.66s p=0.620 n=6
Bind Time 2.33s (± 1.05%) 2.33s (± 0.97%) ~ 2.29s 2.35s p=0.340 n=6
Check Time 70.59s (± 0.37%) 70.84s (± 0.47%) ~ 70.53s 71.30s p=0.230 n=6
Emit Time 0.13s (± 3.87%) 0.14s (± 5.44%) ~ 0.13s 0.15s p=0.247 n=6
Total Time 79.69s (± 0.38%) 79.96s (± 0.44%) ~ 79.63s 80.44s p=0.230 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,231,459 1,231,988 +529 (+ 0.04%) ~ ~ p=0.001 n=6
Types 261,178 261,417 +239 (+ 0.09%) ~ ~ p=0.001 n=6
Memory used 2,346,776k (± 0.02%) 2,347,610k (± 0.05%) ~ 2,345,742k 2,348,583k p=0.128 n=6
Parse Time 5.05s (± 1.13%) 5.02s (± 0.43%) ~ 4.99s 5.05s p=0.521 n=6
Bind Time 1.92s (± 0.39%) 1.93s (± 0.71%) ~ 1.91s 1.95s p=0.099 n=6
Check Time 34.15s (± 0.54%) 34.21s (± 0.65%) ~ 34.05s 34.64s p=0.471 n=6
Emit Time 2.75s (± 3.33%) 2.72s (± 3.17%) ~ 2.61s 2.81s p=0.630 n=6
Total Time 43.87s (± 0.54%) 43.91s (± 0.56%) ~ 43.71s 44.39s p=0.630 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,231,459 1,231,988 +529 (+ 0.04%) ~ ~ p=0.001 n=6
Types 261,178 261,417 +239 (+ 0.09%) ~ ~ p=0.001 n=6
Memory used 2,424,836k (± 0.03%) 2,435,103k (± 0.99%) ~ 2,424,249k 2,484,319k p=0.230 n=6
Parse Time 7.77s (± 0.89%) 7.81s (± 0.80%) ~ 7.71s 7.90s p=0.470 n=6
Bind Time 2.52s (± 0.69%) 2.51s (± 0.54%) ~ 2.49s 2.52s p=0.105 n=6
Check Time 50.05s (± 0.32%) 50.01s (± 0.26%) ~ 49.85s 50.22s p=0.689 n=6
Emit Time 3.89s (± 2.37%) 3.94s (± 2.25%) ~ 3.85s 4.06s p=0.378 n=6
Total Time 64.25s (± 0.27%) 64.28s (± 0.11%) ~ 64.18s 64.40s p=1.000 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 258,577 258,600 +23 (+ 0.01%) ~ ~ p=0.001 n=6
Types 104,827 104,828 +1 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 428,241k (± 0.02%) 428,236k (± 0.01%) ~ 428,192k 428,267k p=0.810 n=6
Parse Time 3.31s (± 0.59%) 3.31s (± 0.91%) ~ 3.28s 3.35s p=0.871 n=6
Bind Time 1.30s (± 0.80%) 1.32s (± 1.97%) ~ 1.27s 1.34s p=0.089 n=6
Check Time 17.74s (± 0.36%) 17.78s (± 0.76%) ~ 17.61s 18.01s p=0.748 n=6
Emit Time 1.38s (± 1.82%) 1.38s (± 0.85%) ~ 1.36s 1.39s p=0.870 n=6
Total Time 23.73s (± 0.28%) 23.78s (± 0.59%) ~ 23.61s 24.03s p=0.629 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 35 35 ~ ~ ~ p=1.000 n=6
Symbols 224,565 224,565 ~ ~ ~ p=1.000 n=6
Types 93,734 93,734 ~ ~ ~ p=1.000 n=6
Memory used 369,459k (± 0.04%) 369,518k (± 0.03%) ~ 369,342k 369,665k p=0.471 n=6
Parse Time 2.78s (± 0.89%) 2.77s (± 1.15%) ~ 2.73s 2.81s p=0.810 n=6
Bind Time 1.59s (± 1.11%) 1.58s (± 0.95%) ~ 1.57s 1.61s p=1.000 n=6
Check Time 15.49s (± 0.13%) 15.46s (± 0.38%) ~ 15.38s 15.55s p=0.146 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 19.85s (± 0.17%) 19.82s (± 0.38%) ~ 19.73s 19.91s p=0.332 n=6
vscode - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,878,705 2,878,705 ~ ~ ~ p=1.000 n=6
Types 975,213 975,213 ~ ~ ~ p=1.000 n=6
Memory used 3,041,996k (± 0.00%) 3,042,016k (± 0.00%) ~ 3,041,950k 3,042,061k p=0.630 n=6
Parse Time 13.54s (± 0.26%) 13.51s (± 0.15%) ~ 13.49s 13.54s p=0.147 n=6
Bind Time 4.19s (± 0.18%) 4.19s (± 0.43%) ~ 4.17s 4.22s p=0.620 n=6
Check Time 73.34s (± 0.33%) 73.97s (± 2.35%) ~ 72.96s 77.48s p=1.000 n=6
Emit Time 24.04s (± 0.30%) 23.42s (± 6.51%) ~ 20.32s 24.33s p=0.423 n=6
Total Time 115.11s (± 0.21%) 115.09s (± 0.25%) ~ 114.79s 115.55s p=0.810 n=6
webpack - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 267,117 267,117 ~ ~ ~ p=1.000 n=6
Types 108,775 108,775 ~ ~ ~ p=1.000 n=6
Memory used 411,549k (± 0.01%) 411,552k (± 0.03%) ~ 411,486k 411,779k p=0.230 n=6
Parse Time 3.83s (± 0.38%) 3.81s (± 0.77%) ~ 3.78s 3.86s p=0.462 n=6
Bind Time 1.69s (± 0.37%) 1.69s (± 0.31%) ~ 1.68s 1.69s p=0.386 n=6
Check Time 16.70s (± 0.40%) 16.71s (± 0.57%) ~ 16.57s 16.85s p=1.000 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 22.21s (± 0.31%) 22.21s (± 0.34%) ~ 22.11s 22.34s p=1.000 n=6
xstate-main - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 525,251 525,251 ~ ~ ~ p=1.000 n=6
Types 178,574 178,574 ~ ~ ~ p=1.000 n=6
Memory used 462,844k (± 0.05%) 462,879k (± 0.07%) ~ 462,460k 463,270k p=0.936 n=6
Parse Time 3.92s (± 0.70%) 3.93s (± 0.70%) ~ 3.89s 3.96s p=0.419 n=6
Bind Time 1.45s (± 0.73%) 1.45s (± 1.14%) ~ 1.43s 1.47s p=0.869 n=6
Check Time 22.24s (± 0.55%) 22.22s (± 0.32%) ~ 22.13s 22.33s p=0.873 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 27.60s (± 0.38%) 27.60s (± 0.28%) ~ 27.49s 27.72s p=0.936 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Compiler-Unions - node (v18.15.0, x64)
  • angular-1 - node (v18.15.0, x64)
  • mui-docs - node (v18.15.0, x64)
  • self-build-src - node (v18.15.0, x64)
  • self-build-src-public-api - node (v18.15.0, x64)
  • self-compiler - node (v18.15.0, x64)
  • ts-pre-modules - node (v18.15.0, x64)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate-main - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@typescript-bot
Copy link
Collaborator

@sheetalkamat Here are the results of running the top 400 repos with tsc comparing main and refs/pull/58866/merge:

Everything looks good!

@@ -2651,6 +2651,7 @@ declare namespace ts {
interface ServerHost extends System {
watchFile(path: string, callback: FileWatcherCallback, pollingInterval?: number, options?: WatchOptions): FileWatcher;
watchDirectory(path: string, callback: DirectoryWatcherCallback, recursive?: boolean, options?: WatchOptions): FileWatcher;
preferNonRecursiveWatch?: boolean;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the intent that downstream users configure this? Do we need to wait for David to check that this helps?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was not sure whether to leave this public on ServerHost or not but TscWatch yes because i think last i checked david was using the API to patch tsc watch.

I am looking to get this in early and revert or reiterate sooner than later as we dont get more feedback without this being in nightly esp since this depends on OS and vscode setting to use their watchers

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i can make these internal on tsc-watch and tsserver internal and make them public in next PR if they are needed if that approach is better

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood; just checking; I think you have more context than me on this.

@sheetalkamat sheetalkamat merged commit f7833b2 into main Jun 27, 2024
28 checks passed
@sheetalkamat sheetalkamat deleted the recursiveWatchOptimization branch June 27, 2024 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants