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

Cache accessibe symbol chains and serialized type parameter name generation #43973

Merged
merged 5 commits into from
May 12, 2021

Conversation

weswigham
Copy link
Member

@weswigham weswigham commented May 5, 2021

Which can improve declaration emit performance significantly in some edge cases. Together, these caches bring the example in the linked issue down from 20s to 5.5s on my machine, which is a pretty marked improvement.

Fixes #42937

@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels May 5, 2021
(context.typeParameterNamesByText || (context.typeParameterNamesByText = new Set())).add(result.escapedText as string);
// avoiding iterations of the above loop turns out to be worth it when `i` starts to get large, so we cache the max
// `i` we've used thus far, to save work later
(context.typeParameterNamesByTextNextNameCount ||= new Map()).set(rawtext, i);
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the "cache serialized type parameter name generation" part - this additional tiny bit of caching brought the runtime of the example down from 7s to 5.5s on my machine.

const firstRelevantLocation = forEachSymbolTableInScope(enclosingDeclaration, (_, __, node) => node);
const key = `${useOnlyExternalAliasing ? 0 : 1}|${firstRelevantLocation && getNodeId(firstRelevantLocation)}|${meaning}`;
if (cache.has(key)) {
return cache.get(key);
Copy link
Member Author

Choose a reason for hiding this comment

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

This cache could probably be better - intelligently sharing results for commonish-meanings and having a hierarchical cache both sound nice in theory, but are a pain to implement performantly (the last time I tried I ruined perf in the general case). This relatively simple cache was sufficient to bring the example runtime down from 20s to 7s on my machine, though is likely to only really effect really degenerate cases, like the one in the linked issue.

const preProgram = ts.length(rootFiles) < 100 ? ts.createProgram(rootFiles || [], { ...compilerOptions, configFile: compilerOptions.configFile, traceResolution: false }, host) : undefined;
// pre-emit/post-emit error comparison requires declaration emit twice, which can be slow. If it's unlikely to flag any error consistency issues
// and if the test is running `skipLibCheck` - an indicator that we want the tets to run quickly - skip the before/after error comparison, too
const skipErrorComparison = ts.length(rootFiles) >= 100 || (!!compilerOptions.skipLibCheck && !!compilerOptions.declaration);
Copy link
Member Author

Choose a reason for hiding this comment

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

Declaration emit for this test still takes 5s on my machine. getPreEmitDiagnostics invokes declaration emit to get declaration emit errors (for historical reasons they've been considered "preEmit" errors), meaning declaration emit had to run twice, so 10s. Single-threaded, this was fine, but in high resource contention scenarios (ie, runtests-parallel) this was long enough to stretch to 40s and timeout. So I added an opt-out case to the preEmit/preEmit-after-emit error consistency check to keep this test runtime low (so it could pass without a timeout when running in parallel, and probably on CI).

@@ -0,0 +1,34 @@
// @declaration: true
// @skipLibCheck: true
// @noTypesAndSymbols: true
Copy link
Member Author

Choose a reason for hiding this comment

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

And I've skipped the type/symbol baselines for this test, since they double again the test runtime (and also thus cause a timeout) by essentially invoking the same logic as declaration emit for no real additional gain (compared to the declaration emit we're already running).

@weswigham
Copy link
Member Author

@typescript-bot pack this
@typescript-bot perf test this ? I'm not sure this'll affect anything - I don't know if any of our perf tests do declaration emit.

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 5, 2021

Heya @weswigham, I've started to run the tarball bundle task on this PR at 0f4e922. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 5, 2021

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

Hey @weswigham, 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/102347/artifacts?artifactName=tgz&fileId=4FC06038ECBF0816C0876149F5C885ACAE6E577EDEF3DD5EE441B8330F64CAE102&fileName=/typescript-4.3.0-insiders.20210505.tgz"
    }
}

and then running npm install.

@@ -3935,12 +3935,12 @@ namespace ts {
return typeCopy;
}

function forEachSymbolTableInScope<T>(enclosingDeclaration: Node | undefined, callback: (symbolTable: SymbolTable) => T): T {
function forEachSymbolTableInScope<T>(enclosingDeclaration: Node | undefined, callback: (symbolTable: SymbolTable, ignoreQualification?: boolean, scopeNode?: Node) => T): T {
Copy link
Member

Choose a reason for hiding this comment

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

I dont see anywhere we are passing ignoreQualification true or false ?
Also can we make these parameter nonOptional but type | undefined instead to ensure every call back considers what needs to be passed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Inside this function, it's not; however the function we often pass as a callback uses it as a second parameter (and it's optional there) for its' other callsites, so this optional parameter is here so the callback parameter is compatible with both that usage and the node-finding usage.

@typescript-bot
Copy link
Collaborator

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

Here they are:

Comparison Report - master..43973

Metric master 43973 Delta Best Worst
Angular - node (v10.16.3, x64)
Memory used 344,651k (± 0.02%) 344,777k (± 0.02%) +125k (+ 0.04%) 344,586k 344,916k
Parse Time 1.91s (± 0.55%) 1.92s (± 0.60%) +0.00s (+ 0.21%) 1.90s 1.95s
Bind Time 0.84s (± 0.57%) 0.84s (± 0.77%) +0.01s (+ 0.60%) 0.83s 0.86s
Check Time 5.25s (± 0.47%) 5.24s (± 0.52%) -0.01s (- 0.13%) 5.17s 5.31s
Emit Time 5.89s (± 0.38%) 5.86s (± 0.54%) -0.03s (- 0.54%) 5.81s 5.94s
Total Time 13.89s (± 0.29%) 13.86s (± 0.43%) -0.03s (- 0.23%) 13.72s 14.00s
Compiler-Unions - node (v10.16.3, x64)
Memory used 200,759k (± 0.03%) 200,816k (± 0.12%) +57k (+ 0.03%) 199,959k 201,159k
Parse Time 0.79s (± 0.51%) 0.78s (± 0.46%) -0.01s (- 0.63%) 0.78s 0.79s
Bind Time 0.53s (± 1.27%) 0.52s (± 1.06%) -0.01s (- 0.95%) 0.51s 0.53s
Check Time 7.59s (± 0.57%) 7.58s (± 0.62%) -0.02s (- 0.21%) 7.50s 7.71s
Emit Time 2.51s (± 1.43%) 2.49s (± 1.23%) -0.03s (- 1.04%) 2.42s 2.55s
Total Time 11.42s (± 0.47%) 11.37s (± 0.47%) -0.05s (- 0.46%) 11.26s 11.49s
Monaco - node (v10.16.3, x64)
Memory used 341,715k (± 0.01%) 341,631k (± 0.02%) -83k (- 0.02%) 341,459k 341,779k
Parse Time 1.56s (± 0.50%) 1.56s (± 0.40%) +0.00s (+ 0.13%) 1.55s 1.58s
Bind Time 0.74s (± 0.78%) 0.74s (± 0.64%) 0.00s ( 0.00%) 0.73s 0.75s
Check Time 5.38s (± 0.34%) 5.38s (± 0.56%) 0.00s ( 0.00%) 5.32s 5.46s
Emit Time 3.02s (± 0.86%) 3.01s (± 0.60%) -0.01s (- 0.23%) 2.96s 3.05s
Total Time 10.70s (± 0.39%) 10.69s (± 0.22%) -0.01s (- 0.07%) 10.66s 10.76s
TFS - node (v10.16.3, x64)
Memory used 304,178k (± 0.03%) 304,225k (± 0.02%) +47k (+ 0.02%) 304,077k 304,345k
Parse Time 1.22s (± 0.55%) 1.21s (± 0.53%) -0.00s (- 0.41%) 1.20s 1.23s
Bind Time 0.71s (± 0.78%) 0.71s (± 0.78%) -0.00s (- 0.56%) 0.70s 0.72s
Check Time 4.79s (± 0.42%) 4.79s (± 0.50%) 0.00s ( 0.00%) 4.75s 4.85s
Emit Time 3.21s (± 1.33%) 3.18s (± 1.38%) -0.03s (- 0.87%) 3.10s 3.31s
Total Time 9.93s (± 0.53%) 9.90s (± 0.53%) -0.03s (- 0.29%) 9.80s 10.01s
material-ui - node (v10.16.3, x64)
Memory used 474,572k (± 0.02%) 474,796k (± 0.01%) +224k (+ 0.05%) 474,662k 474,922k
Parse Time 1.94s (± 0.79%) 1.96s (± 0.62%) +0.01s (+ 0.57%) 1.92s 1.98s
Bind Time 0.65s (± 1.23%) 0.65s (± 0.85%) 0.00s ( 0.00%) 0.64s 0.66s
Check Time 14.81s (± 0.66%) 14.31s (± 0.56%) 🟩-0.50s (- 3.40%) 14.15s 14.51s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 17.41s (± 0.63%) 16.92s (± 0.50%) -0.49s (- 2.82%) 16.74s 17.11s
Angular - node (v12.1.0, x64)
Memory used 322,324k (± 0.02%) 322,387k (± 0.02%) +63k (+ 0.02%) 322,292k 322,550k
Parse Time 1.91s (± 0.63%) 1.91s (± 0.75%) +0.00s (+ 0.21%) 1.89s 1.94s
Bind Time 0.82s (± 0.73%) 0.82s (± 0.92%) 0.00s ( 0.00%) 0.81s 0.85s
Check Time 5.17s (± 0.48%) 5.13s (± 0.49%) -0.04s (- 0.79%) 5.08s 5.17s
Emit Time 6.16s (± 0.82%) 6.10s (± 0.78%) -0.06s (- 0.94%) 6.01s 6.24s
Total Time 14.07s (± 0.49%) 13.97s (± 0.52%) -0.10s (- 0.70%) 13.81s 14.13s
Compiler-Unions - node (v12.1.0, x64)
Memory used 187,812k (± 0.14%) 187,867k (± 0.19%) +55k (+ 0.03%) 186,746k 188,524k
Parse Time 0.77s (± 0.62%) 0.77s (± 0.52%) -0.00s (- 0.52%) 0.76s 0.78s
Bind Time 0.53s (± 0.89%) 0.53s (± 0.76%) -0.00s (- 0.19%) 0.52s 0.54s
Check Time 7.04s (± 0.64%) 7.03s (± 0.78%) -0.01s (- 0.10%) 6.91s 7.17s
Emit Time 2.49s (± 1.00%) 2.48s (± 1.16%) -0.01s (- 0.56%) 2.41s 2.55s
Total Time 10.84s (± 0.63%) 10.81s (± 0.56%) -0.02s (- 0.22%) 10.66s 10.92s
Monaco - node (v12.1.0, x64)
Memory used 324,057k (± 0.02%) 324,068k (± 0.02%) +11k (+ 0.00%) 323,932k 324,182k
Parse Time 1.54s (± 0.71%) 1.54s (± 0.32%) -0.01s (- 0.39%) 1.53s 1.55s
Bind Time 0.72s (± 1.20%) 0.72s (± 0.66%) -0.01s (- 0.69%) 0.71s 0.73s
Check Time 5.20s (± 0.29%) 5.19s (± 0.37%) -0.01s (- 0.12%) 5.14s 5.24s
Emit Time 3.06s (± 0.70%) 3.07s (± 0.53%) +0.01s (+ 0.36%) 3.04s 3.13s
Total Time 10.52s (± 0.33%) 10.52s (± 0.33%) -0.01s (- 0.06%) 10.47s 10.63s
TFS - node (v12.1.0, x64)
Memory used 288,711k (± 0.01%) 288,748k (± 0.01%) +37k (+ 0.01%) 288,698k 288,873k
Parse Time 1.21s (± 0.78%) 1.21s (± 0.67%) -0.00s (- 0.00%) 1.20s 1.23s
Bind Time 0.70s (± 1.16%) 0.70s (± 0.86%) -0.01s (- 1.14%) 0.68s 0.71s
Check Time 4.70s (± 0.61%) 4.69s (± 0.35%) -0.01s (- 0.17%) 4.65s 4.73s
Emit Time 3.18s (± 1.55%) 3.20s (± 1.53%) +0.01s (+ 0.44%) 3.12s 3.35s
Total Time 9.80s (± 0.64%) 9.80s (± 0.48%) +0.00s (+ 0.02%) 9.71s 9.92s
material-ui - node (v12.1.0, x64)
Memory used 452,433k (± 0.05%) 452,693k (± 0.01%) +260k (+ 0.06%) 452,579k 452,766k
Parse Time 1.94s (± 0.38%) 1.95s (± 0.53%) +0.01s (+ 0.52%) 1.93s 1.97s
Bind Time 0.64s (± 0.63%) 0.64s (± 0.76%) +0.01s (+ 0.78%) 0.64s 0.66s
Check Time 13.30s (± 0.52%) 12.81s (± 0.67%) 🟩-0.49s (- 3.69%) 12.69s 13.01s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.88s (± 0.43%) 15.41s (± 0.58%) -0.47s (- 2.99%) 15.26s 15.62s
Angular - node (v14.15.1, x64)
Memory used 321,052k (± 0.01%) 320,996k (± 0.08%) -56k (- 0.02%) 319,982k 321,154k
Parse Time 1.90s (± 0.66%) 1.90s (± 0.68%) +0.00s (+ 0.11%) 1.88s 1.94s
Bind Time 0.87s (± 0.66%) 0.87s (± 0.77%) +0.00s (+ 0.34%) 0.86s 0.89s
Check Time 5.15s (± 0.44%) 5.17s (± 0.55%) +0.02s (+ 0.33%) 5.10s 5.23s
Emit Time 6.19s (± 0.64%) 6.21s (± 0.96%) +0.02s (+ 0.31%) 6.14s 6.40s
Total Time 14.11s (± 0.28%) 14.16s (± 0.63%) +0.05s (+ 0.33%) 14.01s 14.42s
Compiler-Unions - node (v14.15.1, x64)
Memory used 188,505k (± 0.64%) 188,276k (± 0.61%) -228k (- 0.12%) 186,964k 190,211k
Parse Time 0.80s (± 0.59%) 0.80s (± 0.65%) +0.00s (+ 0.12%) 0.79s 0.81s
Bind Time 0.55s (± 0.62%) 0.55s (± 0.90%) +0.00s (+ 0.36%) 0.55s 0.57s
Check Time 7.13s (± 0.47%) 7.13s (± 0.62%) -0.00s (- 0.01%) 7.05s 7.24s
Emit Time 2.49s (± 0.83%) 2.49s (± 0.70%) -0.00s (- 0.08%) 2.45s 2.52s
Total Time 10.98s (± 0.36%) 10.98s (± 0.53%) -0.00s (- 0.02%) 10.87s 11.12s
Monaco - node (v14.15.1, x64)
Memory used 323,144k (± 0.01%) 323,157k (± 0.01%) +13k (+ 0.00%) 323,121k 323,203k
Parse Time 1.57s (± 0.70%) 1.57s (± 0.55%) +0.00s (+ 0.06%) 1.55s 1.58s
Bind Time 0.75s (± 0.77%) 0.75s (± 0.64%) -0.00s (- 0.40%) 0.74s 0.76s
Check Time 5.19s (± 0.30%) 5.18s (± 0.46%) -0.01s (- 0.12%) 5.14s 5.25s
Emit Time 3.13s (± 0.67%) 3.12s (± 1.27%) -0.01s (- 0.29%) 3.07s 3.27s
Total Time 10.63s (± 0.23%) 10.62s (± 0.62%) -0.01s (- 0.12%) 10.55s 10.87s
TFS - node (v14.15.1, x64)
Memory used 287,663k (± 0.01%) 287,657k (± 0.01%) -6k (- 0.00%) 287,598k 287,703k
Parse Time 1.27s (± 1.48%) 1.27s (± 1.06%) +0.00s (+ 0.16%) 1.25s 1.30s
Bind Time 0.72s (± 1.17%) 0.72s (± 1.08%) -0.00s (- 0.28%) 0.71s 0.74s
Check Time 4.70s (± 0.38%) 4.71s (± 0.48%) +0.01s (+ 0.28%) 4.66s 4.77s
Emit Time 3.26s (± 0.40%) 3.29s (± 0.58%) +0.03s (+ 0.92%) 3.24s 3.34s
Total Time 9.95s (± 0.27%) 10.00s (± 0.26%) +0.04s (+ 0.44%) 9.93s 10.04s
material-ui - node (v14.15.1, x64)
Memory used 450,697k (± 0.00%) 450,806k (± 0.06%) +109k (+ 0.02%) 449,724k 450,996k
Parse Time 2.00s (± 0.62%) 1.99s (± 0.70%) -0.01s (- 0.50%) 1.97s 2.04s
Bind Time 0.70s (± 0.74%) 0.70s (± 0.80%) -0.00s (- 0.14%) 0.69s 0.71s
Check Time 13.61s (± 0.91%) 12.95s (± 0.75%) 🟩-0.66s (- 4.86%) 12.73s 13.14s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 16.31s (± 0.76%) 15.64s (± 0.63%) 🟩-0.67s (- 4.10%) 15.41s 15.83s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-206-generic
Architecturex64
Available Memory16 GB
Available Memory7 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)
Benchmark Name Iterations
Current 43973 10
Baseline master 10

Developer Information:

Download Benchmark

@weswigham
Copy link
Member Author

-3-5% check time in material-ui? Nice. I'm wondering what actually invoked symbol visibility logic without declaration emit, but am pleasantly surprised by the improvement.

@weswigham
Copy link
Member Author

@typescript-bot pack this
@typescript-bot perf test this

52499b1 added another layer of caching, this one within visitAndTransformType, which is the recursive guard function in typeToTypeNodeHelper. That was able to bring the runtime of the example down to 3.7s on my machine (from 5.15s on the prior commit - moving the truncation cutoff counter in the prior commit got a 0.35s improvement form the previously stated 5.5s time) which, percentage-wise, is another substantial improvement. And with that, the new test is no longer our longest running test when running in parallel on my machine (which was my goal), so at this point I'm probably going to call this PR complete, barring any requested changes (or anomalous results from the above requested perf run). If material-ui is any indication, these changes could have some pretty positive real world impacts.

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 7, 2021

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 7, 2021

Heya @weswigham, I've started to run the tarball bundle task on this PR at 909d519. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

Hey @weswigham, 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/102626/artifacts?artifactName=tgz&fileId=611964A99C9FF46B88F0F804710A13CF6EB1675346DA9A844777ACE54EF44DE702&fileName=/typescript-4.3.0-insiders.20210507.tgz"
    }
}

and then running npm install.

@typescript-bot
Copy link
Collaborator

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

Here they are:

Comparison Report - master..43973

Metric master 43973 Delta Best Worst
Angular - node (v10.16.3, x64)
Memory used 344,659k (± 0.02%) 344,945k (± 0.03%) +286k (+ 0.08%) 344,747k 345,165k
Parse Time 1.91s (± 0.43%) 1.91s (± 0.49%) -0.00s (- 0.26%) 1.89s 1.93s
Bind Time 0.84s (± 1.41%) 0.83s (± 0.60%) -0.01s (- 0.83%) 0.83s 0.85s
Check Time 5.23s (± 0.43%) 5.24s (± 0.32%) +0.01s (+ 0.25%) 5.20s 5.28s
Emit Time 5.59s (± 0.71%) 5.57s (± 0.71%) -0.01s (- 0.25%) 5.50s 5.70s
Total Time 13.57s (± 0.46%) 13.56s (± 0.37%) -0.01s (- 0.10%) 13.44s 13.71s
Compiler-Unions - node (v10.16.3, x64)
Memory used 200,287k (± 0.04%) 200,392k (± 0.04%) +105k (+ 0.05%) 200,246k 200,541k
Parse Time 0.78s (± 0.63%) 0.78s (± 0.61%) -0.00s (- 0.13%) 0.77s 0.79s
Bind Time 0.53s (± 1.10%) 0.53s (± 1.27%) 0.00s ( 0.00%) 0.51s 0.54s
Check Time 7.54s (± 0.57%) 7.51s (± 0.45%) -0.02s (- 0.33%) 7.44s 7.59s
Emit Time 2.45s (± 0.95%) 2.44s (± 1.58%) -0.01s (- 0.45%) 2.33s 2.51s
Total Time 11.30s (± 0.35%) 11.26s (± 0.42%) -0.03s (- 0.30%) 11.13s 11.35s
Monaco - node (v10.16.3, x64)
Memory used 341,646k (± 0.02%) 341,707k (± 0.03%) +61k (+ 0.02%) 341,512k 342,064k
Parse Time 1.55s (± 0.44%) 1.56s (± 0.26%) +0.01s (+ 0.45%) 1.55s 1.57s
Bind Time 0.74s (± 0.60%) 0.74s (± 0.67%) +0.01s (+ 0.95%) 0.73s 0.75s
Check Time 5.37s (± 0.30%) 5.38s (± 0.36%) +0.02s (+ 0.35%) 5.36s 5.44s
Emit Time 2.97s (± 0.90%) 2.96s (± 0.64%) -0.01s (- 0.24%) 2.92s 2.99s
Total Time 10.62s (± 0.37%) 10.65s (± 0.30%) +0.03s (+ 0.25%) 10.59s 10.73s
TFS - node (v10.16.3, x64)
Memory used 304,239k (± 0.04%) 304,191k (± 0.01%) -48k (- 0.02%) 304,126k 304,259k
Parse Time 1.21s (± 0.55%) 1.21s (± 0.43%) -0.00s (- 0.08%) 1.20s 1.22s
Bind Time 0.70s (± 0.68%) 0.70s (± 0.67%) -0.00s (- 0.43%) 0.69s 0.71s
Check Time 4.78s (± 0.28%) 4.84s (± 0.51%) +0.06s (+ 1.34%) 4.80s 4.91s
Emit Time 3.12s (± 1.32%) 3.14s (± 1.40%) +0.02s (+ 0.67%) 3.03s 3.25s
Total Time 9.80s (± 0.39%) 9.89s (± 0.58%) +0.09s (+ 0.90%) 9.74s 10.01s
material-ui - node (v10.16.3, x64)
Memory used 473,768k (± 0.02%) 474,007k (± 0.01%) +239k (+ 0.05%) 473,900k 474,126k
Parse Time 1.93s (± 0.57%) 1.94s (± 0.87%) +0.01s (+ 0.36%) 1.90s 1.98s
Bind Time 0.65s (± 0.80%) 0.65s (± 0.53%) -0.00s (- 0.61%) 0.64s 0.65s
Check Time 14.72s (± 0.45%) 14.19s (± 0.33%) 🟩-0.53s (- 3.57%) 14.12s 14.31s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 17.30s (± 0.39%) 16.79s (± 0.30%) -0.52s (- 2.98%) 16.69s 16.92s
Angular - node (v12.1.0, x64)
Memory used 322,303k (± 0.03%) 322,542k (± 0.02%) +239k (+ 0.07%) 322,379k 322,739k
Parse Time 1.90s (± 0.51%) 1.90s (± 0.70%) +0.00s (+ 0.11%) 1.87s 1.93s
Bind Time 0.83s (± 1.08%) 0.83s (± 0.88%) +0.00s (+ 0.24%) 0.81s 0.84s
Check Time 5.15s (± 0.23%) 5.14s (± 0.36%) -0.00s (- 0.06%) 5.10s 5.18s
Emit Time 5.76s (± 0.43%) 5.78s (± 0.50%) +0.02s (+ 0.40%) 5.72s 5.86s
Total Time 13.63s (± 0.21%) 13.65s (± 0.27%) +0.03s (+ 0.21%) 13.59s 13.73s
Compiler-Unions - node (v12.1.0, x64)
Memory used 187,548k (± 0.12%) 187,578k (± 0.16%) +30k (+ 0.02%) 186,801k 188,040k
Parse Time 0.78s (± 0.88%) 0.77s (± 0.44%) -0.01s (- 1.03%) 0.76s 0.77s
Bind Time 0.53s (± 1.05%) 0.53s (± 0.84%) +0.00s (+ 0.00%) 0.52s 0.54s
Check Time 7.00s (± 0.32%) 6.96s (± 0.44%) -0.03s (- 0.49%) 6.90s 7.05s
Emit Time 2.43s (± 1.39%) 2.41s (± 1.27%) -0.02s (- 0.70%) 2.37s 2.50s
Total Time 10.73s (± 0.50%) 10.67s (± 0.44%) -0.06s (- 0.56%) 10.57s 10.80s
Monaco - node (v12.1.0, x64)
Memory used 324,043k (± 0.02%) 324,065k (± 0.01%) +23k (+ 0.01%) 323,990k 324,139k
Parse Time 1.53s (± 0.59%) 1.54s (± 0.78%) +0.01s (+ 0.59%) 1.52s 1.57s
Bind Time 0.72s (± 0.69%) 0.72s (± 0.56%) +0.00s (+ 0.42%) 0.71s 0.73s
Check Time 5.19s (± 0.42%) 5.21s (± 0.45%) +0.02s (+ 0.33%) 5.15s 5.27s
Emit Time 3.01s (± 0.55%) 3.02s (± 0.60%) +0.01s (+ 0.23%) 2.99s 3.07s
Total Time 10.45s (± 0.33%) 10.48s (± 0.30%) +0.04s (+ 0.35%) 10.41s 10.55s
TFS - node (v12.1.0, x64)
Memory used 288,721k (± 0.02%) 288,727k (± 0.03%) +6k (+ 0.00%) 288,580k 288,989k
Parse Time 1.21s (± 0.87%) 1.21s (± 0.73%) +0.00s (+ 0.08%) 1.19s 1.24s
Bind Time 0.69s (± 0.83%) 0.69s (± 0.72%) +0.00s (+ 0.72%) 0.69s 0.71s
Check Time 4.69s (± 0.48%) 4.76s (± 0.46%) +0.07s (+ 1.58%) 4.70s 4.82s
Emit Time 3.11s (± 0.68%) 3.13s (± 0.78%) +0.02s (+ 0.48%) 3.08s 3.18s
Total Time 9.71s (± 0.36%) 9.80s (± 0.45%) +0.09s (+ 0.98%) 9.69s 9.89s
material-ui - node (v12.1.0, x64)
Memory used 451,725k (± 0.01%) 451,918k (± 0.01%) +193k (+ 0.04%) 451,784k 452,018k
Parse Time 1.95s (± 0.52%) 1.95s (± 0.38%) -0.00s (- 0.10%) 1.93s 1.97s
Bind Time 0.64s (± 0.70%) 0.64s (± 0.81%) +0.00s (+ 0.47%) 0.63s 0.66s
Check Time 13.24s (± 0.43%) 12.79s (± 0.37%) 🟩-0.45s (- 3.40%) 12.69s 12.94s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.83s (± 0.34%) 15.38s (± 0.30%) -0.45s (- 2.84%) 15.30s 15.53s
Angular - node (v14.15.1, x64)
Memory used 320,998k (± 0.01%) 321,288k (± 0.00%) +291k (+ 0.09%) 321,239k 321,309k
Parse Time 1.89s (± 0.34%) 1.90s (± 0.58%) +0.01s (+ 0.63%) 1.88s 1.93s
Bind Time 0.87s (± 0.54%) 0.87s (± 0.71%) +0.00s (+ 0.11%) 0.86s 0.89s
Check Time 5.15s (± 0.32%) 5.15s (± 0.39%) +0.01s (+ 0.14%) 5.11s 5.20s
Emit Time 5.81s (± 0.69%) 5.84s (± 0.68%) +0.02s (+ 0.38%) 5.74s 5.92s
Total Time 13.72s (± 0.40%) 13.77s (± 0.37%) +0.04s (+ 0.30%) 13.64s 13.90s
Compiler-Unions - node (v14.15.1, x64)
Memory used 187,703k (± 0.62%) 188,732k (± 0.57%) +1,029k (+ 0.55%) 186,473k 189,743k
Parse Time 0.80s (± 0.59%) 0.80s (± 0.87%) +0.00s (+ 0.13%) 0.79s 0.82s
Bind Time 0.55s (± 0.66%) 0.56s (± 0.61%) +0.00s (+ 0.54%) 0.55s 0.56s
Check Time 7.11s (± 0.58%) 7.13s (± 0.37%) +0.01s (+ 0.18%) 7.07s 7.18s
Emit Time 2.44s (± 1.29%) 2.44s (± 0.95%) -0.00s (- 0.00%) 2.40s 2.49s
Total Time 10.90s (± 0.45%) 10.92s (± 0.29%) +0.02s (+ 0.18%) 10.86s 10.98s
Monaco - node (v14.15.1, x64)
Memory used 323,119k (± 0.00%) 323,127k (± 0.01%) +8k (+ 0.00%) 323,085k 323,164k
Parse Time 1.57s (± 0.59%) 1.56s (± 0.43%) -0.00s (- 0.32%) 1.55s 1.58s
Bind Time 0.75s (± 1.26%) 0.74s (± 0.66%) -0.00s (- 0.40%) 0.73s 0.75s
Check Time 5.15s (± 0.43%) 5.20s (± 0.68%) +0.05s (+ 0.89%) 5.15s 5.30s
Emit Time 3.07s (± 1.31%) 3.07s (± 0.60%) -0.00s (- 0.13%) 3.03s 3.10s
Total Time 10.54s (± 0.37%) 10.58s (± 0.43%) +0.04s (+ 0.34%) 10.49s 10.69s
TFS - node (v14.15.1, x64)
Memory used 287,648k (± 0.00%) 287,652k (± 0.00%) +4k (+ 0.00%) 287,634k 287,676k
Parse Time 1.26s (± 1.09%) 1.26s (± 1.19%) +0.00s (+ 0.08%) 1.23s 1.29s
Bind Time 0.71s (± 0.56%) 0.71s (± 1.06%) +0.00s (+ 0.42%) 0.70s 0.74s
Check Time 4.71s (± 0.46%) 4.80s (± 0.40%) +0.09s (+ 1.98%) 4.76s 4.84s
Emit Time 3.21s (± 0.56%) 3.21s (± 0.99%) +0.00s (+ 0.03%) 3.16s 3.32s
Total Time 9.88s (± 0.24%) 9.98s (± 0.33%) +0.10s (+ 1.03%) 9.94s 10.10s
material-ui - node (v14.15.1, x64)
Memory used 449,760k (± 0.07%) 450,180k (± 0.01%) +420k (+ 0.09%) 450,046k 450,294k
Parse Time 1.98s (± 0.80%) 1.98s (± 0.38%) -0.01s (- 0.35%) 1.96s 1.99s
Bind Time 0.69s (± 0.52%) 0.70s (± 0.68%) +0.00s (+ 0.43%) 0.69s 0.71s
Check Time 13.52s (± 0.79%) 12.92s (± 0.40%) 🟩-0.60s (- 4.42%) 12.82s 13.01s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 16.20s (± 0.66%) 15.59s (± 0.34%) 🟩-0.61s (- 3.74%) 15.49s 15.70s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-206-generic
Architecturex64
Available Memory16 GB
Available Memory6 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)
Benchmark Name Iterations
Current 43973 10
Baseline master 10

Developer Information:

Download Benchmark

Copy link
Member

@andrewbranch andrewbranch left a comment

Choose a reason for hiding this comment

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

Interestingly enough, this PR does not fix #43529, and #43733 does not fix #43529, but when combined, they do fix #43529. Probably the caching you added to visitAndTransformType combined with my wrapping of conditional type serialization into that same function.

@@ -4479,7 +4489,7 @@ namespace ts {
enclosingDeclaration,
flags: flags || NodeBuilderFlags.None,
// If no full tracker is provided, fake up a dummy one with a basic limited-functionality moduleResolverHost
tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: noop, moduleResolverHost: flags! & NodeBuilderFlags.DoNotIncludeSymbolChain ? {
tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: () => false, moduleResolverHost: flags! & NodeBuilderFlags.DoNotIncludeSymbolChain ? {
Copy link
Member

Choose a reason for hiding this comment

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

There exists a ts.returnFalse 🙃

Copy link
Member Author

Choose a reason for hiding this comment

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

Eh, while I understand we use noop to reduce memory load, this fallback tracker (along with the other host objects I adjusted) is constructed infrequently enough that it doesn't really matter, I think.

@weswigham weswigham merged commit f7a97b7 into microsoft:master May 12, 2021
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
None yet
Development

Successfully merging this pull request may close these issues.

Extra long code compilation whitch finished with "memory leak" report after ~20min
5 participants