Skip to content

Conversation

andrewbranch
Copy link
Member

Fixes #46024
Also probably fixes #38071 with the missing checker.getMergedSymbol

Side note: the distinction between a type’s members and properties (or resolvedProperties in the case of a union/intersection type) is frustrating—members contains crucial information that properties lacks, which is the key in the symbol table where that symbol is stored. It’s usually just symbol.escapedName, but not always, as in this test case: the type of the export= symbol has a key named defaults, but the symbol at that location has the name newDefaults. (This weirdness may only happen in JS code where we jump through weird hoops to bind everything we can, not sure.) But the properties array also has filtered out the non-value symbols and symbols with reserved names (specifying unique symbol and #private members), so members is not a drop-in replacement. That said, this filtering appears to be very cheap, so I really wonder if storing properties alongside members is even worth the weight of the array allocations. Might be an interesting experiment.

@andrewbranch andrewbranch requested a review from sandersn October 22, 2021 21:29
@typescript-bot typescript-bot added For Backlog Bug PRs that fix a backlog bug For Milestone Bug PRs that fix a bug with a specific milestone labels Oct 22, 2021
@microsoft microsoft deleted a comment from typescript-bot Oct 22, 2021
@microsoft microsoft deleted a comment from typescript-bot Oct 22, 2021
@andrewbranch
Copy link
Member Author

@typescript-bot perf test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Oct 22, 2021

Heya @andrewbranch, I've started to run the perf test suite on this PR at fbf8470. You can monitor the build here.

Update: The results are in!

Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

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

This looks like a good fix, although I have a couple of questions.

}

function isNamedMember(member: Symbol, escapedName: __String) {
return !isReservedMemberName(escapedName) && symbolIsValue(member);
Copy link
Member

Choose a reason for hiding this comment

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

what does symbolIsValue do, and how is it useful here?

Copy link
Member Author

Choose a reason for hiding this comment

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

It just checks symbol.flags & SymbolFlags.Value, and it’s used to filter out type and uninstantiated namespace members out of instantiated namespaces. (I just moved this existing logic into a function so I could reuse it.)

}
});
const exportEquals = resolveExternalModuleSymbol(moduleSymbol);
if (exportEquals !== moduleSymbol) {
Copy link
Member

Choose a reason for hiding this comment

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

is forEachExportAndPropertyOfModule only used in the services layer?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep.

// 3. Otherwise, we have a default/namespace import that can be imported by any name, and
// `symbolTableKey` will be something undesirable like `export=` or `default`, so we try to
// get a better name.
const importedName = exportKind === ExportKind.Named || isExternalModuleSymbol(namedSymbol)
Copy link
Member

Choose a reason for hiding this comment

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

this is fine, but it feels a little backward compared to the usual approach of checking for special names first

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 probably agree—this is a refactor of a refactor of a refactor of... it has probably accumulated some unnecessary roundabout logic that could be simplified if rewritten fresh.

@typescript-bot
Copy link
Collaborator

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

Here they are:

Comparison Report - main..46490

Metric main 46490 Delta Best Worst
Angular - node (v10.16.3, x64)
Memory used 354,020k (± 0.02%) 354,045k (± 0.02%) +24k (+ 0.01%) 353,954k 354,183k
Parse Time 1.95s (± 0.42%) 1.95s (± 0.50%) -0.00s (- 0.10%) 1.93s 1.97s
Bind Time 0.85s (± 0.68%) 0.84s (± 0.62%) -0.01s (- 0.94%) 0.83s 0.85s
Check Time 5.48s (± 0.30%) 5.47s (± 0.34%) -0.00s (- 0.09%) 5.43s 5.53s
Emit Time 5.85s (± 0.91%) 5.84s (± 0.62%) -0.01s (- 0.15%) 5.78s 5.94s
Total Time 14.13s (± 0.44%) 14.11s (± 0.39%) -0.02s (- 0.16%) 13.99s 14.25s
Compiler-Unions - node (v10.16.3, x64)
Memory used 203,624k (± 0.30%) 203,847k (± 0.02%) +223k (+ 0.11%) 203,777k 203,987k
Parse Time 0.78s (± 0.97%) 0.79s (± 0.76%) +0.00s (+ 0.26%) 0.78s 0.80s
Bind Time 0.52s (± 0.85%) 0.52s (± 1.07%) -0.00s (- 0.77%) 0.51s 0.53s
Check Time 7.90s (± 0.67%) 7.93s (± 0.50%) +0.02s (+ 0.30%) 7.83s 8.01s
Emit Time 2.43s (± 0.65%) 2.41s (± 0.45%) -0.02s (- 0.82%) 2.39s 2.44s
Total Time 11.64s (± 0.51%) 11.64s (± 0.34%) +0.00s (+ 0.02%) 11.55s 11.71s
Monaco - node (v10.16.3, x64)
Memory used 342,154k (± 0.02%) 342,085k (± 0.02%) -70k (- 0.02%) 341,927k 342,183k
Parse Time 1.49s (± 0.41%) 1.48s (± 0.82%) -0.01s (- 0.67%) 1.44s 1.50s
Bind Time 0.75s (± 0.46%) 0.75s (± 1.11%) -0.00s (- 0.13%) 0.73s 0.76s
Check Time 5.45s (± 0.34%) 5.45s (± 0.48%) -0.01s (- 0.11%) 5.37s 5.50s
Emit Time 3.16s (± 0.45%) 3.17s (± 0.95%) +0.01s (+ 0.44%) 3.12s 3.27s
Total Time 10.84s (± 0.17%) 10.84s (± 0.28%) 0.00s ( 0.00%) 10.80s 10.92s
TFS - node (v10.16.3, x64)
Memory used 304,779k (± 0.02%) 304,786k (± 0.02%) +6k (+ 0.00%) 304,676k 304,896k
Parse Time 1.20s (± 0.68%) 1.20s (± 0.50%) -0.00s (- 0.33%) 1.18s 1.21s
Bind Time 0.71s (± 0.67%) 0.71s (± 0.78%) -0.00s (- 0.70%) 0.69s 0.72s
Check Time 4.97s (± 0.45%) 4.96s (± 0.46%) -0.01s (- 0.20%) 4.91s 5.00s
Emit Time 3.32s (± 0.77%) 3.32s (± 1.37%) 0.00s ( 0.00%) 3.24s 3.41s
Total Time 10.20s (± 0.31%) 10.18s (± 0.62%) -0.02s (- 0.19%) 10.05s 10.31s
material-ui - node (v10.16.3, x64)
Memory used 470,385k (± 0.02%) 470,369k (± 0.01%) -16k (- 0.00%) 470,178k 470,507k
Parse Time 1.77s (± 0.62%) 1.76s (± 0.33%) -0.01s (- 0.56%) 1.75s 1.77s
Bind Time 0.66s (± 0.61%) 0.66s (± 0.55%) -0.00s (- 0.46%) 0.65s 0.66s
Check Time 14.39s (± 0.36%) 14.32s (± 0.46%) -0.08s (- 0.53%) 14.18s 14.47s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 16.82s (± 0.35%) 16.73s (± 0.40%) -0.09s (- 0.53%) 16.61s 16.89s
xstate - node (v10.16.3, x64)
Memory used 570,055k (± 0.01%) 569,952k (± 0.01%) -103k (- 0.02%) 569,833k 570,171k
Parse Time 2.55s (± 0.33%) 2.55s (± 0.26%) +0.00s (+ 0.08%) 2.54s 2.57s
Bind Time 1.01s (± 0.58%) 1.00s (± 0.49%) -0.00s (- 0.30%) 0.99s 1.01s
Check Time 1.55s (± 0.53%) 1.56s (± 0.39%) +0.00s (+ 0.13%) 1.54s 1.57s
Emit Time 0.07s (± 0.00%) 0.07s (± 3.14%) +0.00s (+ 1.43%) 0.07s 0.08s
Total Time 5.18s (± 0.35%) 5.18s (± 0.13%) -0.00s (- 0.06%) 5.16s 5.19s
Angular - node (v12.1.0, x64)
Memory used 331,948k (± 0.02%) 331,890k (± 0.02%) -57k (- 0.02%) 331,731k 332,059k
Parse Time 1.94s (± 0.98%) 1.94s (± 0.71%) +0.00s (+ 0.15%) 1.91s 1.97s
Bind Time 0.82s (± 0.98%) 0.82s (± 0.63%) +0.00s (+ 0.37%) 0.81s 0.83s
Check Time 5.32s (± 0.42%) 5.30s (± 0.39%) -0.02s (- 0.43%) 5.26s 5.33s
Emit Time 6.10s (± 0.51%) 6.13s (± 0.99%) +0.03s (+ 0.48%) 6.04s 6.28s
Total Time 14.19s (± 0.41%) 14.19s (± 0.54%) +0.01s (+ 0.07%) 14.07s 14.36s
Compiler-Unions - node (v12.1.0, x64)
Memory used 191,334k (± 0.12%) 191,416k (± 0.04%) +82k (+ 0.04%) 191,231k 191,627k
Parse Time 0.78s (± 0.97%) 0.78s (± 0.67%) -0.00s (- 0.64%) 0.77s 0.79s
Bind Time 0.53s (± 0.84%) 0.52s (± 0.94%) -0.01s (- 1.50%) 0.51s 0.53s
Check Time 7.44s (± 1.03%) 7.43s (± 0.71%) -0.01s (- 0.15%) 7.32s 7.57s
Emit Time 2.44s (± 0.75%) 2.45s (± 0.66%) +0.01s (+ 0.29%) 2.41s 2.48s
Total Time 11.20s (± 0.66%) 11.19s (± 0.56%) -0.01s (- 0.12%) 11.04s 11.34s
Monaco - node (v12.1.0, x64)
Memory used 325,210k (± 0.02%) 325,188k (± 0.03%) -21k (- 0.01%) 324,973k 325,437k
Parse Time 1.47s (± 0.84%) 1.45s (± 0.69%) -0.01s (- 0.89%) 1.43s 1.48s
Bind Time 0.73s (± 0.96%) 0.73s (± 1.44%) +0.00s (+ 0.14%) 0.72s 0.76s
Check Time 5.34s (± 0.47%) 5.34s (± 0.30%) +0.00s (+ 0.07%) 5.30s 5.38s
Emit Time 3.18s (± 0.86%) 3.19s (± 0.64%) +0.01s (+ 0.28%) 3.14s 3.25s
Total Time 10.71s (± 0.52%) 10.72s (± 0.30%) +0.00s (+ 0.03%) 10.67s 10.83s
TFS - node (v12.1.0, x64)
Memory used 289,467k (± 0.02%) 289,486k (± 0.02%) +19k (+ 0.01%) 289,404k 289,582k
Parse Time 1.22s (± 0.76%) 1.22s (± 1.23%) -0.00s (- 0.08%) 1.20s 1.26s
Bind Time 0.69s (± 0.69%) 0.69s (± 0.96%) -0.00s (- 0.43%) 0.68s 0.71s
Check Time 4.92s (± 0.51%) 4.91s (± 0.40%) -0.01s (- 0.14%) 4.87s 4.96s
Emit Time 3.37s (± 0.76%) 3.35s (± 1.00%) -0.02s (- 0.59%) 3.26s 3.44s
Total Time 10.20s (± 0.44%) 10.17s (± 0.50%) -0.03s (- 0.32%) 10.04s 10.25s
material-ui - node (v12.1.0, x64)
Memory used 449,172k (± 0.01%) 449,256k (± 0.01%) +84k (+ 0.02%) 449,122k 449,379k
Parse Time 1.78s (± 0.75%) 1.78s (± 0.53%) +0.00s (+ 0.22%) 1.77s 1.81s
Bind Time 0.65s (± 0.76%) 0.64s (± 1.16%) -0.00s (- 0.46%) 0.63s 0.66s
Check Time 12.95s (± 0.67%) 13.01s (± 0.71%) +0.06s (+ 0.46%) 12.86s 13.28s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.37s (± 0.57%) 15.43s (± 0.63%) +0.06s (+ 0.39%) 15.27s 15.72s
xstate - node (v12.1.0, x64)
Memory used 535,947k (± 0.02%) 535,995k (± 0.01%) +48k (+ 0.01%) 535,869k 536,145k
Parse Time 2.50s (± 0.48%) 2.49s (± 0.68%) -0.01s (- 0.40%) 2.46s 2.54s
Bind Time 1.05s (± 0.86%) 1.05s (± 0.91%) -0.00s (- 0.38%) 1.03s 1.07s
Check Time 1.50s (± 0.89%) 1.49s (± 0.55%) -0.01s (- 0.73%) 1.48s 1.52s
Emit Time 0.07s (± 0.00%) 0.07s (± 0.00%) 0.00s ( 0.00%) 0.07s 0.07s
Total Time 5.13s (± 0.44%) 5.10s (± 0.38%) -0.02s (- 0.47%) 5.06s 5.14s
Angular - node (v14.15.1, x64)
Memory used 330,328k (± 0.01%) 330,333k (± 0.01%) +5k (+ 0.00%) 330,279k 330,380k
Parse Time 1.96s (± 0.64%) 1.95s (± 0.75%) -0.01s (- 0.51%) 1.93s 2.00s
Bind Time 0.86s (± 0.55%) 0.86s (± 0.98%) -0.00s (- 0.46%) 0.85s 0.88s
Check Time 5.39s (± 0.61%) 5.38s (± 0.49%) -0.01s (- 0.26%) 5.32s 5.43s
Emit Time 6.19s (± 1.32%) 6.15s (± 0.96%) -0.04s (- 0.63%) 6.04s 6.32s
Total Time 14.40s (± 0.67%) 14.34s (± 0.45%) -0.06s (- 0.44%) 14.24s 14.55s
Compiler-Unions - node (v14.15.1, x64)
Memory used 192,144k (± 0.62%) 192,573k (± 0.49%) +430k (+ 0.22%) 190,027k 193,249k
Parse Time 0.81s (± 1.00%) 0.81s (± 0.42%) -0.01s (- 0.74%) 0.80s 0.81s
Bind Time 0.56s (± 0.61%) 0.55s (± 0.66%) -0.00s (- 0.54%) 0.55s 0.56s
Check Time 7.59s (± 0.79%) 7.53s (± 0.62%) -0.06s (- 0.72%) 7.45s 7.67s
Emit Time 2.46s (± 1.00%) 2.44s (± 0.86%) -0.02s (- 1.02%) 2.40s 2.50s
Total Time 11.42s (± 0.64%) 11.33s (± 0.50%) -0.09s (- 0.80%) 11.25s 11.52s
Monaco - node (v14.15.1, x64)
Memory used 324,008k (± 0.00%) 323,996k (± 0.01%) -12k (- 0.00%) 323,949k 324,033k
Parse Time 1.51s (± 0.44%) 1.51s (± 0.59%) +0.00s (+ 0.00%) 1.50s 1.54s
Bind Time 0.76s (± 0.63%) 0.76s (± 0.87%) +0.00s (+ 0.40%) 0.75s 0.78s
Check Time 5.33s (± 0.45%) 5.30s (± 0.46%) -0.02s (- 0.39%) 5.26s 5.37s
Emit Time 3.24s (± 0.99%) 3.23s (± 0.65%) -0.02s (- 0.52%) 3.19s 3.29s
Total Time 10.83s (± 0.42%) 10.79s (± 0.33%) -0.04s (- 0.34%) 10.71s 10.88s
TFS - node (v14.15.1, x64)
Memory used 288,354k (± 0.01%) 288,370k (± 0.00%) +16k (+ 0.01%) 288,343k 288,398k
Parse Time 1.23s (± 0.71%) 1.24s (± 0.30%) +0.01s (+ 0.57%) 1.23s 1.24s
Bind Time 0.73s (± 0.79%) 0.74s (± 0.68%) +0.01s (+ 0.68%) 0.72s 0.74s
Check Time 4.92s (± 0.48%) 4.92s (± 0.43%) -0.00s (- 0.00%) 4.89s 4.99s
Emit Time 3.51s (± 0.49%) 3.47s (± 0.67%) -0.04s (- 1.17%) 3.42s 3.52s
Total Time 10.39s (± 0.34%) 10.36s (± 0.38%) -0.03s (- 0.28%) 10.28s 10.45s
material-ui - node (v14.15.1, x64)
Memory used 447,429k (± 0.05%) 447,506k (± 0.00%) +77k (+ 0.02%) 447,477k 447,544k
Parse Time 1.83s (± 0.63%) 1.82s (± 0.41%) -0.01s (- 0.55%) 1.81s 1.84s
Bind Time 0.68s (± 0.77%) 0.68s (± 1.03%) +0.00s (+ 0.29%) 0.67s 0.70s
Check Time 13.06s (± 0.61%) 13.03s (± 1.10%) -0.03s (- 0.25%) 12.85s 13.54s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.57s (± 0.51%) 15.53s (± 0.90%) -0.04s (- 0.28%) 15.36s 16.03s
xstate - node (v14.15.1, x64)
Memory used 533,816k (± 0.01%) 533,828k (± 0.01%) +12k (+ 0.00%) 533,761k 533,880k
Parse Time 2.56s (± 0.29%) 2.56s (± 0.50%) +0.00s (+ 0.08%) 2.54s 2.59s
Bind Time 1.16s (± 0.86%) 1.14s (± 0.72%) -0.01s (- 1.12%) 1.13s 1.16s
Check Time 1.55s (± 0.68%) 1.55s (± 0.50%) -0.00s (- 0.19%) 1.54s 1.57s
Emit Time 0.07s (± 0.00%) 0.07s (± 0.00%) 0.00s ( 0.00%) 0.07s 0.07s
Total Time 5.35s (± 0.29%) 5.33s (± 0.40%) -0.02s (- 0.30%) 5.27s 5.37s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-210-generic
Architecturex64
Available Memory16 GB
Available Memory4 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v10.16.3, x64)
  • node (v12.1.0, x64)
  • node (v14.15.1, x64)
Scenarios
  • Angular - node (v10.16.3, x64)
  • Angular - node (v12.1.0, x64)
  • Angular - node (v14.15.1, x64)
  • Compiler-Unions - node (v10.16.3, x64)
  • Compiler-Unions - node (v12.1.0, x64)
  • Compiler-Unions - node (v14.15.1, x64)
  • Monaco - node (v10.16.3, x64)
  • Monaco - node (v12.1.0, x64)
  • Monaco - node (v14.15.1, x64)
  • TFS - node (v10.16.3, x64)
  • TFS - node (v12.1.0, x64)
  • TFS - node (v14.15.1, x64)
  • material-ui - node (v10.16.3, x64)
  • material-ui - node (v12.1.0, x64)
  • material-ui - node (v14.15.1, x64)
  • xstate - node (v10.16.3, x64)
  • xstate - node (v12.1.0, x64)
  • xstate - node (v14.15.1, x64)
Benchmark Name Iterations
Current 46490 10
Baseline main 10

Developer Information:

Download Benchmark

@andrewbranch andrewbranch merged commit 907fc72 into microsoft:main Oct 22, 2021
@andrewbranch andrewbranch deleted the bug/46024 branch October 22, 2021 23:09
mprobst pushed a commit to mprobst/TypeScript that referenced this pull request Jan 10, 2022
* Fix auto import crash on weird JS aliasing

* Comment up the weird test

* Fix setting members on union/intersection type, happens later
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Backlog Bug PRs that fix a backlog bug For Milestone Bug PRs that fix a bug with a specific milestone
Projects
None yet
3 participants