Skip to content

Refactor expression evaluator - #57955

Merged
Wesley Wigham (weswigham) merged 2 commits into
microsoft:mainfrom
bloomberg:refactor-evaluator
Mar 27, 2024
Merged

Refactor expression evaluator#57955
Wesley Wigham (weswigham) merged 2 commits into
microsoft:mainfrom
bloomberg:refactor-evaluator

Conversation

@dragomirtitian

Copy link
Copy Markdown
Contributor

Refactor expression evaluator to sit outside of the checker.

@typescript-botTypeScript Bot (typescript-bot) added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Mar 27, 2024
@typescript-bot

Copy link
Copy Markdown
Contributor

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

@jakebailey

Copy link
Copy Markdown
Member

TypeScript Bot (@typescript-bot) perf test this

@typescript-bot

TypeScript Bot (typescript-bot) commented Mar 27, 2024

Copy link
Copy Markdown
Contributor

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

CommandStatusResults
perf test this✅ Started👀 Results

Comment threadsrc/compiler/checker.ts Outdated
var evaluate = createEvaluator({
evaluateElementAccessExpression,
evaluateEntityNameExpression,
onNumericLiteral: checkGrammarNumericLiteral,

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.

It feels strange to have this callback. This only needs the AST node and nothing else. Can we just walk the nodes like other grammar checks?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I was trying to introduce as little extra overhead as possible, I agree that callback is kinds of the odd one out, but without an extra walk I'm not sure how we could ensure that check is performed in the same way.

The check does appear to happen in other places though. Enum members should go through checkEnumMember which will call checkGrammarNumericLiteral during expression checking. Similarly for template literals. So the check might be redundant for a full check. I'll test and see.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Just tested .. removing the check from here does not fail any test 😕. I do think it ends up being called through other paths.

@typescript-bot

Copy link
Copy Markdown
Contributor

Jake Bailey (@jakebailey)
The results of the perf run you requested are in!

Here they are:

tsc

Comparison Report - baseline..pr
MetricbaselineprDeltaBestWorstp-value
Angular - node (v18.15.0, x64)
Memory used295,484k (± 0.00%)295,498k (± 0.01%)~295,465k295,539kp=0.298 n=6
Parse Time3.19s (± 0.24%)3.19s (± 0.71%)~3.17s3.23sp=0.564 n=6
Bind Time0.99s (± 0.52%)1.00s (± 0.84%)~0.99s1.01sp=0.923 n=6
Check Time9.68s (± 0.27%)9.69s (± 0.36%)~9.63s9.73sp=0.747 n=6
Emit Time8.37s (± 0.14%)8.37s (± 0.43%)~8.32s8.42sp=0.627 n=6
Total Time22.23s (± 0.14%)22.23s (± 0.20%)~22.19s22.31sp=0.747 n=6
Compiler-Unions - node (v18.15.0, x64)
Memory used192,583k (± 0.78%)192,046k (± 0.08%)~191,913k192,315kp=0.936 n=6
Parse Time1.66s (± 0.99%)1.65s (± 0.89%)~1.63s1.67sp=0.871 n=6
Bind Time0.88s (± 0.59%)0.88s (± 0.72%)~0.87s0.89sp=0.386 n=6
Check Time11.21s (± 0.74%)11.27s (± 0.89%)~11.11s11.36sp=0.298 n=6
Emit Time3.14s (± 0.87%)3.14s (± 0.47%)~3.11s3.15sp=1.000 n=6
Total Time16.89s (± 0.53%)16.93s (± 0.72%)~16.74s17.05sp=0.336 n=6
Monaco - node (v18.15.0, x64)
Memory used347,443k (± 0.01%)347,451k (± 0.00%)~347,431k347,472kp=0.423 n=6
Parse Time3.69s (± 1.58%)3.67s (± 1.51%)~3.57s3.73sp=0.574 n=6
Bind Time1.39s (± 1.18%)1.38s (± 1.00%)~1.35s1.39sp=0.341 n=6
Check Time10.25s (± 0.21%)10.24s (± 0.50%)~10.16s10.30sp=1.000 n=6
Emit Time6.02s (± 0.54%)6.02s (± 0.47%)~5.99s6.07sp=0.686 n=6
Total Time21.34s (± 0.29%)21.31s (± 0.41%)~21.18s21.42sp=0.630 n=6
TFS - node (v18.15.0, x64)
Memory used302,734k (± 0.01%)302,751k (± 0.01%)~302,709k302,800kp=0.378 n=6
Parse Time2.40s (± 1.10%)2.40s (± 1.38%)~2.36s2.43sp=0.936 n=6
Bind Time1.19s (± 0.43%)1.22s (± 0.80%)+0.03s (+ 2.37%)1.21s1.23sp=0.004 n=6
Check Time7.46s (± 0.36%)7.48s (± 0.40%)~7.44s7.53sp=0.805 n=6
Emit Time4.27s (± 0.76%)4.28s (± 0.60%)~4.25s4.32sp=0.570 n=6
Total Time15.32s (± 0.25%)15.38s (± 0.37%)~15.32s15.48sp=0.072 n=6
material-ui - node (v18.15.0, x64)
Memory used509,981k (± 0.01%)509,965k (± 0.01%)~509,923k510,005kp=0.575 n=6
Parse Time3.92s (± 0.19%)3.93s (± 0.37%)~3.91s3.95sp=0.117 n=6
Bind Time1.46s (± 0.67%)1.46s (± 0.71%)~1.45s1.48sp=0.452 n=6
Check Time25.31s (± 0.17%)25.41s (± 0.32%)~25.30s25.48sp=0.052 n=6
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)~0.00s0.00sp=1.000 n=6
Total Time30.69s (± 0.14%)30.80s (± 0.27%)+0.11s (+ 0.36%)30.68s30.88sp=0.029 n=6
mui-docs - node (v18.15.0, x64)
Memory used1,737,822k (± 0.00%)1,737,828k (± 0.00%)~1,737,795k1,737,850kp=0.575 n=6
Parse Time7.78s (± 0.25%)7.79s (± 0.70%)~7.71s7.86sp=0.687 n=6
Bind Time2.79s (± 0.32%)2.79s (± 0.74%)~2.76s2.81sp=0.367 n=6
Check Time66.71s (± 0.42%)66.60s (± 0.15%)~66.51s66.77sp=0.378 n=6
Emit Time0.16s (± 3.29%)0.16s (± 2.58%)~0.15s0.16sp=0.595 n=6
Total Time77.44s (± 0.35%)77.34s (± 0.14%)~77.17s77.48sp=0.378 n=6
self-build-src - node (v18.15.0, x64)
Memory used2,392,034k (± 0.03%)2,392,685k (± 0.03%)~2,391,537k2,393,515kp=0.128 n=6
Parse Time6.06s (± 0.50%)6.07s (± 0.66%)~6.01s6.12sp=0.574 n=6
Bind Time2.26s (± 1.03%)2.25s (± 0.92%)~2.23s2.29sp=0.413 n=6
Check Time39.67s (± 0.50%)39.53s (± 0.34%)~39.43s39.78sp=0.298 n=6
Emit Time3.15s (± 1.09%)3.18s (± 1.35%)~3.14s3.26sp=0.297 n=6
Total Time51.15s (± 0.35%)51.04s (± 0.25%)~50.91s51.27sp=0.378 n=6
self-compiler - node (v18.15.0, x64)
Memory used415,053k (± 0.01%)415,056k (± 0.01%)~415,014k415,119kp=0.873 n=6
Parse Time4.17s (± 0.65%)4.11s (± 0.65%)-0.06s (- 1.32%)4.08s4.14sp=0.020 n=6
Bind Time1.58s (± 0.96%)1.59s (± 1.66%)~1.55s1.62sp=0.808 n=6
Check Time22.38s (± 0.38%)22.29s (± 0.43%)~22.16s22.42sp=0.092 n=6
Emit Time1.68s (± 1.78%)1.68s (± 1.99%)~1.64s1.72sp=1.000 n=6
Total Time29.81s (± 0.28%)29.67s (± 0.41%)~29.51s29.85sp=0.054 n=6
vscode - node (v18.15.0, x64)
Memory used2,892,649k (± 0.00%)2,892,623k (± 0.00%)~2,892,494k2,892,679kp=0.575 n=6
Parse Time12.87s (± 0.33%)12.86s (± 0.25%)~12.82s12.91sp=0.570 n=6
Bind Time4.12s (± 1.17%)4.11s (± 0.33%)~4.09s4.13sp=0.742 n=6
Check Time71.33s (± 0.43%)71.15s (± 0.45%)~70.70s71.45sp=0.422 n=6
Emit Time19.99s (± 7.78%)19.20s (± 0.23%)~19.13s19.27sp=0.108 n=6
Total Time108.30s (± 1.68%)107.31s (± 0.32%)~106.84s107.69sp=0.128 n=6
webpack - node (v18.15.0, x64)
Memory used408,368k (± 0.01%)408,443k (± 0.02%)~408,385k408,618kp=0.128 n=6
Parse Time3.88s (± 0.47%)3.89s (± 0.48%)~3.87s3.92sp=0.869 n=6
Bind Time1.69s (± 0.99%)1.69s (± 1.06%)~1.67s1.71sp=1.000 n=6
Check Time16.71s (± 0.34%)16.77s (± 0.35%)~16.69s16.86sp=0.230 n=6
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)~0.00s0.00sp=1.000 n=6
Total Time22.29s (± 0.25%)22.34s (± 0.23%)~22.27s22.42sp=0.170 n=6
xstate - node (v18.15.0, x64)
Memory used513,092k (± 0.02%)513,089k (± 0.01%)~512,988k513,124kp=0.630 n=6
Parse Time3.28s (± 0.31%)3.28s (± 0.33%)~3.27s3.30sp=0.863 n=6
Bind Time1.57s (± 0.62%)1.57s (± 0.40%)~1.56s1.58sp=0.733 n=6
Check Time2.85s (± 1.17%)2.85s (± 0.68%)~2.83s2.88sp=0.570 n=6
Emit Time0.07s (± 5.69%)0.07s (± 0.00%)~0.07s0.07sp=0.405 n=6
Total Time7.77s (± 0.46%)7.77s (± 0.29%)~7.75s7.80sp=0.517 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Angular - node (v18.15.0, x64)
  • Compiler-Unions - node (v18.15.0, x64)
  • Monaco - node (v18.15.0, x64)
  • TFS - node (v18.15.0, x64)
  • material-ui - node (v18.15.0, x64)
  • mui-docs - node (v18.15.0, x64)
  • self-build-src - node (v18.15.0, x64)
  • self-compiler - node (v18.15.0, x64)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate - 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,374ms (± 0.90%)2,371ms (± 0.35%)~2,361ms2,381msp=1.000 n=6
Req 2 - geterr5,612ms (± 0.39%)5,635ms (± 0.41%)~5,604ms5,667msp=0.173 n=6
Req 3 - references317ms (± 0.24%)318ms (± 0.33%)~316ms319msp=0.611 n=6
Req 4 - navto273ms (± 0.15%)272ms (± 0.00%)-1ms (- 0.43%)272ms272msp=0.002 n=6
Req 5 - completionInfo count1,357 (± 0.00%)1,357 (± 0.00%)~1,3571,357p=1.000 n=6
Req 5 - completionInfo87ms (± 3.74%)87ms (± 0.47%)-0ms (- 0.19%)87ms88msp=0.047 n=6
CompilerTSServer - node (v18.15.0, x64)
Req 1 - updateOpen2,504ms (± 0.42%)2,505ms (± 0.44%)~2,493ms2,522msp=0.872 n=6
Req 2 - geterr4,145ms (± 0.25%)4,134ms (± 0.13%)-12ms (- 0.28%)4,129ms4,141msp=0.030 n=6
Req 3 - references333ms (± 0.27%)333ms (± 0.45%)~332ms336msp=0.933 n=6
Req 4 - navto298ms (± 0.14%)296ms (± 0.93%)~293ms298msp=0.054 n=6
Req 5 - completionInfo count1,519 (± 0.00%)1,519 (± 0.00%)~1,5191,519p=1.000 n=6
Req 5 - completionInfo73ms (± 0.56%)73ms (± 0.56%)~72ms73msp=0.218 n=6
xstateTSServer - node (v18.15.0, x64)
Req 1 - updateOpen2,635ms (± 0.20%)2,632ms (± 0.26%)~2,619ms2,638msp=0.575 n=6
Req 2 - geterr1,740ms (± 2.59%)1,744ms (± 2.53%)~1,686ms1,796msp=0.936 n=6
Req 3 - references115ms (±10.96%)126ms (± 1.64%)~122ms128msp=0.332 n=6
Req 4 - navto370ms (± 2.39%)368ms (± 0.64%)~366ms371msp=1.000 n=6
Req 5 - completionInfo count2,079 (± 0.00%)2,079 (± 0.00%)~2,0792,079p=1.000 n=6
Req 5 - completionInfo307ms (± 1.64%)306ms (± 2.03%)~301ms316msp=0.872 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)
  • xstateTSServer - node (v18.15.0, x64)
BenchmarkNameIterations
Currentpr6
Baselinebaseline6

startup

Comparison Report - baseline..pr
MetricbaselineprDeltaBestWorstp-value
tsc-startup - node (v18.15.0, x64)
Execution time153.27ms (± 0.19%)153.29ms (± 0.19%)~152.20ms158.35msp=0.376 n=600
tsserver-startup - node (v18.15.0, x64)
Execution time226.55ms (± 0.14%)226.41ms (± 0.18%)-0.14ms (- 0.06%)224.79ms231.70msp=0.000 n=600
tsserverlibrary-startup - node (v18.15.0, x64)
Execution time221.80ms (± 0.16%)221.81ms (± 0.16%)~220.48ms225.00msp=0.929 n=600
typescript-startup - node (v18.15.0, x64)
Execution time221.48ms (± 0.17%)221.28ms (± 0.15%)-0.19ms (- 0.09%)219.98ms225.87msp=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

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.

Just a philosophy question here: utilities.ts is a now 10,000 line long file of what is essentially uncategorized helper functions. Since we refer to it as "the expression evaluator", does that imply it's standalone enough that it should warrant its' own file, rather than getting tossed in alongside the other uncategorized helper functions?

@DanielRosenwasser

Copy link
Copy Markdown
Member

does that imply it's standalone enough that it should warrant its' own file, rather than getting tossed in alongside the other uncategorized helper functions?

Given how small it is and how often new files get created, I think it's probably fine in utilities.ts - at least for now.

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.

Seems like a very simple change.

@weswigham
Wesley Wigham (weswigham) merged commit fd388f7 into microsoft:mainMar 27, 2024
@microsoftMicrosoft (microsoft) locked as resolved and limited conversation to collaborators Oct 16, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

For Uncommitted BugPR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@dragomirtitian@typescript-bot@jakebailey@DanielRosenwasser@weswigham