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

Don't skip markLinkedReferences on ambient properties #59325

Merged
merged 3 commits into from
Jul 17, 2024

Conversation

jakebailey
Copy link
Member

Fixes #59051

Alternatively, I can also only walk ambients when emitDecoratorMetadata is on, or only when the hint is Unspecified or Decorator.

@jakebailey
Copy link
Member Author

@typescript-bot test it

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jul 17, 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 typescript-bot added the For Milestone Bug PRs that fix a bug with a specific milestone label Jul 17, 2024
@typescript-bot
Copy link
Collaborator

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

Everything looks the same!

You can check the log here.

@typescript-bot
Copy link
Collaborator

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

Everything looks good!

@typescript-bot
Copy link
Collaborator

@jakebailey
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 194,103k (± 0.97%) 194,135k (± 0.98%) ~ 192,247k 195,931k p=1.000 n=6
Parse Time 1.30s (± 1.71%) 1.31s (± 0.75%) ~ 1.29s 1.32s p=0.655 n=6
Bind Time 0.71s (± 0.57%) 0.71s ~ ~ ~ p=0.405 n=6
Check Time 9.51s (± 0.22%) 9.53s (± 0.50%) ~ 9.47s 9.60s p=0.422 n=6
Emit Time 2.73s (± 1.26%) 2.73s (± 1.59%) ~ 2.65s 2.77s p=0.935 n=6
Total Time 14.25s (± 0.34%) 14.28s (± 0.18%) ~ 14.25s 14.32s p=0.224 n=6
angular-1 - node (v18.15.0, x64)
Errors 5 5 ~ ~ ~ p=1.000 n=6
Symbols 944,120 944,120 ~ ~ ~ p=1.000 n=6
Types 407,047 407,047 ~ ~ ~ p=1.000 n=6
Memory used 1,218,670k (± 0.00%) 1,218,649k (± 0.00%) ~ 1,218,603k 1,218,703k p=0.471 n=6
Parse Time 6.72s (± 0.60%) 6.68s (± 0.73%) ~ 6.60s 6.73s p=0.376 n=6
Bind Time 1.86s (± 0.79%) 1.87s (± 0.73%) ~ 1.85s 1.88s p=0.672 n=6
Check Time 31.03s (± 0.44%) 30.96s (± 0.35%) ~ 30.80s 31.10s p=0.471 n=6
Emit Time 15.02s (± 0.71%) 15.00s (± 0.33%) ~ 14.92s 15.07s p=1.000 n=6
Total Time 54.63s (± 0.34%) 54.52s (± 0.25%) ~ 54.40s 54.74s p=0.261 n=6
mui-docs - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,275,944 2,275,944 ~ ~ ~ p=1.000 n=6
Types 948,749 948,749 ~ ~ ~ p=1.000 n=6
Memory used 2,207,308k (± 0.00%) 2,207,244k (± 0.00%) ~ 2,207,134k 2,207,337k p=0.173 n=6
Parse Time 9.69s (± 0.27%) 9.68s (± 0.28%) ~ 9.65s 9.73s p=0.515 n=6
Bind Time 3.39s (± 0.91%) 3.37s (± 0.35%) ~ 3.35s 3.38s p=0.072 n=6
Check Time 105.46s (± 0.52%) 105.78s (± 0.39%) ~ 105.20s 106.24s p=0.298 n=6
Emit Time 0.20s (± 2.06%) 0.20s (± 4.47%) ~ 0.19s 0.21s p=0.787 n=6
Total Time 118.76s (± 0.48%) 119.04s (± 0.35%) ~ 118.46s 119.54s p=0.378 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,227,101 1,227,101 ~ ~ ~ p=1.000 n=6
Types 261,800 261,800 ~ ~ ~ p=1.000 n=6
Memory used 2,459,002k (±11.76%) 2,340,826k (± 0.03%) ~ 2,339,530k 2,341,579k p=1.000 n=6
Parse Time 5.13s (± 0.93%) 5.12s (± 0.49%) ~ 5.07s 5.14s p=1.000 n=6
Bind Time 1.89s (± 0.78%) 1.90s (± 0.67%) ~ 1.88s 1.92s p=0.392 n=6
Check Time 34.47s (± 0.52%) 34.41s (± 0.29%) ~ 34.25s 34.55s p=1.000 n=6
Emit Time 3.34s (± 1.64%) 3.29s (± 1.54%) ~ 3.21s 3.36s p=0.230 n=6
Total Time 44.84s (± 0.50%) 44.74s (± 0.30%) ~ 44.55s 44.90s p=0.689 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,227,101 1,227,101 ~ ~ ~ p=1.000 n=6
Types 261,800 261,800 ~ ~ ~ p=1.000 n=6
Memory used 2,415,560k (± 0.02%) 2,415,143k (± 0.01%) ~ 2,414,890k 2,415,531k p=0.229 n=6
Parse Time 5.29s (± 1.09%) 5.25s (± 0.43%) ~ 5.21s 5.28s p=0.229 n=6
Bind Time 1.70s (± 0.81%) 1.70s (± 0.48%) ~ 1.69s 1.71s p=0.868 n=6
Check Time 35.02s (± 0.13%) 34.95s (± 0.36%) ~ 34.76s 35.13s p=0.229 n=6
Emit Time 3.32s (± 2.54%) 3.36s (± 1.50%) ~ 3.27s 3.42s p=0.172 n=6
Total Time 45.35s (± 0.23%) 45.27s (± 0.35%) ~ 45.09s 45.50s p=0.378 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 258,471 258,471 ~ ~ ~ p=1.000 n=6
Types 104,867 104,867 ~ ~ ~ p=1.000 n=6
Memory used 427,701k (± 0.01%) 427,793k (± 0.03%) ~ 427,665k 427,992k p=0.109 n=6
Parse Time 3.35s (± 0.53%) 3.35s (± 1.25%) ~ 3.30s 3.41s p=0.686 n=6
Bind Time 1.32s (± 1.82%) 1.33s (± 0.63%) ~ 1.31s 1.33s p=1.000 n=6
Check Time 17.96s (± 0.31%) 18.04s (± 0.29%) 0.08s ( 0.45%) 17.96s 18.12s p=0.043 n=6
Emit Time 1.63s (± 0.93%) 1.63s (± 1.27%) ~ 1.60s 1.66s p=0.405 n=6
Total Time 24.26s (± 0.39%) 24.34s (± 0.13%) ~ 24.29s 24.38s p=0.108 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,607k (± 0.03%) 369,576k (± 0.03%) ~ 369,442k 369,751k p=0.873 n=6
Parse Time 3.43s (± 0.65%) 3.42s (± 0.78%) ~ 3.38s 3.46s p=0.678 n=6
Bind Time 1.94s (± 1.05%) 1.93s (± 0.97%) ~ 1.91s 1.96s p=0.871 n=6
Check Time 19.33s (± 0.27%) 19.32s (± 0.42%) ~ 19.21s 19.45s p=0.748 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 24.70s (± 0.28%) 24.68s (± 0.36%) ~ 24.56s 24.78s p=0.748 n=6
vscode - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,971,932 2,971,932 ~ ~ ~ p=1.000 n=6
Types 1,020,692 1,020,692 ~ ~ ~ p=1.000 n=6
Memory used 3,096,420k (± 0.00%) 3,096,375k (± 0.00%) ~ 3,096,313k 3,096,431k p=0.230 n=6
Parse Time 17.07s (± 0.29%) 17.08s (± 0.19%) ~ 17.04s 17.11s p=0.872 n=6
Bind Time 5.25s (± 2.37%) 5.26s (± 2.72%) ~ 5.15s 5.46s p=1.000 n=6
Check Time 96.38s (± 0.23%) 95.97s (± 0.28%) -0.42s (- 0.43%) 95.62s 96.34s p=0.020 n=6
Emit Time 24.98s (± 0.75%) 24.87s (± 0.41%) ~ 24.74s 24.99s p=0.422 n=6
Total Time 143.67s (± 0.22%) 143.17s (± 0.16%) -0.50s (- 0.35%) 142.87s 143.50s p=0.020 n=6
webpack - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 267,282 267,282 ~ ~ ~ p=1.000 n=6
Types 108,835 108,835 ~ ~ ~ p=1.000 n=6
Memory used 411,825k (± 0.02%) 411,838k (± 0.02%) ~ 411,763k 411,947k p=1.000 n=6
Parse Time 3.84s (± 0.43%) 3.83s (± 0.49%) ~ 3.81s 3.86s p=1.000 n=6
Bind Time 1.69s (± 0.31%) 1.67s (± 0.82%) ~ 1.66s 1.69s p=0.102 n=6
Check Time 16.80s (± 0.41%) 16.86s (± 0.27%) ~ 16.80s 16.93s p=0.106 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 22.33s (± 0.28%) 22.37s (± 0.22%) ~ 22.30s 22.42s p=0.296 n=6
xstate-main - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 510,479 510,479 ~ ~ ~ p=1.000 n=6
Types 161,598 161,598 ~ ~ ~ p=1.000 n=6
Memory used 447,985k (± 0.09%) 448,171k (± 0.09%) ~ 447,689k 448,535k p=0.336 n=6
Parse Time 3.15s (± 1.34%) 3.16s (± 0.38%) ~ 3.15s 3.18s p=0.089 n=6
Bind Time 1.18s (± 0.54%) 1.18s (± 1.07%) ~ 1.17s 1.20s p=0.799 n=6
Check Time 17.14s (± 0.48%) 17.15s (± 0.56%) ~ 17.04s 17.27s p=0.571 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 21.47s (± 0.50%) 21.50s (± 0.44%) ~ 21.38s 21.61s p=0.574 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

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

Everything looks good!

@jakebailey
Copy link
Member Author

Everything seems fine in the above; @weswigham is there a major downside to removing this bit?

@rbuckton
Copy link
Member

I think the only declare that effects runtime emit are declare fields with decorators. Should we preserve all ambients, or should this fix be more narrowly focused?

@jakebailey
Copy link
Member Author

I think the only declare that effects runtime emit are declare fields with decorators. Should we preserve all ambients, or should this fix be more narrowly focused?

I can scope it down, the trouble is just that there's an "unspecified" hint which is hit from noCheck as it's not actually walking things the same way as we do the checker, so I have to disable it for that category as well. I wasn't sure how bad that'd be, but it did work fine too.

We just didn't have this optimization at all in the original code before #58366 so reverting it seemed okayish.

@@ -29679,9 29679,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
if (!canCollectSymbolAliasAccessabilityData) {
return;
}
if (location.flags & NodeFlags.Ambient) {
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I wouldn't want to remove this outright - perf tests won't show it, but this is pretty important to keep this fast from my testing. I'd just except ambient property signatures from the early skip, since they're like... not really ambient? It looks like when we have something like

class A {
  @decorator(class B {})
  declare prop: string;
}

the prop is ambient marked, but the decorator is not, so we should just be able to except the prop, like @rbuckton says.

if (location.flags & NodeFlags.Ambient && !isPropertySignature(location) && !isPropertyDeclaration(location)) {

seems like it aughta work?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done; that seemed to be enough.

Copy link
Member

Choose a reason for hiding this comment

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

declare fields aren't quite as ambient as other declarations. They were added as a compatiblity mechanism due to native class fields using Define semantics, with legacy decorators being one of the main motivations.

@jakebailey jakebailey changed the title Don't skip markLinkedReferences on ambients Don't skip markLinkedReferences on ambient properties Jul 17, 2024
@jakebailey
Copy link
Member Author

Updated; PTAL

Copy link
Member

@weswigham weswigham left a comment

Choose a reason for hiding this comment

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

Funky to me that we allow a supposedly ambient prop to be decorated at all - seems like that kinda forces it to be non-ambient 🤷‍♂️

@jakebailey
Copy link
Member Author

@typescript-bot cherry-pick this to release-5.5

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jul 17, 2024

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

Command Status Results
cherry-pick this to release-5.5 ✅ Started ✅ Results

@typescript-bot
Copy link
Collaborator

Hey, @jakebailey! I've created #59336 for you.

@jakebailey jakebailey merged commit 95a968c into microsoft:main Jul 17, 2024
29 checks passed
@jakebailey jakebailey deleted the fix-59051 branch July 17, 2024 23:10
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 5.5.4 milestone Jul 17, 2024
DanielRosenwasser pushed a commit that referenced this pull request Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

TS 5.5 - Imports used by decorator output are removed
5 participants