Skip to content

Optimize scan with a lookup table to reduce branching - #59106

Closed
Daniel Rosenwasser (DanielRosenwasser) wants to merge 13 commits into
mainfrom
scan-experiments
Closed

Optimize scan with a lookup table to reduce branching#59106
Daniel Rosenwasser (DanielRosenwasser) wants to merge 13 commits into
mainfrom
scan-experiments

Conversation

@DanielRosenwasser

@DanielRosenwasserDaniel Rosenwasser (DanielRosenwasser) commented Jul 2, 2024

Copy link
Copy Markdown
Member

This change introduces two lookup tables to the lexical scanner/tokenizer. One is a simple array-based lookup for entities in the ASCII range, and the other is a Map for wider codepoints.

These tables assign categories to codepoints to indicate how they should be handled. For example, all line breaks, single-line whitespace, and single-character tokens can be handled generically in their own respective fashion. Doing so allows us to perform fewer individual checks to jump into or skip over a given branch.

One additional optimization is the way in which simple single-character tokens are handled is that the token itself is encoded in the lower 8 bits the category value. This allows us to avoid any branching for such cases.

This all comes at the expense of some memory overhead, along with some overhead from fetching from the table. To avoid hitting the table too often, spaces, tabs, and carriage returns, and line feeds are currently handled separately.

@DanielRosenwasser

Copy link
Copy Markdown
MemberAuthor

It's probably faster to actually check the common case of spaces, tabs, and newlines, but the current draft always does the lookup.

TypeScript Bot (@typescript-bot) perf test this

@typescript-bot

TypeScript Bot (typescript-bot) commented Jul 2, 2024

Copy link
Copy Markdown
Contributor

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

CommandStatusResults
perf test this✅ Started👀 Results

@typescript-bot

Copy link
Copy Markdown
Contributor

Daniel Rosenwasser (@DanielRosenwasser)
The results of the perf run you requested are in!

Here they are:

tsc

Comparison Report - baseline..pr
MetricbaselineprDeltaBestWorstp-value
Compiler-Unions - node (v18.15.0, x64)
Errors3030~~~p=1.000 n=6
Symbols62,15362,153~~~p=1.000 n=6
Types50,24250,242~~~p=1.000 n=6
Memory used193,967k (± 1.03%)192,827k (± 0.77%)~192,123k195,863kp=0.810 n=6
Parse Time1.57s (± 1.04%)1.54s (± 0.76%)-0.03s (- 2.12%)1.53s1.56sp=0.010 n=6
Bind Time0.85s (± 0.48%)0.85s (± 0.96%)~0.83s0.85sp=1.000 n=6
Check Time11.16s (± 0.73%)11.22s (± 0.58%)~11.17s11.35sp=0.261 n=6
Emit Time3.25s (± 1.13%)3.26s (± 0.54%)~3.23s3.28sp=0.802 n=6
Total Time16.84s (± 0.48%)16.86s (± 0.44%)~16.80s17.01sp=0.574 n=6
angular-1 - node (v18.15.0, x64)
Errors55~~~p=1.000 n=6
Symbols944,114944,114~~~p=1.000 n=6
Types407,050407,050~~~p=1.000 n=6
Memory used1,218,360k (± 0.00%)1,218,350k (± 0.00%)~1,218,273k1,218,452kp=0.575 n=6
Parse Time7.97s (± 0.63%)7.92s (± 0.48%)~7.86s7.97sp=0.064 n=6
Bind Time2.22s (± 0.18%)2.23s (± 0.87%)~2.20s2.25sp=0.473 n=6
Check Time35.84s (± 0.39%)35.73s (± 0.59%)~35.51s36.09sp=0.173 n=6
Emit Time16.22s (± 0.31%)16.14s (± 0.59%)~16.01s16.28sp=0.148 n=6
Total Time62.25s (± 0.24%)62.03s (± 0.40%)~61.76s62.39sp=0.148 n=6
mui-docs - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols2,136,9802,136,980~~~p=1.000 n=6
Types929,117929,117~~~p=1.000 n=6
Memory used2,117,767k (± 0.00%)2,117,708k (± 0.01%)~2,117,559k2,117,943kp=0.298 n=6
Parse Time9.71s (± 0.16%)9.63s (± 0.63%)~9.55s9.73sp=0.063 n=6
Bind Time3.39s (± 0.58%)3.40s (± 1.27%)~3.34s3.45sp=0.571 n=6
Check Time102.35s (± 1.25%)102.33s (± 0.99%)~100.38s103.20sp=0.936 n=6
Emit Time0.19s (± 4.29%)0.19s (± 2.81%)~0.19s0.20sp=0.855 n=6
Total Time115.64s (± 1.09%)115.55s (± 0.87%)~113.64s116.47sp=0.423 n=6
self-build-src - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols1,225,2811,226,737+1,456 (+ 0.12%)~~p=0.001 n=6
Types261,342261,620+278 (+ 0.11%)~~p=0.001 n=6
Memory used2,341,362k (± 0.05%)2,341,478k (± 0.06%)~2,339,978k2,343,685kp=1.000 n=6
Parse Time7.52s (± 0.57%)7.47s (± 1.18%)~7.38s7.59sp=0.378 n=6
Bind Time2.78s (± 0.87%)2.80s (± 0.69%)~2.78s2.83sp=0.191 n=6
Check Time49.65s (± 0.65%)49.63s (± 0.54%)~49.39s50.16sp=1.000 n=6
Emit Time3.90s (± 5.28%)4.07s (± 6.58%)~3.75s4.38sp=0.298 n=6
Total Time63.88s (± 0.45%)63.98s (± 0.59%)~63.47s64.49sp=0.689 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols1,225,2811,226,737+1,456 (+ 0.12%)~~p=0.001 n=6
Types261,342261,620+278 (+ 0.11%)~~p=0.001 n=6
Memory used2,424,311k (± 1.02%)2,415,497k (± 0.05%)~2,414,486k2,417,424kp=0.471 n=6
Parse Time6.28s (± 0.93%)6.25s (± 0.84%)~6.20s6.35sp=0.298 n=6
Bind Time2.02s (± 0.74%)2.02s (± 0.60%)~2.00s2.03sp=0.517 n=6
Check Time40.72s (± 0.37%)40.95s (± 0.63%)~40.66s41.23sp=0.230 n=6
Emit Time3.20s (± 6.13%)3.22s (± 5.34%)~3.04s3.53sp=0.688 n=6
Total Time52.23s (± 0.46%)52.44s (± 0.54%)~52.07s52.79sp=0.173 n=6
self-compiler - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols258,194259,650+1,456 (+ 0.56%)~~p=0.001 n=6
Types104,737105,015+278 (+ 0.27%)~~p=0.001 n=6
Memory used427,489k (± 0.01%)428,192k (± 0.01%)+704k (+ 0.16%)428,150k428,249kp=0.005 n=6
Parse Time3.29s (± 0.57%)3.27s (± 0.32%)~3.26s3.29sp=0.370 n=6
Bind Time1.33s (± 0.31%)1.32s (± 0.96%)~1.30s1.33sp=0.214 n=6
Check Time17.86s (± 0.42%)17.82s (± 0.31%)~17.77s17.92sp=0.335 n=6
Emit Time1.25s (± 1.40%)1.26s (± 0.96%)~1.25s1.28sp=0.317 n=6
Total Time23.72s (± 0.41%)23.68s (± 0.20%)~23.62s23.75sp=0.195 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors3535~~~p=1.000 n=6
Symbols224,565224,565~~~p=1.000 n=6
Types93,73493,734~~~p=1.000 n=6
Memory used369,514k (± 0.04%)369,435k (± 0.02%)~369,334k369,557kp=0.298 n=6
Parse Time2.76s (± 0.67%)2.76s (± 1.11%)~2.72s2.79sp=0.747 n=6
Bind Time1.58s (± 0.52%)1.59s (± 1.17%)~1.57s1.61sp=0.445 n=6
Check Time15.44s (± 0.24%)15.41s (± 0.44%)~15.31s15.49sp=0.573 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time19.77s (± 0.27%)19.75s (± 0.44%)~19.65s19.88sp=0.936 n=6
vscode - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols2,879,9752,879,975~~~p=1.000 n=6
Types975,327975,327~~~p=1.000 n=6
Memory used3,042,839k (± 0.00%)3,042,871k (± 0.00%)~3,042,771k3,042,936kp=0.298 n=6
Parse Time13.73s (± 0.35%)13.73s (± 0.40%)~13.64s13.78sp=1.000 n=6
Bind Time4.24s (± 1.91%)4.26s (± 2.49%)~4.18s4.40sp=0.935 n=6
Check Time74.09s (± 2.34%)73.73s (± 0.43%)~73.21s74.19sp=0.471 n=6
Emit Time23.67s (± 6.50%)24.12s (± 1.92%)~23.22s24.50sp=0.936 n=6
Total Time115.72s (± 0.26%)115.84s (± 0.36%)~115.22s116.41sp=0.810 n=6
webpack - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols267,117267,117~~~p=1.000 n=6
Types108,775108,775~~~p=1.000 n=6
Memory used411,511k (± 0.01%)411,543k (± 0.01%)~411,475k411,623kp=0.378 n=6
Parse Time3.18s (± 0.59%)3.15s (± 0.53%)~3.13s3.17sp=0.062 n=6
Bind Time1.41s (± 1.22%)1.41s (± 0.59%)~1.41s1.43sp=0.934 n=6
Check Time14.16s (± 0.24%)14.19s (± 0.33%)~14.14s14.25sp=0.688 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time18.75s (± 0.23%)18.75s (± 0.25%)~18.69s18.82sp=0.936 n=6
xstate-main - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols525,251525,251~~~p=1.000 n=6
Types178,574178,574~~~p=1.000 n=6
Memory used462,921k (± 0.07%)462,714k (± 0.08%)~462,378k463,125kp=0.471 n=6
Parse Time3.18s (± 0.37%)3.08s (± 0.67%)-0.09s (- 2.94%)3.06s3.12sp=0.005 n=6
Bind Time1.17s1.17s (± 0.76%)~1.16s1.18sp=1.000 n=6
Check Time17.89s (± 0.36%)17.95s (± 0.71%)~17.82s18.18sp=0.470 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time22.24s (± 0.29%)22.20s (± 0.64%)~22.04s22.46sp=0.378 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)
BenchmarkNameIterations
Currentpr6
Baselinebaseline6

tsserver

Comparison Report - baseline..pr
MetricbaselineprDeltaBestWorstp-value
Compiler-UnionsTSServer - node (v18.15.0, x64)
Req 1 - updateOpen2,294ms (± 0.67%)2,287ms (± 0.64%)~2,265ms2,310msp=0.298 n=6
Req 2 - geterr5,059ms (± 0.89%)5,059ms (± 0.55%)~5,008ms5,087msp=1.000 n=6
Req 3 - references264ms (± 0.24%)264ms (± 0.21%)~263ms264msp=0.201 n=6
Req 4 - navto228ms (± 0.18%)227ms (± 0.90%)~223ms228msp=0.218 n=6
Req 5 - completionInfo count1,3571,357~~~p=1.000 n=6
Req 5 - completionInfo89ms (± 0.94%)90ms (± 3.58%)~88ms96msp=1.000 n=6
CompilerTSServer - node (v18.15.0, x64)
Req 1 - updateOpen2,424ms (± 0.56%)2,397ms (± 0.69%)-27ms (- 1.11%)2,382ms2,418msp=0.030 n=6
Req 2 - geterr3,791ms (± 0.52%)3,794ms (± 0.28%)~3,778ms3,810msp=1.000 n=6
Req 3 - references278ms (± 0.20%)278ms (± 0.63%)~275ms279msp=0.508 n=6
Req 4 - navto226ms (± 0.28%)230ms (± 2.60%)+4ms (+ 1.70%)227ms242msp=0.008 n=6
Req 5 - completionInfo count1,5191,519~~~p=1.000 n=6
Req 5 - completionInfo71ms (± 3.83%)83ms (± 5.31%)🔻+12ms (+16.12%)74ms85msp=0.007 n=6
xstate-main-1-tsserver - node (v18.15.0, x64)
Req 1 - updateOpen5,184ms (± 0.87%)5,140ms (± 0.30%)-44ms (- 0.85%)5,120ms5,156msp=0.030 n=6
Req 2 - geterr1,133ms (± 1.61%)1,125ms (± 1.33%)~1,111ms1,153msp=0.423 n=6
Req 3 - references78ms (± 4.99%)77ms (± 4.67%)~75ms82msp=0.344 n=6
Req 4 - navto457ms (± 0.23%)458ms (± 0.93%)~456ms467msp=0.605 n=6
Req 5 - completionInfo count3,4133,413~~~p=1.000 n=6
Req 5 - completionInfo832ms (± 2.15%)842ms (± 1.25%)~830ms857msp=0.297 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • CompilerTSServer - node (v18.15.0, x64)
  • Compiler-UnionsTSServer - node (v18.15.0, x64)
  • xstate-main-1-tsserver - node (v18.15.0, x64)
BenchmarkNameIterations
Currentpr6
Baselinebaseline6

startup

Comparison Report - baseline..pr
MetricbaselineprDeltaBestWorstp-value
tsc-startup - node (v18.15.0, x64)
Execution time156.97ms (± 0.16%)156.76ms (± 0.21%)-0.20ms (- 0.13%)155.79ms162.86msp=0.000 n=600
tsserver-startup - node (v18.15.0, x64)
Execution time230.76ms (± 0.13%)230.73ms (± 0.13%)~229.50ms233.81msp=0.615 n=600
tsserverlibrary-startup - node (v18.15.0, x64)
Execution time225.94ms (± 0.14%)226.15ms (± 0.13%)+0.21ms (+ 0.09%)224.77ms229.96msp=0.000 n=600
typescript-startup - node (v18.15.0, x64)
Execution time225.80ms (± 0.16%)225.89ms (± 0.13%)+0.08ms (+ 0.04%)224.41ms227.84msp=0.000 n=600
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • tsc-startup - node (v18.15.0, x64)
  • tsserver-startup - node (v18.15.0, x64)
  • tsserverlibrary-startup - node (v18.15.0, x64)
  • typescript-startup - node (v18.15.0, x64)
BenchmarkNameIterations
Currentpr6
Baselinebaseline6

Developer Information:

Download Benchmarks

@DanielRosenwasser

Copy link
Copy Markdown
MemberAuthor

TypeScript Bot (@typescript-bot) perf test this

@typescript-bot

TypeScript Bot (typescript-bot) commented Jul 2, 2024

Copy link
Copy Markdown
Contributor

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

CommandStatusResults
perf test this✅ Started👀 Results

@typescript-bot

Copy link
Copy Markdown
Contributor

Daniel Rosenwasser (@DanielRosenwasser)
The results of the perf run you requested are in!

Here they are:

tsc

Comparison Report - baseline..pr
MetricbaselineprDeltaBestWorstp-value
Compiler-Unions - node (v18.15.0, x64)
Errors3030~~~p=1.000 n=6
Symbols62,15362,153~~~p=1.000 n=6
Types50,24250,242~~~p=1.000 n=6
Memory used193,968k (± 1.03%)193,382k (± 0.97%)~192,131k195,906kp=0.936 n=6
Parse Time1.58s (± 0.40%)1.55s (± 1.35%)-0.03s (- 1.90%)1.51s1.57sp=0.005 n=6
Bind Time0.85s (± 0.60%)0.86s (± 1.47%)~0.85s0.88sp=0.418 n=6
Check Time11.17s (± 0.39%)11.17s (± 0.45%)~11.10s11.25sp=1.000 n=6
Emit Time3.29s (± 0.17%)3.27s (± 0.59%)~3.25s3.30sp=0.100 n=6
Total Time16.89s (± 0.31%)16.84s (± 0.28%)~16.80s16.92sp=0.170 n=6
angular-1 - node (v18.15.0, x64)
Errors55~~~p=1.000 n=6
Symbols944,114944,114~~~p=1.000 n=6
Types407,050407,050~~~p=1.000 n=6
Memory used1,218,354k (± 0.00%)1,218,334k (± 0.00%)~1,218,307k1,218,364kp=0.471 n=6
Parse Time7.96s (± 1.13%)7.86s (± 0.61%)-0.09s (- 1.19%)7.78s7.92sp=0.043 n=6
Bind Time2.23s (± 0.52%)2.22s (± 0.68%)~2.21s2.25sp=0.401 n=6
Check Time35.74s (± 0.30%)35.75s (± 0.36%)~35.59s35.97sp=0.936 n=6
Emit Time16.16s (± 0.44%)16.12s (± 0.29%)~16.05s16.18sp=0.377 n=6
Total Time62.08s (± 0.21%)61.95s (± 0.17%)~61.81s62.14sp=0.065 n=6
mui-docs - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols2,136,9802,136,980~~~p=1.000 n=6
Types929,117929,117~~~p=1.000 n=6
Memory used2,117,728k (± 0.01%)2,117,653k (± 0.01%)~2,117,562k2,117,860kp=0.378 n=6
Parse Time7.89s (± 0.19%)7.77s (± 0.29%)-0.12s (- 1.52%)7.75s7.81sp=0.005 n=6
Bind Time2.76s (± 0.37%)2.76s (± 0.70%)~2.73s2.79sp=1.000 n=6
Check Time83.71s (± 0.25%)83.61s (± 0.39%)~83.29s84.12sp=0.470 n=6
Emit Time0.16s (± 4.65%)0.16s (± 3.95%)~0.15s0.17sp=0.718 n=6
Total Time94.52s (± 0.22%)94.31s (± 0.34%)~93.98s94.78sp=0.336 n=6
self-build-src - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols1,225,2811,225,410+129 (+ 0.01%)~~p=0.001 n=6
Types261,342261,443+101 (+ 0.04%)~~p=0.001 n=6
Memory used2,350,713k (± 1.06%)2,341,270k (± 0.04%)~2,339,826k2,342,288kp=0.378 n=6
Parse Time7.52s (± 0.49%)7.42s (± 0.98%)-0.09s (- 1.26%)7.34s7.55sp=0.045 n=6
Bind Time2.78s (± 0.49%)2.79s (± 0.77%)~2.75s2.81sp=0.569 n=6
Check Time49.78s (± 0.71%)49.77s (± 0.38%)~49.51s50.03sp=1.000 n=6
Emit Time3.94s (± 5.23%)3.85s (± 3.21%)~3.78s4.10sp=0.688 n=6
Total Time64.05s (± 0.74%)63.84s (± 0.55%)~63.48s64.46sp=0.689 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols1,225,2811,225,410+129 (+ 0.01%)~~p=0.001 n=6
Types261,342261,443+101 (+ 0.04%)~~p=0.001 n=6
Memory used2,415,021k (± 0.04%)2,416,113k (± 0.05%)~2,415,052k2,417,912kp=0.128 n=6
Parse Time7.80s (± 0.99%)7.66s (± 1.02%)-0.13s (- 1.69%)7.52s7.73sp=0.020 n=6
Bind Time2.51s (± 0.39%)2.52s (± 1.05%)~2.48s2.55sp=0.870 n=6
Check Time50.40s (± 0.64%)50.43s (± 0.51%)~50.20s50.86sp=1.000 n=6
Emit Time3.99s (± 4.97%)3.85s (± 2.53%)~3.73s3.99sp=0.336 n=6
Total Time64.71s (± 0.41%)64.47s (± 0.37%)~64.26s64.89sp=0.173 n=6
self-compiler - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols258,194258,323+129 (+ 0.05%)~~p=0.001 n=6
Types104,737104,838+101 (+ 0.10%)~~p=0.001 n=6
Memory used427,490k (± 0.01%)427,609k (± 0.01%)+119k (+ 0.03%)427,547k427,695kp=0.005 n=6
Parse Time3.30s (± 0.70%)3.23s (± 0.54%)-0.07s (- 1.97%)3.21s3.26sp=0.005 n=6
Bind Time1.32s (± 0.91%)1.31s (± 1.42%)~1.28s1.33sp=0.096 n=6
Check Time17.86s (± 0.30%)17.84s (± 0.29%)~17.78s17.91sp=0.471 n=6
Emit Time1.26s (± 0.83%)1.26s (± 0.82%)~1.24s1.27sp=0.801 n=6
Total Time23.74s (± 0.27%)23.63s (± 0.22%)-0.11s (- 0.46%)23.58s23.69sp=0.037 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors3535~~~p=1.000 n=6
Symbols224,565224,565~~~p=1.000 n=6
Types93,73493,734~~~p=1.000 n=6
Memory used369,602k (± 0.05%)369,472k (± 0.01%)~369,409k369,567kp=0.298 n=6
Parse Time2.78s (± 1.50%)2.72s (± 0.72%)-0.05s (- 1.92%)2.70s2.75sp=0.036 n=6
Bind Time1.57s (± 0.40%)1.59s (± 1.11%)~1.56s1.61sp=0.081 n=6
Check Time15.44s (± 0.14%)15.45s (± 0.19%)~15.42s15.49sp=0.625 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time19.79s (± 0.22%)19.76s (± 0.18%)~19.71s19.80sp=0.147 n=6
vscode - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols2,879,9752,879,975~~~p=1.000 n=6
Types975,327975,327~~~p=1.000 n=6
Memory used3,042,832k (± 0.00%)3,042,846k (± 0.00%)~3,042,776k3,042,921kp=0.872 n=6
Parse Time13.70s (± 0.25%)13.63s (± 0.29%)-0.07s (- 0.51%)13.57s13.68sp=0.020 n=6
Bind Time4.24s (± 2.07%)4.20s (± 0.18%)~4.19s4.21sp=0.210 n=6
Check Time73.44s (± 0.29%)74.72s (± 2.03%)+1.28s (+ 1.75%)73.36s77.27sp=0.045 n=6
Emit Time24.17s (± 1.22%)23.06s (± 6.83%)~20.45s24.52sp=0.335 n=6
Total Time115.55s (± 0.40%)115.61s (± 0.22%)~115.30s116.02sp=1.000 n=6
webpack - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols267,117267,117~~~p=1.000 n=6
Types108,775108,775~~~p=1.000 n=6
Memory used411,574k (± 0.02%)411,568k (± 0.01%)~411,519k411,630kp=1.000 n=6
Parse Time3.81s (± 0.59%)3.75s (± 0.31%)-0.07s (- 1.75%)3.73s3.76sp=0.005 n=6
Bind Time1.70s (± 0.62%)1.69s (± 0.58%)~1.68s1.71sp=0.547 n=6
Check Time16.74s (± 0.28%)16.76s (± 0.25%)~16.70s16.83sp=0.421 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time22.25s (± 0.22%)22.19s (± 0.25%)~22.11s22.28sp=0.106 n=6
xstate-main - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols525,251525,251~~~p=1.000 n=6
Types178,574178,574~~~p=1.000 n=6
Memory used462,752k (± 0.09%)462,922k (± 0.07%)~462,313k463,152kp=0.936 n=6
Parse Time2.65s (± 0.82%)2.56s (± 0.40%)🟩-0.08s (- 3.15%)2.55s2.57sp=0.004 n=6
Bind Time0.98s (± 0.42%)0.97s (± 0.42%)-0.01s (- 0.68%)0.97s0.98sp=0.034 n=6
Check Time15.18s (± 0.33%)15.19s (± 0.33%)~15.10s15.24sp=0.748 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time18.81s (± 0.20%)18.72s (± 0.30%)-0.08s (- 0.43%)18.62s18.78sp=0.013 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)
BenchmarkNameIterations
Currentpr6
Baselinebaseline6

tsserver

Comparison Report - baseline..pr
MetricbaselineprDeltaBestWorstp-value
Compiler-UnionsTSServer - node (v18.15.0, x64)
Req 1 - updateOpen2,299ms (± 0.49%)2,280ms (± 0.70%)-19ms (- 0.84%)2,253ms2,295msp=0.045 n=6
Req 2 - geterr5,060ms (± 0.47%)5,056ms (± 0.55%)~5,012ms5,085msp=0.936 n=6
Req 3 - references264ms (± 0.28%)264ms (± 0.62%)~261ms265msp=0.800 n=6
Req 4 - navto227ms (± 1.31%)229ms (± 0.33%)~228ms230msp=0.081 n=6
Req 5 - completionInfo count1,3571,357~~~p=1.000 n=6
Req 5 - completionInfo89ms (± 0.84%)86ms (± 7.46%)~78ms93msp=0.564 n=6
CompilerTSServer - node (v18.15.0, x64)
Req 1 - updateOpen2,409ms (± 0.50%)2,375ms (± 0.37%)-34ms (- 1.40%)2,366ms2,391msp=0.005 n=6
Req 2 - geterr3,796ms (± 0.43%)3,801ms (± 0.20%)~3,794ms3,814msp=0.173 n=6
Req 3 - references276ms (± 0.42%)276ms (± 0.54%)~275ms279msp=0.804 n=6
Req 4 - navto227ms (± 0.18%)227ms (± 0.18%)~226ms227msp=1.000 n=6
Req 5 - completionInfo count1,5191,519~~~p=1.000 n=6
Req 5 - completionInfo73ms (± 7.73%)76ms (± 8.76%)~69ms85msp=0.372 n=6
xstate-main-1-tsserver - node (v18.15.0, x64)
Req 1 - updateOpen5,204ms (± 0.84%)5,137ms (± 0.78%)-68ms (- 1.30%)5,086ms5,200msp=0.031 n=6
Req 2 - geterr1,128ms (± 1.34%)1,130ms (± 0.68%)~1,123ms1,143msp=0.936 n=6
Req 3 - references78ms (± 4.93%)77ms (± 5.21%)~74ms83msp=0.681 n=6
Req 4 - navto459ms (± 0.79%)457ms (± 0.29%)~455ms459msp=0.246 n=6
Req 5 - completionInfo count3,4133,413~~~p=1.000 n=6
Req 5 - completionInfo841ms (± 2.00%)835ms (± 1.56%)~823ms851msp=0.689 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • CompilerTSServer - node (v18.15.0, x64)
  • Compiler-UnionsTSServer - node (v18.15.0, x64)
  • xstate-main-1-tsserver - node (v18.15.0, x64)
BenchmarkNameIterations
Currentpr6
Baselinebaseline6

startup

Comparison Report - baseline..pr
MetricbaselineprDeltaBestWorstp-value
tsc-startup - node (v18.15.0, x64)
Execution time156.99ms (± 0.17%)156.89ms (± 0.17%)-0.10ms (- 0.07%)155.87ms159.53msp=0.001 n=600
tsserver-startup - node (v18.15.0, x64)
Execution time230.67ms (± 0.13%)230.82ms (± 0.14%)+0.16ms (+ 0.07%)229.42ms235.56msp=0.000 n=600
tsserverlibrary-startup - node (v18.15.0, x64)
Execution time226.45ms (± 0.13%)226.53ms (± 0.13%)+0.08ms (+ 0.04%)225.23ms229.04msp=0.009 n=600
typescript-startup - node (v18.15.0, x64)
Execution time225.73ms (± 0.13%)225.97ms (± 0.13%)+0.25ms (+ 0.11%)224.25ms228.07msp=0.000 n=600
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • tsc-startup - node (v18.15.0, x64)
  • tsserver-startup - node (v18.15.0, x64)
  • tsserverlibrary-startup - node (v18.15.0, x64)
  • typescript-startup - node (v18.15.0, x64)
BenchmarkNameIterations
Currentpr6
Baselinebaseline6

Developer Information:

Download Benchmarks

@DanielRosenwasser

Copy link
Copy Markdown
MemberAuthor

TypeScript Bot (@typescript-bot) perf test this

@typescript-bot

TypeScript Bot (typescript-bot) commented Jul 2, 2024

Copy link
Copy Markdown
Contributor

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

CommandStatusResults
perf test this✅ Started👀 Results

@DanielRosenwasser

Copy link
Copy Markdown
MemberAuthor

TypeScript Bot (@typescript-bot) perf test this

@typescript-bot

TypeScript Bot (typescript-bot) commented Jul 2, 2024

Copy link
Copy Markdown
Contributor

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

CommandStatusResults
perf test this✅ Started👀 Results

@typescript-bot

Copy link
Copy Markdown
Contributor

Daniel Rosenwasser (@DanielRosenwasser)
The results of the perf run you requested are in!

Here they are:

tsc

Comparison Report - baseline..pr
MetricbaselineprDeltaBestWorstp-value
Compiler-Unions - node (v18.15.0, x64)
Errors3030~~~p=1.000 n=6
Symbols62,15362,153~~~p=1.000 n=6
Types50,24250,242~~~p=1.000 n=6
Memory used193,962k (± 1.02%)193,453k (± 0.92%)~192,161k195,765kp=0.936 n=6
Parse Time1.57s (± 0.74%)1.52s (± 0.77%)-0.05s (- 2.98%)1.50s1.53sp=0.005 n=6
Bind Time0.85s (± 0.89%)0.85s (± 0.60%)~0.85s0.86sp=0.241 n=6
Check Time11.23s (± 0.43%)11.21s (± 0.34%)~11.17s11.27sp=0.519 n=6
Emit Time3.27s (± 1.09%)3.28s (± 0.89%)~3.24s3.33sp=0.519 n=6
Total Time16.92s (± 0.43%)16.86s (± 0.21%)~16.83s16.93sp=0.171 n=6
angular-1 - node (v18.15.0, x64)
Errors55~~~p=1.000 n=6
Symbols944,114944,114~~~p=1.000 n=6
Types407,050407,050~~~p=1.000 n=6
Memory used1,218,327k (± 0.00%)1,218,367k (± 0.00%)~1,218,289k1,218,410kp=0.066 n=6
Parse Time7.96s (± 0.47%)7.88s (± 0.33%)-0.08s (- 0.96%)7.85s7.91sp=0.008 n=6
Bind Time2.23s (± 0.54%)2.23s (± 0.54%)~2.22s2.25sp=1.000 n=6
Check Time35.79s (± 0.58%)35.84s (± 0.21%)~35.75s35.92sp=0.198 n=6
Emit Time16.18s (± 0.29%)16.23s (± 0.73%)~16.11s16.43sp=0.520 n=6
Total Time62.16s (± 0.35%)62.18s (± 0.20%)~62.04s62.35sp=0.574 n=6
mui-docs - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols2,136,9802,136,980~~~p=1.000 n=6
Types929,117929,117~~~p=1.000 n=6
Memory used2,117,610k (± 0.00%)2,117,706k (± 0.01%)~2,117,502k2,117,823kp=0.093 n=6
Parse Time9.71s (± 0.57%)9.54s (± 0.35%)-0.17s (- 1.73%)9.51s9.59sp=0.005 n=6
Bind Time3.38s (± 0.76%)3.37s (± 0.50%)~3.35s3.39sp=0.568 n=6
Check Time102.45s (± 0.35%)101.87s (± 0.99%)~99.94s102.67sp=0.261 n=6
Emit Time0.19s (± 4.22%)0.20s (± 4.15%)~0.19s0.21sp=0.389 n=6
Total Time115.73s (± 0.29%)114.98s (± 0.85%)~113.12s115.78sp=0.078 n=6
self-build-src - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols1,225,2811,225,412+131 (+ 0.01%)~~p=0.001 n=6
Types261,342261,447+105 (+ 0.04%)~~p=0.001 n=6
Memory used2,341,897k (± 0.06%)2,342,141k (± 0.03%)~2,341,329k2,343,133kp=0.936 n=6
Parse Time6.05s (± 0.90%)5.93s (± 0.86%)-0.12s (- 1.96%)5.89s6.02sp=0.013 n=6
Bind Time2.27s (± 0.66%)2.25s (± 0.61%)~2.24s2.27sp=0.197 n=6
Check Time40.19s (± 0.46%)40.33s (± 0.44%)~40.18s40.56sp=0.128 n=6
Emit Time3.04s (± 5.65%)3.03s (± 2.33%)~2.95s3.15sp=0.471 n=6
Total Time51.57s (± 0.61%)51.55s (± 0.50%)~51.33s51.89sp=0.810 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols1,225,2811,225,412+131 (+ 0.01%)~~p=0.001 n=6
Types261,342261,447+105 (+ 0.04%)~~p=0.001 n=6
Memory used2,415,583k (± 0.03%)2,415,755k (± 0.01%)~2,415,449k2,416,417kp=0.575 n=6
Parse Time7.76s (± 0.37%)7.59s (± 1.04%)-0.17s (- 2.19%)7.46s7.68sp=0.005 n=6
Bind Time2.52s (± 0.89%)2.52s (± 1.54%)~2.47s2.57sp=0.809 n=6
Check Time50.21s (± 0.47%)50.38s (± 0.29%)~50.19s50.58sp=0.173 n=6
Emit Time3.93s (± 4.63%)3.92s (± 1.48%)~3.82s4.00sp=0.470 n=6
Total Time64.41s (± 0.49%)64.42s (± 0.25%)~64.15s64.60sp=0.810 n=6
self-compiler - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols258,194258,325+131 (+ 0.05%)~~p=0.001 n=6
Types104,737104,842+105 (+ 0.10%)~~p=0.001 n=6
Memory used427,480k (± 0.00%)427,683k (± 0.01%)+203k (+ 0.05%)427,630k427,729kp=0.005 n=6
Parse Time3.28s (± 0.66%)3.23s (± 0.73%)-0.05s (- 1.42%)3.20s3.26sp=0.013 n=6
Bind Time1.31s (± 0.96%)1.30s (± 1.41%)~1.29s1.33sp=0.397 n=6
Check Time17.79s (± 0.29%)17.82s (± 0.38%)~17.76s17.94sp=0.870 n=6
Emit Time1.25s (± 0.71%)1.25s (± 1.01%)~1.23s1.27sp=1.000 n=6
Total Time23.63s (± 0.18%)23.60s (± 0.21%)~23.54s23.68sp=0.377 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors3535~~~p=1.000 n=6
Symbols224,565224,565~~~p=1.000 n=6
Types93,73493,734~~~p=1.000 n=6
Memory used369,562k (± 0.03%)369,530k (± 0.04%)~369,434k369,814kp=0.575 n=6
Parse Time2.78s (± 0.71%)2.73s (± 0.46%)-0.05s (- 1.68%)2.71s2.74sp=0.005 n=6
Bind Time1.58s (± 0.98%)1.59s (± 0.94%)~1.58s1.62sp=0.084 n=6
Check Time15.48s (± 0.34%)15.45s (± 0.42%)~15.34s15.53sp=0.422 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time19.84s (± 0.39%)19.78s (± 0.45%)~19.64s19.89sp=0.336 n=6
vscode - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols2,879,9752,879,975~~~p=1.000 n=6
Types975,327975,327~~~p=1.000 n=6
Memory used3,042,831k (± 0.00%)3,042,773k (± 0.00%)~3,042,693k3,042,884kp=0.093 n=6
Parse Time13.74s (± 0.52%)13.54s (± 0.26%)-0.20s (- 1.44%)13.50s13.60sp=0.005 n=6
Bind Time4.24s (± 1.92%)4.22s (± 1.96%)~4.17s4.39sp=0.373 n=6
Check Time73.51s (± 0.35%)74.09s (± 1.81%)~73.20s76.16sp=0.810 n=6
Emit Time24.23s (± 0.42%)23.60s (± 4.01%)~22.20s24.27sp=0.128 n=6
Total Time115.72s (± 0.20%)115.46s (± 0.33%)~115.07s116.08sp=0.228 n=6
webpack - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols267,117267,117~~~p=1.000 n=6
Types108,775108,775~~~p=1.000 n=6
Memory used411,528k (± 0.01%)411,534k (± 0.02%)~411,456k411,618kp=0.936 n=6
Parse Time3.18s (± 0.54%)3.13s (± 0.90%)-0.05s (- 1.63%)3.10s3.16sp=0.013 n=6
Bind Time1.41s (± 0.53%)1.41s (± 0.94%)~1.39s1.43sp=0.548 n=6
Check Time14.20s (± 0.34%)14.20s (± 0.24%)~14.15s14.25sp=1.000 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time18.79s (± 0.28%)18.74s (± 0.25%)~18.66s18.80sp=0.172 n=6
xstate-main - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols525,251525,251~~~p=1.000 n=6
Types178,574178,574~~~p=1.000 n=6
Memory used462,528k (± 0.06%)462,641k (± 0.08%)~462,297k463,096kp=0.575 n=6
Parse Time3.18s (± 0.32%)3.08s (± 0.45%)🟩-0.10s (- 3.20%)3.06s3.10sp=0.004 n=6
Bind Time1.17s (± 0.47%)1.17s (± 0.35%)~1.16s1.17sp=0.282 n=6
Check Time17.88s (± 0.45%)17.88s (± 0.18%)~17.84s17.91sp=0.468 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time22.22s (± 0.39%)22.12s (± 0.17%)~22.07s22.17sp=0.066 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)
BenchmarkNameIterations
Currentpr6
Baselinebaseline6

tsserver

Comparison Report - baseline..pr
MetricbaselineprDeltaBestWorstp-value
Compiler-UnionsTSServer - node (v18.15.0, x64)
Req 1 - updateOpen2,291ms (± 0.18%)2,242ms (± 0.62%)-49ms (- 2.14%)2,227ms2,262msp=0.005 n=6
Req 2 - geterr5,057ms (± 0.58%)5,071ms (± 0.31%)~5,045ms5,087msp=0.471 n=6
Req 3 - references265ms (± 0.15%)264ms (± 0.20%)-1ms (- 0.44%)263ms264msp=0.007 n=6
Req 4 - navto228ms228ms (± 0.37%)~226ms228msp=0.176 n=6
Req 5 - completionInfo count1,3571,357~~~p=1.000 n=6
Req 5 - completionInfo88ms (± 0.46%)88ms (± 0.46%)~88ms89msp=1.000 n=6
CompilerTSServer - node (v18.15.0, x64)
Req 1 - updateOpen2,419ms (± 0.30%)2,386ms (± 1.10%)~2,366ms2,425msp=0.065 n=6
Req 2 - geterr3,793ms (± 0.38%)3,792ms (± 0.34%)~3,777ms3,812msp=0.748 n=6
Req 3 - references276ms (± 0.27%)277ms (± 0.48%)~275ms279msp=0.131 n=6
Req 4 - navto226ms (± 0.28%)226ms (± 0.23%)~226ms227msp=0.386 n=6
Req 5 - completionInfo count1,5191,519~~~p=1.000 n=6
Req 5 - completionInfo72ms (± 3.83%)72ms (± 8.71%)~67ms84msp=0.412 n=6
xstate-main-1-tsserver - node (v18.15.0, x64)
Req 1 - updateOpen5,182ms (± 0.45%)5,126ms (± 0.19%)-56ms (- 1.08%)5,112ms5,137msp=0.005 n=6
Req 2 - geterr1,120ms (± 1.44%)1,137ms (± 1.43%)~1,118ms1,162msp=0.148 n=6
Req 3 - references77ms (± 2.95%)79ms (± 4.88%)~75ms82msp=0.673 n=6
Req 4 - navto459ms (± 0.70%)459ms (± 1.26%)~456ms471msp=0.505 n=6
Req 5 - completionInfo count3,4133,413~~~p=1.000 n=6
Req 5 - completionInfo833ms (± 1.53%)841ms (± 1.18%)~830ms851msp=0.469 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • CompilerTSServer - node (v18.15.0, x64)
  • Compiler-UnionsTSServer - node (v18.15.0, x64)
  • xstate-main-1-tsserver - node (v18.15.0, x64)
BenchmarkNameIterations
Currentpr6
Baselinebaseline6

startup

Comparison Report - baseline..pr
MetricbaselineprDeltaBestWorstp-value
tsc-startup - node (v18.15.0, x64)
Execution time157.08ms (± 0.17%)157.15ms (± 0.17%)+0.08ms (+ 0.05%)156.02ms160.72msp=0.004 n=600
tsserver-startup - node (v18.15.0, x64)
Execution time230.51ms (± 0.14%)230.61ms (± 0.19%)+0.10ms (+ 0.04%)229.34ms246.30msp=0.008 n=600
tsserverlibrary-startup - node (v18.15.0, x64)
Execution time226.09ms (± 0.13%)226.31ms (± 0.17%)+0.22ms (+ 0.10%)225.05ms236.63msp=0.000 n=600
typescript-startup - node (v18.15.0, x64)
Execution time225.82ms (± 0.16%)225.89ms (± 0.17%)+0.07ms (+ 0.03%)224.42ms235.68msp=0.034 n=600
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • tsc-startup - node (v18.15.0, x64)
  • tsserver-startup - node (v18.15.0, x64)
  • tsserverlibrary-startup - node (v18.15.0, x64)
  • typescript-startup - node (v18.15.0, x64)
BenchmarkNameIterations
Currentpr6
Baselinebaseline6

Developer Information:

Download Benchmarks

@typescript-bot

Copy link
Copy Markdown
Contributor

Daniel Rosenwasser (@DanielRosenwasser)
The results of the perf run you requested are in!

Here they are:

tsc

Comparison Report - baseline..pr
MetricbaselineprDeltaBestWorstp-value
Compiler-Unions - node (v18.15.0, x64)
Errors3030~~~p=1.000 n=6
Symbols62,15362,153~~~p=1.000 n=6
Types50,24250,242~~~p=1.000 n=6
Memory used193,433k (± 0.93%)194,534k (± 0.94%)~192,152k195,805kp=0.810 n=6
Parse Time1.58s (± 1.09%)1.50s (± 0.73%)🟩-0.08s (- 4.96%)1.49s1.52sp=0.005 n=6
Bind Time0.85s (± 1.21%)0.86s (± 1.36%)~0.84s0.87sp=0.456 n=6
Check Time11.17s (± 0.37%)11.22s (± 0.45%)~11.16s11.28sp=0.196 n=6
Emit Time3.29s (± 0.85%)3.28s (± 0.45%)~3.26s3.30sp=0.935 n=6
Total Time16.89s (± 0.17%)16.86s (± 0.26%)~16.80s16.91sp=0.295 n=6
angular-1 - node (v18.15.0, x64)
Errors55~~~p=1.000 n=6
Symbols944,114944,114~~~p=1.000 n=6
Types407,050407,050~~~p=1.000 n=6
Memory used1,218,400k (± 0.00%)1,218,372k (± 0.00%)~1,218,309k1,218,440kp=0.230 n=6
Parse Time6.67s (± 0.92%)6.57s (± 0.54%)-0.10s (- 1.47%)6.50s6.60sp=0.016 n=6
Bind Time1.87s (± 0.44%)1.87s (± 0.22%)~1.87s1.88sp=0.206 n=6
Check Time30.60s (± 0.36%)30.62s (± 0.67%)~30.43s31.02sp=1.000 n=6
Emit Time13.58s (± 0.40%)13.58s (± 0.50%)~13.51s13.69sp=1.000 n=6
Total Time52.72s (± 0.38%)52.65s (± 0.51%)~52.42s53.15sp=0.470 n=6
mui-docs - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols2,136,9802,136,980~~~p=1.000 n=6
Types929,117929,117~~~p=1.000 n=6
Memory used2,117,784k (± 0.01%)2,117,749k (± 0.00%)~2,117,569k2,117,854kp=0.810 n=6
Parse Time7.88s (± 0.25%)7.74s (± 0.28%)-0.14s (- 1.76%)7.72s7.78sp=0.005 n=6
Bind Time2.73s (± 0.43%)2.74s (± 0.68%)~2.71s2.76sp=0.101 n=6
Check Time83.32s (± 0.38%)83.25s (± 0.24%)~82.99s83.49sp=0.471 n=6
Emit Time0.15s (± 3.53%)0.16s (± 3.29%)~0.15s0.16sp=0.640 n=6
Total Time94.08s (± 0.35%)93.89s (± 0.20%)~93.66s94.12sp=0.336 n=6
self-build-src - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols1,225,2811,225,412+131 (+ 0.01%)~~p=0.001 n=6
Types261,342261,448+106 (+ 0.04%)~~p=0.001 n=6
Memory used2,342,656k (± 0.02%)2,342,024k (± 0.04%)~2,340,664k2,343,136kp=0.378 n=6
Parse Time6.03s (± 0.77%)5.98s (± 0.93%)~5.90s6.05sp=0.297 n=6
Bind Time2.26s (± 0.91%)2.26s (± 0.54%)~2.24s2.27sp=0.625 n=6
Check Time40.29s (± 0.56%)40.33s (± 0.13%)~40.24s40.38sp=0.936 n=6
Emit Time2.95s (± 1.41%)3.04s (± 2.52%)+0.09s (+ 2.99%)2.96s3.17sp=0.045 n=6
Total Time51.54s (± 0.54%)51.63s (± 0.17%)~51.51s51.72sp=0.936 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols1,225,2811,225,412+131 (+ 0.01%)~~p=0.001 n=6
Types261,342261,448+106 (+ 0.04%)~~p=0.001 n=6
Memory used2,415,148k (± 0.05%)2,415,902k (± 0.04%)~2,414,963k2,417,577kp=0.128 n=6
Parse Time7.74s (± 0.76%)7.63s (± 1.08%)~7.56s7.73sp=0.066 n=6
Bind Time2.52s (± 1.29%)2.53s (± 0.65%)~2.51s2.56sp=0.574 n=6
Check Time50.30s (± 0.52%)50.54s (± 0.79%)~50.18s51.24sp=0.575 n=6
Emit Time3.92s (± 3.49%)3.87s (± 1.94%)~3.73s3.94sp=0.689 n=6
Total Time64.49s (± 0.56%)64.59s (± 0.79%)~64.12s65.49sp=1.000 n=6
self-compiler - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols258,194258,325+131 (+ 0.05%)~~p=0.001 n=6
Types104,737104,843+106 (+ 0.10%)~~p=0.001 n=6
Memory used427,524k (± 0.03%)427,685k (± 0.01%)~427,642k427,717kp=0.065 n=6
Parse Time3.30s (± 0.56%)3.22s (± 0.47%)-0.07s (- 2.17%)3.21s3.25sp=0.005 n=6
Bind Time1.33s (± 0.61%)1.31s (± 1.79%)~1.28s1.34sp=0.171 n=6
Check Time17.89s (± 0.30%)17.84s (± 0.35%)~17.77s17.91sp=0.230 n=6
Emit Time1.26s (± 1.30%)1.25s (± 1.20%)~1.24s1.28sp=0.287 n=6
Total Time23.77s (± 0.21%)23.62s (± 0.27%)-0.15s (- 0.63%)23.51s23.67sp=0.005 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors3535~~~p=1.000 n=6
Symbols224,565224,565~~~p=1.000 n=6
Types93,73493,734~~~p=1.000 n=6
Memory used369,547k (± 0.05%)369,476k (± 0.02%)~369,393k369,583kp=0.810 n=6
Parse Time2.75s (± 1.00%)2.73s (± 1.06%)~2.69s2.76sp=0.225 n=6
Bind Time1.57s (± 0.48%)1.58s (± 0.67%)~1.56s1.59sp=0.611 n=6
Check Time15.44s (± 0.33%)15.45s (± 0.22%)~15.42s15.51sp=0.871 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time19.76s (± 0.31%)19.74s (± 0.22%)~19.70s19.81sp=0.686 n=6
vscode - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols2,880,0172,880,017~~~p=1.000 n=6
Types975,336975,336~~~p=1.000 n=6
Memory used3,042,842k (± 0.00%)3,042,791k (± 0.00%)~3,042,683k3,042,922kp=0.229 n=6
Parse Time11.45s (± 0.38%)11.32s (± 0.51%)-0.13s (- 1.12%)11.27s11.43sp=0.010 n=6
Bind Time3.50s (± 0.33%)3.51s (± 0.43%)~3.49s3.53sp=0.618 n=6
Check Time64.76s (± 1.98%)65.23s (± 1.96%)~63.50s66.91sp=0.575 n=6
Emit Time19.25s (± 6.63%)18.70s (± 6.37%)~17.27s20.15sp=0.471 n=6
Total Time98.97s (± 0.40%)98.75s (± 0.22%)~98.48s99.02sp=0.173 n=6
webpack - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols267,117267,117~~~p=1.000 n=6
Types108,775108,775~~~p=1.000 n=6
Memory used411,571k (± 0.02%)411,585k (± 0.01%)~411,507k411,672kp=0.575 n=6
Parse Time3.83s (± 0.64%)3.75s (± 0.62%)-0.08s (- 1.96%)3.72s3.78sp=0.005 n=6
Bind Time1.70s (± 0.71%)1.69s (± 0.32%)~1.69s1.70sp=0.865 n=6
Check Time16.78s (± 0.29%)16.75s (± 0.30%)~16.67s16.80sp=0.469 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time22.31s (± 0.26%)22.20s (± 0.30%)-0.11s (- 0.48%)22.11s22.26sp=0.016 n=6
xstate-main - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols525,251525,251~~~p=1.000 n=6
Types178,574178,574~~~p=1.000 n=6
Memory used462,791k (± 0.08%)462,975k (± 0.02%)~462,906k463,149kp=0.423 n=6
Parse Time2.65s (± 0.31%)2.56s (± 0.59%)🟩-0.08s (- 3.15%)2.54s2.58sp=0.004 n=6
Bind Time0.98s (± 0.53%)0.98s (± 1.12%)~0.97s1.00sp=0.784 n=6
Check Time15.19s (± 0.16%)15.24s (± 0.48%)~15.13s15.30sp=0.335 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time18.82s (± 0.15%)18.78s (± 0.41%)~18.67s18.85sp=0.688 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)
BenchmarkNameIterations
Currentpr6
Baselinebaseline6

tsserver

Comparison Report - baseline..pr
MetricbaselineprDeltaBestWorstp-value
Compiler-UnionsTSServer - node (v18.15.0, x64)
Req 1 - updateOpen2,301ms (± 0.29%)2,242ms (± 0.71%)-59ms (- 2.56%)2,221ms2,259msp=0.005 n=6
Req 2 - geterr5,060ms (± 0.37%)5,075ms (± 0.60%)~5,023ms5,107msp=0.335 n=6
Req 3 - references264ms (± 0.15%)266ms (± 1.18%)~264ms272msp=0.248 n=6
Req 4 - navto227ms (± 1.48%)226ms (± 1.40%)~222ms229msp=0.607 n=6
Req 5 - completionInfo count1,3571,357~~~p=1.000 n=6
Req 5 - completionInfo89ms (± 2.30%)89ms (± 6.61%)~78ms94msp=0.531 n=6
CompilerTSServer - node (v18.15.0, x64)
Req 1 - updateOpen2,419ms (± 0.55%)2,360ms (± 0.65%)-60ms (- 2.46%)2,345ms2,384msp=0.005 n=6
Req 2 - geterr3,797ms (± 0.41%)3,802ms (± 0.21%)~3,792ms3,815msp=0.378 n=6
Req 3 - references277ms (± 0.30%)277ms (± 0.15%)~276ms277msp=0.285 n=6
Req 4 - navto226ms (± 0.33%)226ms (± 0.53%)~224ms227msp=0.485 n=6
Req 5 - completionInfo count1,5191,519~~~p=1.000 n=6
Req 5 - completionInfo73ms (± 8.26%)73ms (± 8.07%)~69ms84msp=1.000 n=6
xstate-main-1-tsserver - node (v18.15.0, x64)
Req 1 - updateOpen6,217ms (± 0.43%)6,249ms (± 4.61%)~6,101ms6,836msp=0.066 n=6
Req 2 - geterr1,577ms (±10.42%)1,582ms (±11.03%)~1,353ms1,710msp=0.936 n=6
Req 3 - references118ms (± 4.38%)112ms (± 7.33%)~99ms122msp=0.213 n=6
Req 4 - navto606ms (± 2.37%)599ms (± 2.44%)~580ms620msp=0.378 n=6
Req 5 - completionInfo count3,4133,413~~~p=1.000 n=6
Req 5 - completionInfo1,268ms (± 2.05%)1,255ms (± 1.67%)~1,234ms1,284msp=0.377 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • CompilerTSServer - node (v18.15.0, x64)
  • Compiler-UnionsTSServer - node (v18.15.0, x64)
  • xstate-main-1-tsserver - node (v18.15.0, x64)
BenchmarkNameIterations
Currentpr6
Baselinebaseline6

startup

Comparison Report - baseline..pr
MetricbaselineprDeltaBestWorstp-value
tsc-startup - node (v18.15.0, x64)
Execution time188.04ms (± 0.17%)188.07ms (± 0.17%)~186.53ms192.34msp=0.188 n=600
tsserver-startup - node (v18.15.0, x64)
Execution time230.59ms (± 0.12%)230.73ms (± 0.12%)+0.14ms (+ 0.06%)229.43ms233.17msp=0.000 n=600
tsserverlibrary-startup - node (v18.15.0, x64)
Execution time225.92ms (± 0.13%)226.09ms (± 0.15%)+0.16ms (+ 0.07%)224.82ms232.69msp=0.000 n=600
typescript-startup - node (v18.15.0, x64)
Execution time226.00ms (± 0.13%)226.46ms (± 0.14%)+0.46ms (+ 0.20%)224.95ms231.90msp=0.000 n=600
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • tsc-startup - node (v18.15.0, x64)
  • tsserver-startup - node (v18.15.0, x64)
  • tsserverlibrary-startup - node (v18.15.0, x64)
  • typescript-startup - node (v18.15.0, x64)
BenchmarkNameIterations
Currentpr6
Baselinebaseline6

Developer Information:

Download Benchmarks

@DanielRosenwasser

Copy link
Copy Markdown
MemberAuthor

I'm actually not sure if that's much better or not, it could just be a better run.

TypeScript Bot (@typescript-bot) pack this

@typescript-bot

TypeScript Bot (typescript-bot) commented Jul 2, 2024

Copy link
Copy Markdown
Contributor

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

CommandStatusResults
pack this✅ Started✅ Results

@typescript-bot

TypeScript Bot (typescript-bot) commented Jul 2, 2024

Copy link
Copy Markdown
Contributor

Hey Daniel Rosenwasser (@DanielRosenwasser), 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/162560/artifacts?artifactName=tgz&fileId=4AA9667F9E1F7B8C6212CF52192D9CDF3B283A368A7D0AD742ABB748FCC2402602&fileName=/typescript-5.6.0-insiders.20240702.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/pr-build@5.6.0-pr-59106-14".;

@DanielRosenwasserDaniel Rosenwasser (DanielRosenwasser) changed the title Experiments with token scanningOptimize scan with a lookup table to reduce branchingJul 2, 2024
@DanielRosenwasser

Daniel Rosenwasser (DanielRosenwasser) commented Jul 2, 2024

Copy link
Copy Markdown
MemberAuthor

TypeScript Bot (@typescript-bot) pack this

@typescript-bot

TypeScript Bot (typescript-bot) commented Jul 2, 2024

Copy link
Copy Markdown
Contributor

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

CommandStatusResults
pack this✅ Started✅ Results

@DanielRosenwasser

Copy link
Copy Markdown
MemberAuthor

TypeScript Bot (@typescript-bot) test top400
TypeScript Bot (@typescript-bot) perf test this

@typescript-bot

TypeScript Bot (typescript-bot) commented Jul 2, 2024

Copy link
Copy Markdown
Contributor

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

CommandStatusResults
test top400✅ Started✅ Results
perf test this✅ Started👀 Results

@typescript-bot

TypeScript Bot (typescript-bot) commented Jul 2, 2024

Copy link
Copy Markdown
Contributor

Hey Daniel Rosenwasser (@DanielRosenwasser), 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/162561/artifacts?artifactName=tgz&fileId=E35843EEA10E387D43B75BB02FEF6B9CF5F7BA42782FB52C26B1840A976DBB6102&fileName=/typescript-5.6.0-insiders.20240702.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/pr-build@5.6.0-pr-59106-19".;

@typescript-bot

Copy link
Copy Markdown
Contributor

Daniel Rosenwasser (@DanielRosenwasser)
The results of the perf run you requested are in!

Here they are:

tsc

Comparison Report - baseline..pr
MetricbaselineprDeltaBestWorstp-value
Compiler-Unions - node (v18.15.0, x64)
Errors3030~~~p=1.000 n=6
Symbols62,15362,153~~~p=1.000 n=6
Types50,24250,242~~~p=1.000 n=6
Memory used193,427k (± 0.92%)192,159k (± 0.02%)~192,113k192,244kp=0.298 n=6
Parse Time1.31s (± 0.75%)1.24s (± 0.83%)🟩-0.07s (- 5.21%)1.23s1.26sp=0.004 n=6
Bind Time0.71s0.71s~~~p=1.000 n=6
Check Time9.43s (± 0.61%)9.45s (± 0.26%)~9.40s9.47sp=0.519 n=6
Emit Time2.75s (± 0.88%)2.73s (± 1.37%)~2.66s2.76sp=0.255 n=6
Total Time14.20s (± 0.45%)14.13s (± 0.34%)~14.05s14.19sp=0.064 n=6
angular-1 - node (v18.15.0, x64)
Errors55~~~p=1.000 n=6
Symbols944,114944,114~~~p=1.000 n=6
Types407,050407,050~~~p=1.000 n=6
Memory used1,218,317k (± 0.00%)1,218,356k (± 0.00%)~1,218,316k1,218,402kp=0.092 n=6
Parse Time7.99s (± 0.52%)7.88s (± 0.69%)-0.11s (- 1.34%)7.81s7.95sp=0.006 n=6
Bind Time2.22s (± 0.34%)2.22s (± 0.55%)~2.20s2.23sp=0.503 n=6
Check Time35.89s (± 0.71%)35.81s (± 0.49%)~35.55s36.04sp=0.688 n=6
Emit Time16.19s (± 0.34%)16.19s (± 0.36%)~16.08s16.24sp=0.809 n=6
Total Time62.29s (± 0.45%)62.10s (± 0.28%)~61.88s62.36sp=0.230 n=6
mui-docs - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols2,136,9392,136,939~~~p=1.000 n=6
Types929,123929,123~~~p=1.000 n=6
Memory used2,117,686k (± 0.01%)2,117,782k (± 0.00%)~2,117,617k2,117,884kp=0.230 n=6
Parse Time9.70s (± 0.34%)9.54s (± 0.38%)-0.16s (- 1.60%)9.50s9.59sp=0.005 n=6
Bind Time3.38s (± 0.51%)3.40s (± 0.37%)+0.02s (+ 0.64%)3.39s3.42sp=0.035 n=6
Check Time102.88s (± 0.57%)101.50s (± 1.84%)~99.72s103.42sp=0.378 n=6
Emit Time0.20s (± 4.15%)0.20s (± 4.47%)~0.19s0.21sp=0.550 n=6
Total Time116.15s (± 0.51%)114.64s (± 1.60%)~112.87s116.51sp=0.298 n=6
self-build-src - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols1,225,2811,225,412+131 (+ 0.01%)~~p=0.001 n=6
Types261,342261,448+106 (+ 0.04%)~~p=0.001 n=6
Memory used2,341,955k (± 0.05%)2,341,458k (± 0.03%)~2,340,732k2,342,696kp=0.230 n=6
Parse Time6.01s (± 0.91%)5.93s (± 0.81%)~5.89s5.99sp=0.061 n=6
Bind Time2.26s (± 0.93%)2.25s (± 0.76%)~2.23s2.27sp=0.809 n=6
Check Time40.21s (± 0.31%)40.29s (± 0.78%)~40.08s40.92sp=0.936 n=6
Emit Time3.06s (± 4.86%)3.06s (± 2.89%)~2.88s3.11sp=0.574 n=6
Total Time51.57s (± 0.44%)51.56s (± 0.67%)~51.22s52.21sp=0.689 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols1,225,2811,225,412+131 (+ 0.01%)~~p=0.001 n=6
Types261,342261,448+106 (+ 0.04%)~~p=0.001 n=6
Memory used2,415,657k (± 0.02%)2,415,756k (± 0.04%)~2,414,302k2,417,226kp=0.810 n=6
Parse Time7.74s (± 0.38%)7.60s (± 0.79%)-0.14s (- 1.77%)7.54s7.68sp=0.005 n=6
Bind Time2.51s (± 0.70%)2.51s (± 0.91%)~2.47s2.53sp=0.628 n=6
Check Time50.15s (± 0.31%)50.46s (± 0.63%)+0.31s (+ 0.62%)50.09s51.05sp=0.045 n=6
Emit Time3.82s (± 2.13%)3.90s (± 2.95%)~3.73s4.08sp=0.149 n=6
Total Time64.23s (± 0.21%)64.48s (± 0.63%)~63.95s65.17sp=0.109 n=6
self-compiler - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols258,194258,325+131 (+ 0.05%)~~p=0.001 n=6
Types104,737104,843+106 (+ 0.10%)~~p=0.001 n=6
Memory used427,519k (± 0.00%)427,684k (± 0.01%)+164k (+ 0.04%)427,650k427,708kp=0.005 n=6
Parse Time3.31s (± 1.05%)3.21s (± 0.65%)🟩-0.10s (- 3.02%)3.19s3.24sp=0.005 n=6
Bind Time1.32s (± 0.31%)1.29s (± 1.16%)-0.03s (- 2.14%)1.28s1.32sp=0.010 n=6
Check Time17.82s (± 0.39%)17.84s (± 0.39%)~17.73s17.91sp=0.810 n=6
Emit Time1.25s (± 1.17%)1.25s (± 0.94%)~1.24s1.27sp=0.680 n=6
Total Time23.71s (± 0.33%)23.60s (± 0.33%)-0.11s (- 0.46%)23.48s23.68sp=0.045 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors3535~~~p=1.000 n=6
Symbols224,565224,565~~~p=1.000 n=6
Types93,73493,734~~~p=1.000 n=6
Memory used369,504k (± 0.02%)369,545k (± 0.03%)~369,396k369,689kp=0.575 n=6
Parse Time2.77s (± 1.64%)2.71s (± 0.77%)-0.06s (- 2.11%)2.67s2.73sp=0.029 n=6
Bind Time1.58s (± 0.96%)1.58s (± 0.33%)~1.57s1.58sp=0.351 n=6
Check Time15.48s (± 0.24%)15.48s (± 0.25%)~15.41s15.51sp=1.000 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time19.83s (± 0.22%)19.77s (± 0.28%)-0.07s (- 0.34%)19.66s19.82sp=0.037 n=6
vscode - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols2,879,7802,879,780~~~p=1.000 n=6
Types975,260975,260~~~p=1.000 n=6
Memory used3,042,725k (± 0.00%)3,042,710k (± 0.00%)~3,042,618k3,042,860kp=0.810 n=6
Parse Time13.69s (± 0.56%)13.54s (± 0.36%)-0.16s (- 1.16%)13.47s13.62sp=0.008 n=6
Bind Time4.19s (± 0.25%)4.26s (± 2.08%)+0.07s (+ 1.71%)4.18s4.41sp=0.037 n=6
Check Time73.60s (± 0.73%)74.17s (± 1.36%)~73.00s75.93sp=0.298 n=6
Emit Time24.11s (± 2.28%)23.59s (± 4.16%)~21.91s24.44sp=0.687 n=6
Total Time115.59s (± 0.33%)115.56s (± 0.24%)~115.18s115.86sp=0.810 n=6
webpack - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols267,117267,117~~~p=1.000 n=6
Types108,775108,775~~~p=1.000 n=6
Memory used411,550k (± 0.02%)411,617k (± 0.02%)~411,549k411,731kp=0.093 n=6
Parse Time3.18s (± 0.37%)3.12s (± 0.43%)-0.06s (- 1.78%)3.10s3.14sp=0.004 n=6
Bind Time1.41s (± 0.37%)1.41s (± 0.59%)~1.39s1.41sp=0.070 n=6
Check Time14.21s (± 0.25%)14.21s (± 0.26%)~14.14s14.24sp=0.936 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time18.81s (± 0.22%)18.73s (± 0.26%)-0.08s (- 0.40%)18.64s18.78sp=0.009 n=6
xstate-main - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols525,251525,251~~~p=1.000 n=6
Types178,574178,574~~~p=1.000 n=6
Memory used463,001k (± 0.07%)463,009k (± 0.05%)~462,622k463,281kp=0.810 n=6
Parse Time2.66s (± 0.39%)2.56s (± 0.67%)🟩-0.09s (- 3.52%)2.54s2.58sp=0.005 n=6
Bind Time0.98s (± 0.77%)0.97s (± 0.86%)~0.97s0.99sp=0.172 n=6
Check Time15.19s (± 0.26%)15.25s (± 0.37%)~15.20s15.34sp=0.126 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time18.82s (± 0.23%)18.79s (± 0.34%)~18.74s18.91sp=0.334 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)
BenchmarkNameIterations
Currentpr6
Baselinebaseline6

tsserver

Comparison Report - baseline..pr
MetricbaselineprDeltaBestWorstp-value
Compiler-UnionsTSServer - node (v18.15.0, x64)
Req 1 - updateOpen2,294ms (± 0.34%)2,235ms (± 0.76%)-60ms (- 2.59%)2,223ms2,265msp=0.005 n=6
Req 2 - geterr5,061ms (± 0.50%)5,077ms (± 0.46%)~5,050ms5,116msp=0.298 n=6
Req 3 - references265ms (± 1.25%)264ms (± 0.28%)~263ms265msp=0.931 n=6
Req 4 - navto227ms (± 0.53%)227ms (± 1.18%)~222ms230msp=0.931 n=6
Req 5 - completionInfo count1,3571,357~~~p=1.000 n=6
Req 5 - completionInfo87ms (± 3.88%)88ms (± 6.22%)~78ms93msp=0.391 n=6
CompilerTSServer - node (v18.15.0, x64)
Req 1 - updateOpen2,431ms (± 0.56%)2,364ms (± 0.24%)-67ms (- 2.77%)2,357ms2,372msp=0.005 n=6
Req 2 - geterr3,798ms (± 0.18%)3,791ms (± 0.42%)~3,774ms3,816msp=0.378 n=6
Req 3 - references277ms (± 0.29%)276ms (± 0.46%)~275ms278msp=0.082 n=6
Req 4 - navto227ms (± 0.28%)229ms (± 2.83%)~225ms242msp=0.438 n=6
Req 5 - completionInfo count1,5191,519~~~p=1.000 n=6
Req 5 - completionInfo79ms (± 9.11%)78ms (± 8.10%)~69ms85msp=0.677 n=6
xstate-main-1-tsserver - node (v18.15.0, x64)
Req 1 - updateOpen6,342ms (± 5.02%)6,109ms (± 0.55%)🟩-233ms (- 3.67%)6,056ms6,160msp=0.005 n=6
Req 2 - geterr1,597ms (±10.84%)1,585ms (±10.42%)~1,364ms1,721msp=0.689 n=6
Req 3 - references113ms (± 4.02%)114ms (± 4.48%)~110ms121msp=0.561 n=6
Req 4 - navto597ms (± 2.78%)596ms (± 1.51%)~586ms609msp=0.810 n=6
Req 5 - completionInfo count3,4133,413~~~p=1.000 n=6
Req 5 - completionInfo1,251ms (± 1.60%)1,254ms (± 1.32%)~1,234ms1,274msp=0.873 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • CompilerTSServer - node (v18.15.0, x64)
  • Compiler-UnionsTSServer - node (v18.15.0, x64)
  • xstate-main-1-tsserver - node (v18.15.0, x64)
BenchmarkNameIterations
Currentpr6
Baselinebaseline6

startup

Comparison Report - baseline..pr
MetricbaselineprDeltaBestWorstp-value
tsc-startup - node (v18.15.0, x64)
Execution time157.17ms (± 0.20%)157.21ms (± 0.16%)+0.03ms (+ 0.02%)156.22ms160.96msp=0.047 n=600
tsserver-startup - node (v18.15.0, x64)
Execution time230.32ms (± 0.21%)230.43ms (± 0.14%)+0.11ms (+ 0.05%)229.08ms236.21msp=0.000 n=600
tsserverlibrary-startup - node (v18.15.0, x64)
Execution time226.63ms (± 0.14%)226.87ms (± 0.14%)+0.24ms (+ 0.11%)225.59ms231.38msp=0.000 n=600
typescript-startup - node (v18.15.0, x64)
Execution time275.26ms (± 0.28%)276.27ms (± 0.73%)+1.01ms (+ 0.37%)269.29ms308.09msp=0.000 n=600
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • tsc-startup - node (v18.15.0, x64)
  • tsserver-startup - node (v18.15.0, x64)
  • tsserverlibrary-startup - node (v18.15.0, x64)
  • typescript-startup - node (v18.15.0, x64)
BenchmarkNameIterations
Currentpr6
Baselinebaseline6

Developer Information:

Download Benchmarks

@DanielRosenwasser
Daniel Rosenwasser (DanielRosenwasser) marked this pull request as ready for review July 2, 2024 20:30
@typescript-bot

Copy link
Copy Markdown
Contributor

Daniel Rosenwasser (@DanielRosenwasser) Here are the results of running the top 400 repos with tsc comparing main and refs/pull/59106/merge:

Everything looks good!

@DanielRosenwasser

Copy link
Copy Markdown
MemberAuthor

Titian Cernicova-Dragomir (@dragomirtitian) maybe this balances out the parse-time hit from #58928. 😄

@DanielRosenwasser

Copy link
Copy Markdown
MemberAuthor

TypeScript Bot (@typescript-bot) perf test this

@typescript-bot

TypeScript Bot (typescript-bot) commented Jul 3, 2024

Copy link
Copy Markdown
Contributor

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

CommandStatusResults
perf test this✅ Started👀 Results

@typescript-bot

Copy link
Copy Markdown
Contributor

Daniel Rosenwasser (@DanielRosenwasser)
The results of the perf run you requested are in!

Here they are:

tsc

Comparison Report - baseline..pr
MetricbaselineprDeltaBestWorstp-value
Compiler-Unions - node (v18.15.0, x64)
Errors3030~~~p=1.000 n=6
Symbols62,15362,153~~~p=1.000 n=6
Types50,24250,242~~~p=1.000 n=6
Memory used192,850k (± 0.77%)193,503k (± 0.93%)~192,149k195,866kp=0.261 n=6
Parse Time1.58s (± 0.48%)1.50s (± 1.09%)🟩-0.08s (- 4.85%)1.49s1.53sp=0.005 n=6
Bind Time0.86s (± 1.41%)0.85s (± 1.16%)~0.84s0.86sp=0.246 n=6
Check Time11.18s (± 0.60%)11.21s (± 0.17%)~11.18s11.23sp=0.520 n=6
Emit Time3.28s (± 0.76%)3.29s (± 0.95%)~3.25s3.32sp=0.808 n=6
Total Time16.90s (± 0.19%)16.85s (± 0.19%)~16.82s16.89sp=0.065 n=6
angular-1 - node (v18.15.0, x64)
Errors55~~~p=1.000 n=6
Symbols944,114944,114~~~p=1.000 n=6
Types407,050407,050~~~p=1.000 n=6
Memory used1,218,371k (± 0.00%)1,218,388k (± 0.00%)~1,218,311k1,218,446kp=0.575 n=6
Parse Time7.96s (± 0.64%)7.90s (± 0.49%)-0.07s (- 0.82%)7.84s7.93sp=0.030 n=6
Bind Time2.24s (± 1.08%)2.22s (± 0.66%)~2.21s2.25sp=0.145 n=6
Check Time35.73s (± 0.40%)35.87s (± 0.43%)~35.65s36.13sp=0.171 n=6
Emit Time16.11s (± 0.32%)16.18s (± 0.22%)~16.14s16.23sp=0.052 n=6
Total Time62.04s (± 0.33%)62.17s (± 0.27%)~61.90s62.43sp=0.229 n=6
mui-docs - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols2,154,9492,154,949~~~p=1.000 n=6
Types931,473931,473~~~p=1.000 n=6
Memory used2,125,930k (± 0.00%)2,126,089k (± 0.00%)+159k (+ 0.01%)2,126,001k2,126,145kp=0.005 n=6
Parse Time9.77s (± 0.34%)9.56s (± 0.33%)-0.21s (- 2.20%)9.52s9.61sp=0.005 n=6
Bind Time3.39s (± 0.37%)3.38s (± 0.51%)~3.36s3.40sp=0.415 n=6
Check Time103.96s (± 0.62%)103.99s (± 0.33%)~103.33s104.29sp=1.000 n=6
Emit Time0.19s (± 2.13%)0.20s🔻+0.01s (+ 4.35%)~~p=0.007 n=6
Total Time117.31s (± 0.55%)117.12s (± 0.31%)~116.41s117.43sp=0.297 n=6
self-build-src - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols1,225,2811,225,413+132 (+ 0.01%)~~p=0.001 n=6
Types261,342261,448+106 (+ 0.04%)~~p=0.001 n=6
Memory used2,342,013k (± 0.03%)2,341,774k (± 0.04%)~2,340,479k2,343,198kp=0.471 n=6
Parse Time6.03s (± 1.12%)5.99s (± 1.09%)~5.91s6.09sp=0.336 n=6
Bind Time2.26s (± 0.87%)2.27s (± 1.02%)~2.23s2.29sp=0.686 n=6
Check Time40.22s (± 0.60%)40.42s (± 0.49%)~40.11s40.63sp=0.128 n=6
Emit Time3.05s (± 1.85%)3.11s (± 6.04%)~2.93s3.47sp=0.873 n=6
Total Time51.56s (± 0.52%)51.79s (± 0.47%)~51.37s52.11sp=0.128 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols1,225,2811,225,413+132 (+ 0.01%)~~p=0.001 n=6
Types261,342261,448+106 (+ 0.04%)~~p=0.001 n=6
Memory used2,414,808k (± 0.05%)2,415,265k (± 0.03%)~2,414,227k2,416,053kp=0.689 n=6
Parse Time7.79s (± 0.85%)7.64s (± 0.36%)-0.15s (- 1.95%)7.61s7.69sp=0.008 n=6
Bind Time2.51s (± 0.48%)2.52s (± 1.03%)~2.48s2.55sp=0.518 n=6
Check Time50.32s (± 0.43%)50.45s (± 0.31%)~50.17s50.62sp=0.298 n=6
Emit Time3.94s (± 2.65%)3.99s (± 4.57%)~3.89s4.36sp=0.298 n=6
Total Time64.58s (± 0.34%)64.61s (± 0.40%)~64.20s64.99sp=0.936 n=6
self-compiler - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols258,194258,326+132 (+ 0.05%)~~p=0.001 n=6
Types104,737104,843+106 (+ 0.10%)~~p=0.001 n=6
Memory used427,488k (± 0.01%)427,701k (± 0.01%)+213k (+ 0.05%)427,650k427,748kp=0.005 n=6
Parse Time3.28s (± 0.60%)3.26s (± 0.19%)-0.02s (- 0.71%)3.25s3.27sp=0.048 n=6
Bind Time1.31s (± 1.12%)1.32s (± 1.82%)~1.29s1.35sp=0.514 n=6
Check Time17.76s (± 0.29%)17.77s (± 0.35%)~17.69s17.87sp=1.000 n=6
Emit Time1.25s (± 1.31%)1.25s (± 1.20%)~1.24s1.27sp=0.458 n=6
Total Time23.60s (± 0.30%)23.60s (± 0.37%)~23.51s23.75sp=0.810 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors3535~~~p=1.000 n=6
Symbols224,565224,565~~~p=1.000 n=6
Types93,73493,734~~~p=1.000 n=6
Memory used369,475k (± 0.04%)369,514k (± 0.04%)~369,393k369,750kp=0.298 n=6
Parse Time2.76s (± 0.88%)2.74s (± 1.41%)~2.68s2.79sp=0.376 n=6
Bind Time1.59s (± 0.94%)1.59s (± 1.30%)~1.58s1.62sp=0.666 n=6
Check Time15.46s (± 0.26%)15.49s (± 0.36%)~15.42s15.56sp=0.469 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time19.81s (± 0.18%)19.83s (± 0.30%)~19.78s19.93sp=0.747 n=6
vscode - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols2,879,7912,879,791~~~p=1.000 n=6
Types975,122975,122~~~p=1.000 n=6
Memory used3,043,017k (± 0.00%)3,042,990k (± 0.00%)~3,042,960k3,043,023kp=0.298 n=6
Parse Time13.71s (± 0.75%)13.56s (± 0.41%)-0.14s (- 1.06%)13.47s13.62sp=0.016 n=6
Bind Time4.30s (± 2.90%)4.19s (± 0.30%)~4.18s4.21sp=0.369 n=6
Check Time73.88s (± 2.34%)74.11s (± 2.25%)~73.21s77.49sp=0.092 n=6
Emit Time23.67s (± 6.92%)23.66s (± 6.60%)~20.50s24.48sp=0.810 n=6
Total Time115.55s (± 0.26%)115.52s (± 0.34%)~114.87s115.91sp=1.000 n=6
webpack - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols267,117267,117~~~p=1.000 n=6
Types108,775108,775~~~p=1.000 n=6
Memory used411,562k (± 0.02%)411,552k (± 0.01%)~411,496k411,643kp=0.936 n=6
Parse Time3.18s (± 0.67%)3.14s (± 0.20%)-0.04s (- 1.21%)3.13s3.15sp=0.004 n=6
Bind Time1.41s1.42s (± 0.39%)~1.41s1.42sp=0.071 n=6
Check Time14.20s (± 0.31%)14.16s (± 0.31%)~14.09s14.22sp=0.127 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time18.79s (± 0.27%)18.71s (± 0.26%)-0.08s (- 0.41%)18.64s18.78sp=0.037 n=6
xstate-main - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols525,251525,251~~~p=1.000 n=6
Types178,574178,574~~~p=1.000 n=6
Memory used462,855k (± 0.08%)462,947k (± 0.04%)~462,673k463,208kp=0.810 n=6
Parse Time3.93s (± 0.57%)3.83s (± 0.26%)-0.10s (- 2.58%)3.82s3.84sp=0.004 n=6
Bind Time1.46s (± 1.28%)1.46s (± 0.71%)~1.44s1.47sp=1.000 n=6
Check Time22.15s (± 0.28%)22.17s (± 0.28%)~22.09s22.27sp=0.463 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time27.54s (± 0.24%)27.47s (± 0.26%)~27.37s27.57sp=0.127 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)
BenchmarkNameIterations
Currentpr6
Baselinebaseline6

tsserver

Comparison Report - baseline..pr
MetricbaselineprDeltaBestWorstp-value
Compiler-UnionsTSServer - node (v18.15.0, x64)
Req 1 - updateOpen2,295ms (± 0.54%)2,244ms (± 0.54%)-50ms (- 2.19%)2,230ms2,259msp=0.005 n=6
Req 2 - geterr5,068ms (± 0.37%)5,072ms (± 0.32%)~5,056ms5,100msp=0.689 n=6
Req 3 - references263ms (± 0.44%)264ms (± 0.50%)~262ms266msp=0.216 n=6
Req 4 - navto229ms (± 0.81%)227ms (± 0.72%)~224ms228msp=0.177 n=6
Req 5 - completionInfo count1,3571,357~~~p=1.000 n=6
Req 5 - completionInfo84ms (± 8.24%)87ms (± 5.91%)~78ms94msp=0.432 n=6
CompilerTSServer - node (v18.15.0, x64)
Req 1 - updateOpen2,414ms (± 0.41%)2,387ms (± 0.59%)-27ms (- 1.13%)2,370ms2,406msp=0.008 n=6
Req 2 - geterr3,794ms (± 0.37%)3,795ms (± 0.33%)~3,780ms3,809msp=1.000 n=6
Req 3 - references277ms (± 0.29%)277ms (± 0.35%)~275ms278msp=0.604 n=6
Req 4 - navto226ms (± 0.33%)227ms (± 0.18%)~226ms227msp=0.100 n=6
Req 5 - completionInfo count1,5191,519~~~p=1.000 n=6
Req 5 - completionInfo75ms (± 7.21%)77ms (±10.31%)~69ms85msp=1.000 n=6
xstate-main-1-tsserver - node (v18.15.0, x64)
Req 1 - updateOpen5,182ms (± 0.20%)5,116ms (± 0.28%)-66ms (- 1.28%)5,100ms5,135msp=0.005 n=6
Req 2 - geterr1,129ms (± 0.88%)1,123ms (± 0.18%)~1,120ms1,125msp=0.196 n=6
Req 3 - references77ms (± 4.67%)75ms (± 0.54%)~74ms75msp=0.114 n=6
Req 4 - navto460ms (± 1.04%)457ms (± 0.11%)~457ms458msp=1.000 n=6
Req 5 - completionInfo count3,4133,413~~~p=1.000 n=6
Req 5 - completionInfo834ms (± 1.52%)832ms (± 1.05%)~823ms848msp=0.748 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • CompilerTSServer - node (v18.15.0, x64)
  • Compiler-UnionsTSServer - node (v18.15.0, x64)
  • xstate-main-1-tsserver - node (v18.15.0, x64)
BenchmarkNameIterations
Currentpr6
Baselinebaseline6

startup

Comparison Report - baseline..pr
MetricbaselineprDeltaBestWorstp-value
tsc-startup - node (v18.15.0, x64)
Execution time157.43ms (± 0.16%)157.38ms (± 0.17%)~156.21ms159.84msp=0.074 n=600
tsserver-startup - node (v18.15.0, x64)
Execution time230.50ms (± 0.15%)230.58ms (± 0.15%)+0.08ms (+ 0.04%)229.33ms236.14msp=0.025 n=600
tsserverlibrary-startup - node (v18.15.0, x64)
Execution time226.02ms (± 0.15%)226.16ms (± 0.17%)+0.14ms (+ 0.06%)224.63ms232.34msp=0.000 n=600
typescript-startup - node (v18.15.0, x64)
Execution time225.25ms (± 0.15%)225.33ms (± 0.13%)+0.08ms (+ 0.04%)224.05ms227.31msp=0.003 n=600
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • tsc-startup - node (v18.15.0, x64)
  • tsserver-startup - node (v18.15.0, x64)
  • tsserverlibrary-startup - node (v18.15.0, x64)
  • typescript-startup - node (v18.15.0, x64)
BenchmarkNameIterations
Currentpr6
Baselinebaseline6

Developer Information:

Download Benchmarks

}

const tokenCategoryLookup: TokenCategory[] = [];
const tokenCategoryLookupUncommon = new Map<CharacterCodes, TokenCategory>();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How does map lookup performance and memory usage compare to branching ifs with comparison operators?

[CharacterCodes.replacementCharacter, TokenCategory.RecognizedMisc],
]
) {
if (key < tokenCategoryLookup.length) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why do this in a branch? The uncommon lookups could just be passed to the Map constructor.

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.

Can you be more specific? In the first two commits, I split this out from a map to an array and map to avoid the map lookup.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I mean that, since we know ahead of time which characters belong in the Map, we can just construct the map with those character codes rather than looping and comparing. It's not that important, and if it makes more sense to have them visually grouped together, that's perfectly fine.

}

if (!(tokenCategory & TokenCategory.RecognizedMisc)) Debug.fail(`Unhandled token category ${tokenCategory}`);
switch (ch) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder if the switch here is optimized in any way or if it is doing case-by-case comparisons against each character code. If the latter, maybe it would be worthwhile to analyze what that most common character codes in JS are and change the order of the cases so that the more frequent cases are earlier in the list. I expect the perf improvement here actually comes from handling digit and identifier characters earlier than the switch, since those are the most frequent characters in a given file. If that's the case, some of the complexity and memory overhead could be reduced by just optimizing for those two cases.

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.

I think it is typically case-by-case comparisons. You're absolutely right that doing the checks earlier on for common classes; however, I think that checking for all the identifier starts isn't practical (or requires the same sort of fast-path/slow-path separation where we check for ranges), so that's why the token categorization is helpful here. By dismissing all the other types of categories, we can immediately launch into the fast path.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Assuming CharacterCodes is a const enum, the VM should be able to optimize the switch case quite heavily as a branch table, but that's a question for V8.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If the majority of identifier/keyword characters are ASCII characters, then it's fairly trivial to check for those major cases without an array or Map using a simple comparison:

if((ch|32)>=CharacterCodes.a&&(ch|32)<=CharacterCodes.z||ch===CharacterCodes._||ch===CharacterCodes.$){/* [A-Za-z_$] */}

If the array/map lookups are faster than this for the identifier case, then by all means keep it as is. I only point this out as you explicitly avoid hitting the table for line terminators and spaces. If that was an important optimization, then it might make sense to do the same kind of optimization for the most frequent (and easy to optimize for) characters in a source file, e.g., ASCII letters.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Assuming CharacterCodes is a const enum, the VM should be able to optimize the switch case quite heavily as a branch table, but that's a question for V8.

We've generally found that not to be the case, which is why we've had to implement our own jump tables for functions like forEachChild. I'm not sure what heuristics V8 uses for switch optimization, if any.

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.

If the majority of identifier/keyword characters are ASCII characters, then it's fairly trivial to check for those major cases without an array or Map using a simple comparison:

Fair, and this is what Anders Hejlsberg (@ahejlsberg) also suggested. The same way whitespace is prioritized, ASCII range is also very likely and worth prioritizing as a quicker up-front case instead of hitting the lookup table. It would mean there's some code duplication but maybe it's fine.

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.

Assuming CharacterCodes is a const enum, the VM should be able to optimize the switch case quite heavily as a branch table, but that's a question for V8.

We've generally found that not to be the case, which is why we've had to implement our own jump tables for functions like forEachChild. I'm not sure what heuristics V8 uses for switch optimization, if any.

Especially in the case where these character codes are so sparse - I am very doubtful that V8 would do such an optimization, and at best I'd guess we'd end up with something like a binary search.


if (tokenCategory & TokenCategory.SimpleToken) {
pos++;
return token = tokenCategory & TokenCategory.SimpleTokenMask;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A comment here would be good for future readers as it isn't obvious at first glance how a TokenCategory becomes a token.

Comment on lines +2067 to +2101
if (ch === CharacterCodes._0) {
if (pos + 2 < end && (charCodeUnchecked(pos + 1) === CharacterCodes.X || charCodeUnchecked(pos + 1) === CharacterCodes.x)) {
pos += 2;
tokenValue = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ true);
if (!tokenValue) {
error(Diagnostics.Hexadecimal_digit_expected);
tokenValue = "0";
}
else {
pos++;
tokenValue = "0x" + tokenValue;
tokenFlags |= TokenFlags.HexSpecifier;
return token = checkBigIntSuffix();
}
else if (pos + 2 < end && (charCodeUnchecked(pos + 1) === CharacterCodes.B || charCodeUnchecked(pos + 1) === CharacterCodes.b)) {
pos += 2;
tokenValue = scanBinaryOrOctalDigits(/* base */ 2);
if (!tokenValue) {
error(Diagnostics.Binary_digit_expected);
tokenValue = "0";
}
return token = SyntaxKind.NewLineTrivia;
}
case CharacterCodes.tab:
case CharacterCodes.verticalTab:
case CharacterCodes.formFeed:
case CharacterCodes.space:
case CharacterCodes.nonBreakingSpace:
case CharacterCodes.ogham:
case CharacterCodes.enQuad:
case CharacterCodes.emQuad:
case CharacterCodes.enSpace:
case CharacterCodes.emSpace:
case CharacterCodes.threePerEmSpace:
case CharacterCodes.fourPerEmSpace:
case CharacterCodes.sixPerEmSpace:
case CharacterCodes.figureSpace:
case CharacterCodes.punctuationSpace:
case CharacterCodes.thinSpace:
case CharacterCodes.hairSpace:
case CharacterCodes.zeroWidthSpace:
case CharacterCodes.narrowNoBreakSpace:
case CharacterCodes.mathematicalSpace:
case CharacterCodes.ideographicSpace:
case CharacterCodes.byteOrderMark:
if (skipTrivia) {
pos++;
continue;
tokenValue = "0b" + tokenValue;
tokenFlags |= TokenFlags.BinarySpecifier;
return token = checkBigIntSuffix();
}
else {
while (pos < end && isWhiteSpaceSingleLine(charCodeUnchecked(pos))) {
pos++;
else if (pos + 2 < end && (charCodeUnchecked(pos + 1) === CharacterCodes.O || charCodeUnchecked(pos + 1) === CharacterCodes.o)) {
pos += 2;
tokenValue = scanBinaryOrOctalDigits(/* base */ 8);
if (!tokenValue) {
error(Diagnostics.Octal_digit_expected);
tokenValue = "0";
}
return token = SyntaxKind.WhitespaceTrivia;
tokenValue = "0o" + tokenValue;
tokenFlags |= TokenFlags.OctalSpecifier;
return token = checkBigIntSuffix();
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
if(ch===CharacterCodes._0){
if(pos+2<end&&(charCodeUnchecked(pos+1)===CharacterCodes.X||charCodeUnchecked(pos+1)===CharacterCodes.x)){
pos+=2;
tokenValue=scanMinimumNumberOfHexDigits(1,/*canHaveSeparators*/true);
if(!tokenValue){
error(Diagnostics.Hexadecimal_digit_expected);
tokenValue="0";
}
else{
pos++;
tokenValue="0x"+tokenValue;
tokenFlags|=TokenFlags.HexSpecifier;
returntoken=checkBigIntSuffix();
}
elseif(pos+2<end&&(charCodeUnchecked(pos+1)===CharacterCodes.B||charCodeUnchecked(pos+1)===CharacterCodes.b)){
pos+=2;
tokenValue=scanBinaryOrOctalDigits(/* base */2);
if(!tokenValue){
error(Diagnostics.Binary_digit_expected);
tokenValue="0";
}
returntoken=SyntaxKind.NewLineTrivia;
}
caseCharacterCodes.tab:
caseCharacterCodes.verticalTab:
caseCharacterCodes.formFeed:
caseCharacterCodes.space:
caseCharacterCodes.nonBreakingSpace:
caseCharacterCodes.ogham:
caseCharacterCodes.enQuad:
caseCharacterCodes.emQuad:
caseCharacterCodes.enSpace:
caseCharacterCodes.emSpace:
caseCharacterCodes.threePerEmSpace:
caseCharacterCodes.fourPerEmSpace:
caseCharacterCodes.sixPerEmSpace:
caseCharacterCodes.figureSpace:
caseCharacterCodes.punctuationSpace:
caseCharacterCodes.thinSpace:
caseCharacterCodes.hairSpace:
caseCharacterCodes.zeroWidthSpace:
caseCharacterCodes.narrowNoBreakSpace:
caseCharacterCodes.mathematicalSpace:
caseCharacterCodes.ideographicSpace:
caseCharacterCodes.byteOrderMark:
if(skipTrivia){
pos++;
continue;
tokenValue="0b"+tokenValue;
tokenFlags|=TokenFlags.BinarySpecifier;
returntoken=checkBigIntSuffix();
}
else{
while(pos<end&&isWhiteSpaceSingleLine(charCodeUnchecked(pos))){
pos++;
elseif(pos+2<end&&(charCodeUnchecked(pos+1)===CharacterCodes.O||charCodeUnchecked(pos+1)===CharacterCodes.o)){
pos+=2;
tokenValue=scanBinaryOrOctalDigits(/* base */8);
if(!tokenValue){
error(Diagnostics.Octal_digit_expected);
tokenValue="0";
}
returntoken=SyntaxKind.WhitespaceTrivia;
tokenValue="0o"+tokenValue;
tokenFlags|=TokenFlags.OctalSpecifier;
returntoken=checkBigIntSuffix();
}
}
if(ch===CharacterCodes._0&&pos+2<end){
switch(charCodeUnchecked(pos+1)){
caseCharacterCodes.X:
caseCharacterCodes.x:
pos+=2;
tokenValue=scanMinimumNumberOfHexDigits(1,/*canHaveSeparators*/true);
if(!tokenValue){
error(Diagnostics.Hexadecimal_digit_expected);
tokenValue="0";
}
tokenValue="0x"+tokenValue;
tokenFlags|=TokenFlags.HexSpecifier;
returntoken=checkBigIntSuffix();
caseCharacterCodes.B:
caseCharacterCodes.b:
pos+=2;
tokenValue=scanBinaryOrOctalDigits(/* base */2);
if(!tokenValue){
error(Diagnostics.Binary_digit_expected);
tokenValue="0";
}
tokenValue="0b"+tokenValue;
tokenFlags|=TokenFlags.BinarySpecifier;
returntoken=checkBigIntSuffix();
caseCharacterCodes.O:
caseCharacterCodes.o:
pos+=2;
tokenValue=scanBinaryOrOctalDigits(/* base */8);
if(!tokenValue){
error(Diagnostics.Octal_digit_expected);
tokenValue="0";
}
tokenValue="0o"+tokenValue;
tokenFlags|=TokenFlags.OctalSpecifier;
returntoken=checkBigIntSuffix();
}

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.

It's hard to parse out what the suggestion is - can you explain it?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah, that's fair, I don't know why GitHub insists on showing the old code in the diff rather than diffing against your PR version of the code.

Suggestion is to promote the pos + 2 < end check to the same if that checks for CharacterCodes._0, since all branches beneath it use that condition, then replace the nested if statements with a single switch (charCodeUnchecked(pos + 1)) with grouped case statements for each of the radix markers.

}

if (!(tokenCategory & TokenCategory.RecognizedMisc)) Debug.fail(`Unhandled token category ${tokenCategory}`);
switch (ch) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Assuming CharacterCodes is a const enum, the VM should be able to optimize the switch case quite heavily as a branch table, but that's a question for V8.

@DanielRosenwasser

Copy link
Copy Markdown
MemberAuthor

#59244 tries to just check for identifiers up-front, and moves checks for space earlier. It is faster, but not as fast as the lookup approach here.

@typescript-bot

Copy link
Copy Markdown
Contributor

With 6.0 out as the final release vehicle for this codebase, we're closing all PRs that don't fit the merge criteria for post-6.0 patches. If you think this was a mistake and this PR fits the post-6.0 patch criteria, please post to the 6.0 iteration issue with details (specifically, which PR and which patch criteria it satisfies).

Next steps for PRs:

  • For crash bugfixes or language service improvements, PRs are currently accepted at the typescript-go repo
  • Changes to type system behavior should wait until after 7.0, at which point mainline TypeScript development will resume in this repository with the Go codebase
  • Library file updates (lib.d.ts etc) continue to live in this repo or the DOM Generator repo as appropriate

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

Labels

Author: TeamFor Uncommitted BugPR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@DanielRosenwasser@typescript-bot@rbuckton@dmichon-msft@RyanCavanaugh