Skip to content

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

Merged
Wesley Wigham (weswigham) merged 5 commits into
microsoft:masterfrom
weswigham:declaration-emit-performance
May 12, 2021
Merged

Cache accessibe symbol chains and serialized type parameter name generation#43973
Wesley Wigham (weswigham) merged 5 commits into
microsoft:masterfrom
weswigham:declaration-emit-performance

Conversation

@weswigham

@weswighamWesley Wigham (weswigham) commented May 5, 2021

Copy link
Copy Markdown
Member

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

(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
Copy Markdown
MemberAuthor

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
Copy Markdown
MemberAuthor

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
Copy Markdown
MemberAuthor

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
Copy Markdown
MemberAuthor

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
Copy Markdown
MemberAuthor

TypeScript Bot (@typescript-bot) pack this
TypeScript Bot (@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

TypeScript Bot (typescript-bot) commented May 5, 2021

Copy link
Copy Markdown
Contributor

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

@typescript-bot

TypeScript Bot (typescript-bot) commented May 5, 2021

Copy link
Copy Markdown
Contributor

Heya Wesley Wigham (@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
Copy Markdown
Contributor

Hey Wesley Wigham (@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.

Comment threadsrc/compiler/checker.ts Outdated
}

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
Copy Markdown
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
Copy Markdown
MemberAuthor

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
Copy Markdown
Contributor

Wesley Wigham (@weswigham)
The results of the perf run you requested are in!

Here they are:

Comparison Report - master..43973

Metricmaster43973DeltaBestWorst
Angular - node (v10.16.3, x64)
Memory used344,651k (± 0.02%)344,777k (± 0.02%)+125k (+ 0.04%)344,586k344,916k
Parse Time1.91s (± 0.55%)1.92s (± 0.60%)+0.00s (+ 0.21%)1.90s1.95s
Bind Time0.84s (± 0.57%)0.84s (± 0.77%)+0.01s (+ 0.60%)0.83s0.86s
Check Time5.25s (± 0.47%)5.24s (± 0.52%)-0.01s (- 0.13%)5.17s5.31s
Emit Time5.89s (± 0.38%)5.86s (± 0.54%)-0.03s (- 0.54%)5.81s5.94s
Total Time13.89s (± 0.29%)13.86s (± 0.43%)-0.03s (- 0.23%)13.72s14.00s
Compiler-Unions - node (v10.16.3, x64)
Memory used200,759k (± 0.03%)200,816k (± 0.12%)+57k (+ 0.03%)199,959k201,159k
Parse Time0.79s (± 0.51%)0.78s (± 0.46%)-0.01s (- 0.63%)0.78s0.79s
Bind Time0.53s (± 1.27%)0.52s (± 1.06%)-0.01s (- 0.95%)0.51s0.53s
Check Time7.59s (± 0.57%)7.58s (± 0.62%)-0.02s (- 0.21%)7.50s7.71s
Emit Time2.51s (± 1.43%)2.49s (± 1.23%)-0.03s (- 1.04%)2.42s2.55s
Total Time11.42s (± 0.47%)11.37s (± 0.47%)-0.05s (- 0.46%)11.26s11.49s
Monaco - node (v10.16.3, x64)
Memory used341,715k (± 0.01%)341,631k (± 0.02%)-83k (- 0.02%)341,459k341,779k
Parse Time1.56s (± 0.50%)1.56s (± 0.40%)+0.00s (+ 0.13%)1.55s1.58s
Bind Time0.74s (± 0.78%)0.74s (± 0.64%)0.00s ( 0.00%)0.73s0.75s
Check Time5.38s (± 0.34%)5.38s (± 0.56%)0.00s ( 0.00%)5.32s5.46s
Emit Time3.02s (± 0.86%)3.01s (± 0.60%)-0.01s (- 0.23%)2.96s3.05s
Total Time10.70s (± 0.39%)10.69s (± 0.22%)-0.01s (- 0.07%)10.66s10.76s
TFS - node (v10.16.3, x64)
Memory used304,178k (± 0.03%)304,225k (± 0.02%)+47k (+ 0.02%)304,077k304,345k
Parse Time1.22s (± 0.55%)1.21s (± 0.53%)-0.00s (- 0.41%)1.20s1.23s
Bind Time0.71s (± 0.78%)0.71s (± 0.78%)-0.00s (- 0.56%)0.70s0.72s
Check Time4.79s (± 0.42%)4.79s (± 0.50%)0.00s ( 0.00%)4.75s4.85s
Emit Time3.21s (± 1.33%)3.18s (± 1.38%)-0.03s (- 0.87%)3.10s3.31s
Total Time9.93s (± 0.53%)9.90s (± 0.53%)-0.03s (- 0.29%)9.80s10.01s
material-ui - node (v10.16.3, x64)
Memory used474,572k (± 0.02%)474,796k (± 0.01%)+224k (+ 0.05%)474,662k474,922k
Parse Time1.94s (± 0.79%)1.96s (± 0.62%)+0.01s (+ 0.57%)1.92s1.98s
Bind Time0.65s (± 1.23%)0.65s (± 0.85%)0.00s ( 0.00%)0.64s0.66s
Check Time14.81s (± 0.66%)14.31s (± 0.56%)🟩-0.50s (- 3.40%)14.15s14.51s
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)0.00s ( NaN%)0.00s0.00s
Total Time17.41s (± 0.63%)16.92s (± 0.50%)-0.49s (- 2.82%)16.74s17.11s
Angular - node (v12.1.0, x64)
Memory used322,324k (± 0.02%)322,387k (± 0.02%)+63k (+ 0.02%)322,292k322,550k
Parse Time1.91s (± 0.63%)1.91s (± 0.75%)+0.00s (+ 0.21%)1.89s1.94s
Bind Time0.82s (± 0.73%)0.82s (± 0.92%)0.00s ( 0.00%)0.81s0.85s
Check Time5.17s (± 0.48%)5.13s (± 0.49%)-0.04s (- 0.79%)5.08s5.17s
Emit Time6.16s (± 0.82%)6.10s (± 0.78%)-0.06s (- 0.94%)6.01s6.24s
Total Time14.07s (± 0.49%)13.97s (± 0.52%)-0.10s (- 0.70%)13.81s14.13s
Compiler-Unions - node (v12.1.0, x64)
Memory used187,812k (± 0.14%)187,867k (± 0.19%)+55k (+ 0.03%)186,746k188,524k
Parse Time0.77s (± 0.62%)0.77s (± 0.52%)-0.00s (- 0.52%)0.76s0.78s
Bind Time0.53s (± 0.89%)0.53s (± 0.76%)-0.00s (- 0.19%)0.52s0.54s
Check Time7.04s (± 0.64%)7.03s (± 0.78%)-0.01s (- 0.10%)6.91s7.17s
Emit Time2.49s (± 1.00%)2.48s (± 1.16%)-0.01s (- 0.56%)2.41s2.55s
Total Time10.84s (± 0.63%)10.81s (± 0.56%)-0.02s (- 0.22%)10.66s10.92s
Monaco - node (v12.1.0, x64)
Memory used324,057k (± 0.02%)324,068k (± 0.02%)+11k (+ 0.00%)323,932k324,182k
Parse Time1.54s (± 0.71%)1.54s (± 0.32%)-0.01s (- 0.39%)1.53s1.55s
Bind Time0.72s (± 1.20%)0.72s (± 0.66%)-0.01s (- 0.69%)0.71s0.73s
Check Time5.20s (± 0.29%)5.19s (± 0.37%)-0.01s (- 0.12%)5.14s5.24s
Emit Time3.06s (± 0.70%)3.07s (± 0.53%)+0.01s (+ 0.36%)3.04s3.13s
Total Time10.52s (± 0.33%)10.52s (± 0.33%)-0.01s (- 0.06%)10.47s10.63s
TFS - node (v12.1.0, x64)
Memory used288,711k (± 0.01%)288,748k (± 0.01%)+37k (+ 0.01%)288,698k288,873k
Parse Time1.21s (± 0.78%)1.21s (± 0.67%)-0.00s (- 0.00%)1.20s1.23s
Bind Time0.70s (± 1.16%)0.70s (± 0.86%)-0.01s (- 1.14%)0.68s0.71s
Check Time4.70s (± 0.61%)4.69s (± 0.35%)-0.01s (- 0.17%)4.65s4.73s
Emit Time3.18s (± 1.55%)3.20s (± 1.53%)+0.01s (+ 0.44%)3.12s3.35s
Total Time9.80s (± 0.64%)9.80s (± 0.48%)+0.00s (+ 0.02%)9.71s9.92s
material-ui - node (v12.1.0, x64)
Memory used452,433k (± 0.05%)452,693k (± 0.01%)+260k (+ 0.06%)452,579k452,766k
Parse Time1.94s (± 0.38%)1.95s (± 0.53%)+0.01s (+ 0.52%)1.93s1.97s
Bind Time0.64s (± 0.63%)0.64s (± 0.76%)+0.01s (+ 0.78%)0.64s0.66s
Check Time13.30s (± 0.52%)12.81s (± 0.67%)🟩-0.49s (- 3.69%)12.69s13.01s
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)0.00s ( NaN%)0.00s0.00s
Total Time15.88s (± 0.43%)15.41s (± 0.58%)-0.47s (- 2.99%)15.26s15.62s
Angular - node (v14.15.1, x64)
Memory used321,052k (± 0.01%)320,996k (± 0.08%)-56k (- 0.02%)319,982k321,154k
Parse Time1.90s (± 0.66%)1.90s (± 0.68%)+0.00s (+ 0.11%)1.88s1.94s
Bind Time0.87s (± 0.66%)0.87s (± 0.77%)+0.00s (+ 0.34%)0.86s0.89s
Check Time5.15s (± 0.44%)5.17s (± 0.55%)+0.02s (+ 0.33%)5.10s5.23s
Emit Time6.19s (± 0.64%)6.21s (± 0.96%)+0.02s (+ 0.31%)6.14s6.40s
Total Time14.11s (± 0.28%)14.16s (± 0.63%)+0.05s (+ 0.33%)14.01s14.42s
Compiler-Unions - node (v14.15.1, x64)
Memory used188,505k (± 0.64%)188,276k (± 0.61%)-228k (- 0.12%)186,964k190,211k
Parse Time0.80s (± 0.59%)0.80s (± 0.65%)+0.00s (+ 0.12%)0.79s0.81s
Bind Time0.55s (± 0.62%)0.55s (± 0.90%)+0.00s (+ 0.36%)0.55s0.57s
Check Time7.13s (± 0.47%)7.13s (± 0.62%)-0.00s (- 0.01%)7.05s7.24s
Emit Time2.49s (± 0.83%)2.49s (± 0.70%)-0.00s (- 0.08%)2.45s2.52s
Total Time10.98s (± 0.36%)10.98s (± 0.53%)-0.00s (- 0.02%)10.87s11.12s
Monaco - node (v14.15.1, x64)
Memory used323,144k (± 0.01%)323,157k (± 0.01%)+13k (+ 0.00%)323,121k323,203k
Parse Time1.57s (± 0.70%)1.57s (± 0.55%)+0.00s (+ 0.06%)1.55s1.58s
Bind Time0.75s (± 0.77%)0.75s (± 0.64%)-0.00s (- 0.40%)0.74s0.76s
Check Time5.19s (± 0.30%)5.18s (± 0.46%)-0.01s (- 0.12%)5.14s5.25s
Emit Time3.13s (± 0.67%)3.12s (± 1.27%)-0.01s (- 0.29%)3.07s3.27s
Total Time10.63s (± 0.23%)10.62s (± 0.62%)-0.01s (- 0.12%)10.55s10.87s
TFS - node (v14.15.1, x64)
Memory used287,663k (± 0.01%)287,657k (± 0.01%)-6k (- 0.00%)287,598k287,703k
Parse Time1.27s (± 1.48%)1.27s (± 1.06%)+0.00s (+ 0.16%)1.25s1.30s
Bind Time0.72s (± 1.17%)0.72s (± 1.08%)-0.00s (- 0.28%)0.71s0.74s
Check Time4.70s (± 0.38%)4.71s (± 0.48%)+0.01s (+ 0.28%)4.66s4.77s
Emit Time3.26s (± 0.40%)3.29s (± 0.58%)+0.03s (+ 0.92%)3.24s3.34s
Total Time9.95s (± 0.27%)10.00s (± 0.26%)+0.04s (+ 0.44%)9.93s10.04s
material-ui - node (v14.15.1, x64)
Memory used450,697k (± 0.00%)450,806k (± 0.06%)+109k (+ 0.02%)449,724k450,996k
Parse Time2.00s (± 0.62%)1.99s (± 0.70%)-0.01s (- 0.50%)1.97s2.04s
Bind Time0.70s (± 0.74%)0.70s (± 0.80%)-0.00s (- 0.14%)0.69s0.71s
Check Time13.61s (± 0.91%)12.95s (± 0.75%)🟩-0.66s (- 4.86%)12.73s13.14s
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)0.00s ( NaN%)0.00s0.00s
Total Time16.31s (± 0.76%)15.64s (± 0.63%)🟩-0.67s (- 4.10%)15.41s15.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)
BenchmarkNameIterations
Current4397310
Baselinemaster10

Developer Information:

Download Benchmark

@weswigham

Copy link
Copy Markdown
MemberAuthor

-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.

Comment threadsrc/compiler/checker.ts
Comment threadsrc/compiler/checker.ts Outdated
@weswigham

Copy link
Copy Markdown
MemberAuthor

TypeScript Bot (@typescript-bot) pack this
TypeScript Bot (@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

TypeScript Bot (typescript-bot) commented May 7, 2021

Copy link
Copy Markdown
Contributor

Heya Wesley Wigham (@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

TypeScript Bot (typescript-bot) commented May 7, 2021

Copy link
Copy Markdown
Contributor

Heya Wesley Wigham (@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
Copy Markdown
Contributor

Hey Wesley Wigham (@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
Copy Markdown
Contributor

Wesley Wigham (@weswigham)
The results of the perf run you requested are in!

Here they are:

Comparison Report - master..43973

Metricmaster43973DeltaBestWorst
Angular - node (v10.16.3, x64)
Memory used344,659k (± 0.02%)344,945k (± 0.03%)+286k (+ 0.08%)344,747k345,165k
Parse Time1.91s (± 0.43%)1.91s (± 0.49%)-0.00s (- 0.26%)1.89s1.93s
Bind Time0.84s (± 1.41%)0.83s (± 0.60%)-0.01s (- 0.83%)0.83s0.85s
Check Time5.23s (± 0.43%)5.24s (± 0.32%)+0.01s (+ 0.25%)5.20s5.28s
Emit Time5.59s (± 0.71%)5.57s (± 0.71%)-0.01s (- 0.25%)5.50s5.70s
Total Time13.57s (± 0.46%)13.56s (± 0.37%)-0.01s (- 0.10%)13.44s13.71s
Compiler-Unions - node (v10.16.3, x64)
Memory used200,287k (± 0.04%)200,392k (± 0.04%)+105k (+ 0.05%)200,246k200,541k
Parse Time0.78s (± 0.63%)0.78s (± 0.61%)-0.00s (- 0.13%)0.77s0.79s
Bind Time0.53s (± 1.10%)0.53s (± 1.27%)0.00s ( 0.00%)0.51s0.54s
Check Time7.54s (± 0.57%)7.51s (± 0.45%)-0.02s (- 0.33%)7.44s7.59s
Emit Time2.45s (± 0.95%)2.44s (± 1.58%)-0.01s (- 0.45%)2.33s2.51s
Total Time11.30s (± 0.35%)11.26s (± 0.42%)-0.03s (- 0.30%)11.13s11.35s
Monaco - node (v10.16.3, x64)
Memory used341,646k (± 0.02%)341,707k (± 0.03%)+61k (+ 0.02%)341,512k342,064k
Parse Time1.55s (± 0.44%)1.56s (± 0.26%)+0.01s (+ 0.45%)1.55s1.57s
Bind Time0.74s (± 0.60%)0.74s (± 0.67%)+0.01s (+ 0.95%)0.73s0.75s
Check Time5.37s (± 0.30%)5.38s (± 0.36%)+0.02s (+ 0.35%)5.36s5.44s
Emit Time2.97s (± 0.90%)2.96s (± 0.64%)-0.01s (- 0.24%)2.92s2.99s
Total Time10.62s (± 0.37%)10.65s (± 0.30%)+0.03s (+ 0.25%)10.59s10.73s
TFS - node (v10.16.3, x64)
Memory used304,239k (± 0.04%)304,191k (± 0.01%)-48k (- 0.02%)304,126k304,259k
Parse Time1.21s (± 0.55%)1.21s (± 0.43%)-0.00s (- 0.08%)1.20s1.22s
Bind Time0.70s (± 0.68%)0.70s (± 0.67%)-0.00s (- 0.43%)0.69s0.71s
Check Time4.78s (± 0.28%)4.84s (± 0.51%)+0.06s (+ 1.34%)4.80s4.91s
Emit Time3.12s (± 1.32%)3.14s (± 1.40%)+0.02s (+ 0.67%)3.03s3.25s
Total Time9.80s (± 0.39%)9.89s (± 0.58%)+0.09s (+ 0.90%)9.74s10.01s
material-ui - node (v10.16.3, x64)
Memory used473,768k (± 0.02%)474,007k (± 0.01%)+239k (+ 0.05%)473,900k474,126k
Parse Time1.93s (± 0.57%)1.94s (± 0.87%)+0.01s (+ 0.36%)1.90s1.98s
Bind Time0.65s (± 0.80%)0.65s (± 0.53%)-0.00s (- 0.61%)0.64s0.65s
Check Time14.72s (± 0.45%)14.19s (± 0.33%)🟩-0.53s (- 3.57%)14.12s14.31s
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)0.00s ( NaN%)0.00s0.00s
Total Time17.30s (± 0.39%)16.79s (± 0.30%)-0.52s (- 2.98%)16.69s16.92s
Angular - node (v12.1.0, x64)
Memory used322,303k (± 0.03%)322,542k (± 0.02%)+239k (+ 0.07%)322,379k322,739k
Parse Time1.90s (± 0.51%)1.90s (± 0.70%)+0.00s (+ 0.11%)1.87s1.93s
Bind Time0.83s (± 1.08%)0.83s (± 0.88%)+0.00s (+ 0.24%)0.81s0.84s
Check Time5.15s (± 0.23%)5.14s (± 0.36%)-0.00s (- 0.06%)5.10s5.18s
Emit Time5.76s (± 0.43%)5.78s (± 0.50%)+0.02s (+ 0.40%)5.72s5.86s
Total Time13.63s (± 0.21%)13.65s (± 0.27%)+0.03s (+ 0.21%)13.59s13.73s
Compiler-Unions - node (v12.1.0, x64)
Memory used187,548k (± 0.12%)187,578k (± 0.16%)+30k (+ 0.02%)186,801k188,040k
Parse Time0.78s (± 0.88%)0.77s (± 0.44%)-0.01s (- 1.03%)0.76s0.77s
Bind Time0.53s (± 1.05%)0.53s (± 0.84%)+0.00s (+ 0.00%)0.52s0.54s
Check Time7.00s (± 0.32%)6.96s (± 0.44%)-0.03s (- 0.49%)6.90s7.05s
Emit Time2.43s (± 1.39%)2.41s (± 1.27%)-0.02s (- 0.70%)2.37s2.50s
Total Time10.73s (± 0.50%)10.67s (± 0.44%)-0.06s (- 0.56%)10.57s10.80s
Monaco - node (v12.1.0, x64)
Memory used324,043k (± 0.02%)324,065k (± 0.01%)+23k (+ 0.01%)323,990k324,139k
Parse Time1.53s (± 0.59%)1.54s (± 0.78%)+0.01s (+ 0.59%)1.52s1.57s
Bind Time0.72s (± 0.69%)0.72s (± 0.56%)+0.00s (+ 0.42%)0.71s0.73s
Check Time5.19s (± 0.42%)5.21s (± 0.45%)+0.02s (+ 0.33%)5.15s5.27s
Emit Time3.01s (± 0.55%)3.02s (± 0.60%)+0.01s (+ 0.23%)2.99s3.07s
Total Time10.45s (± 0.33%)10.48s (± 0.30%)+0.04s (+ 0.35%)10.41s10.55s
TFS - node (v12.1.0, x64)
Memory used288,721k (± 0.02%)288,727k (± 0.03%)+6k (+ 0.00%)288,580k288,989k
Parse Time1.21s (± 0.87%)1.21s (± 0.73%)+0.00s (+ 0.08%)1.19s1.24s
Bind Time0.69s (± 0.83%)0.69s (± 0.72%)+0.00s (+ 0.72%)0.69s0.71s
Check Time4.69s (± 0.48%)4.76s (± 0.46%)+0.07s (+ 1.58%)4.70s4.82s
Emit Time3.11s (± 0.68%)3.13s (± 0.78%)+0.02s (+ 0.48%)3.08s3.18s
Total Time9.71s (± 0.36%)9.80s (± 0.45%)+0.09s (+ 0.98%)9.69s9.89s
material-ui - node (v12.1.0, x64)
Memory used451,725k (± 0.01%)451,918k (± 0.01%)+193k (+ 0.04%)451,784k452,018k
Parse Time1.95s (± 0.52%)1.95s (± 0.38%)-0.00s (- 0.10%)1.93s1.97s
Bind Time0.64s (± 0.70%)0.64s (± 0.81%)+0.00s (+ 0.47%)0.63s0.66s
Check Time13.24s (± 0.43%)12.79s (± 0.37%)🟩-0.45s (- 3.40%)12.69s12.94s
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)0.00s ( NaN%)0.00s0.00s
Total Time15.83s (± 0.34%)15.38s (± 0.30%)-0.45s (- 2.84%)15.30s15.53s
Angular - node (v14.15.1, x64)
Memory used320,998k (± 0.01%)321,288k (± 0.00%)+291k (+ 0.09%)321,239k321,309k
Parse Time1.89s (± 0.34%)1.90s (± 0.58%)+0.01s (+ 0.63%)1.88s1.93s
Bind Time0.87s (± 0.54%)0.87s (± 0.71%)+0.00s (+ 0.11%)0.86s0.89s
Check Time5.15s (± 0.32%)5.15s (± 0.39%)+0.01s (+ 0.14%)5.11s5.20s
Emit Time5.81s (± 0.69%)5.84s (± 0.68%)+0.02s (+ 0.38%)5.74s5.92s
Total Time13.72s (± 0.40%)13.77s (± 0.37%)+0.04s (+ 0.30%)13.64s13.90s
Compiler-Unions - node (v14.15.1, x64)
Memory used187,703k (± 0.62%)188,732k (± 0.57%)+1,029k (+ 0.55%)186,473k189,743k
Parse Time0.80s (± 0.59%)0.80s (± 0.87%)+0.00s (+ 0.13%)0.79s0.82s
Bind Time0.55s (± 0.66%)0.56s (± 0.61%)+0.00s (+ 0.54%)0.55s0.56s
Check Time7.11s (± 0.58%)7.13s (± 0.37%)+0.01s (+ 0.18%)7.07s7.18s
Emit Time2.44s (± 1.29%)2.44s (± 0.95%)-0.00s (- 0.00%)2.40s2.49s
Total Time10.90s (± 0.45%)10.92s (± 0.29%)+0.02s (+ 0.18%)10.86s10.98s
Monaco - node (v14.15.1, x64)
Memory used323,119k (± 0.00%)323,127k (± 0.01%)+8k (+ 0.00%)323,085k323,164k
Parse Time1.57s (± 0.59%)1.56s (± 0.43%)-0.00s (- 0.32%)1.55s1.58s
Bind Time0.75s (± 1.26%)0.74s (± 0.66%)-0.00s (- 0.40%)0.73s0.75s
Check Time5.15s (± 0.43%)5.20s (± 0.68%)+0.05s (+ 0.89%)5.15s5.30s
Emit Time3.07s (± 1.31%)3.07s (± 0.60%)-0.00s (- 0.13%)3.03s3.10s
Total Time10.54s (± 0.37%)10.58s (± 0.43%)+0.04s (+ 0.34%)10.49s10.69s
TFS - node (v14.15.1, x64)
Memory used287,648k (± 0.00%)287,652k (± 0.00%)+4k (+ 0.00%)287,634k287,676k
Parse Time1.26s (± 1.09%)1.26s (± 1.19%)+0.00s (+ 0.08%)1.23s1.29s
Bind Time0.71s (± 0.56%)0.71s (± 1.06%)+0.00s (+ 0.42%)0.70s0.74s
Check Time4.71s (± 0.46%)4.80s (± 0.40%)+0.09s (+ 1.98%)4.76s4.84s
Emit Time3.21s (± 0.56%)3.21s (± 0.99%)+0.00s (+ 0.03%)3.16s3.32s
Total Time9.88s (± 0.24%)9.98s (± 0.33%)+0.10s (+ 1.03%)9.94s10.10s
material-ui - node (v14.15.1, x64)
Memory used449,760k (± 0.07%)450,180k (± 0.01%)+420k (+ 0.09%)450,046k450,294k
Parse Time1.98s (± 0.80%)1.98s (± 0.38%)-0.01s (- 0.35%)1.96s1.99s
Bind Time0.69s (± 0.52%)0.70s (± 0.68%)+0.00s (+ 0.43%)0.69s0.71s
Check Time13.52s (± 0.79%)12.92s (± 0.40%)🟩-0.60s (- 4.42%)12.82s13.01s
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)0.00s ( NaN%)0.00s0.00s
Total Time16.20s (± 0.66%)15.59s (± 0.34%)🟩-0.61s (- 3.74%)15.49s15.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)
BenchmarkNameIterations
Current4397310
Baselinemaster10

Developer Information:

Download Benchmark

Copy link
Copy Markdown
Member

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.

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
Copy Markdown
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
Copy Markdown
MemberAuthor

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.

Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Author: TeamFor Milestone BugPRs 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

@weswigham@typescript-bot@andrewbranch@sheetalkamat@dmichon-msft