Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Freeze emptyArray, make emptyMap and emptySet immutable #55755

Closed

Conversation

jakebailey
Copy link
Member

We'll see if this ends up slow, but it theoretically prevents us from making mistakes and modifying these sentinel values.

@typescript-bot typescript-bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Sep 15, 2023
@jakebailey
Copy link
Member Author

@typescript-bot perf test this faster
@typescript-bot perf test this bun

@typescript-bot
Copy link
Collaborator

typescript-bot commented Sep 15, 2023

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Sep 15, 2023

Heya @jakebailey, I've started to run the tsc-only perf test suite on this PR at cee1695. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

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

Here they are:

Compiler

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Angular - bun (v1.0.2, x64)
Memory used 316,904k (± 0.15%) 334,602k (± 0.44%) 🔻+17,698k (+ 5.58%) 331,654k 337,468k p=0.000 n=12
Parse Time 2.28s (± 0.47%) 2.29s (± 0.67%) ~ 2.27s 2.35s p=0.166 n=12
Bind Time 0.89s (± 2.02%) 0.88s (± 1.73%) ~ 0.83s 0.92s p=0.347 n=12
Check Time 7.97s (± 0.37%) 8.09s (± 0.31%) +0.12s (+ 1.53%) 8.03s 8.15s p=0.000 n=12
Emit Time 6.41s (± 0.26%) 6.50s (± 0.38%) +0.08s (+ 1.29%) 6.45s 6.59s p=0.000 n=12
Total Time 17.56s (± 0.23%) 17.77s (± 0.25%) +0.21s (+ 1.17%) 17.68s 17.89s p=0.000 n=12
Compiler-Unions - bun (v1.0.2, x64)
Memory used 245,841k (± 0.71%) 240,810k (± 1.20%) -5,031k (- 2.05%) 232,839k 244,987k p=0.001 n=12
Parse Time 1.12s (± 0.74%) 1.14s (± 1.48%) ~ 1.10s 1.17s p=0.105 n=12
Bind Time 0.83s (± 1.12%) 0.84s (± 1.66%) ~ 0.81s 0.89s p=0.249 n=12
Check Time 8.82s (± 0.48%) 9.02s (± 0.42%) +0.20s (+ 2.30%) 8.90s 9.11s p=0.000 n=12
Emit Time 2.79s (± 0.56%) 2.75s (± 0.44%) -0.04s (- 1.49%) 2.72s 2.79s p=0.000 n=12
Total Time 13.57s (± 0.25%) 13.75s (± 0.38%) +0.19s (+ 1.36%) 13.60s 13.93s p=0.000 n=12
Monaco - bun (v1.0.2, x64)
Memory used 378,181k (± 0.29%) 387,781k (± 0.15%) +9,600k (+ 2.54%) 386,726k 389,474k p=0.000 n=12
Parse Time 1.97s (± 0.52%) 1.97s (± 0.67%) ~ 1.95s 2.01s p=0.766 n=12
Bind Time 0.98s (± 1.81%) 0.97s (± 1.85%) ~ 0.93s 1.02s p=0.541 n=12
Check Time 7.36s (± 0.47%) 7.61s (± 0.28%) +0.24s (+ 3.33%) 7.55s 7.68s p=0.000 n=12
Emit Time 3.77s (± 0.41%) 3.81s (± 0.44%) +0.05s (+ 1.24%) 3.77s 3.84s p=0.002 n=12
Total Time 14.07s (± 0.41%) 14.36s (± 0.19%) +0.29s (+ 2.08%) 14.29s 14.43s p=0.000 n=12
TFS - bun (v1.0.2, x64)
Memory used 317,290k (± 0.15%) 332,215k (± 0.21%) 🔻+14,925k (+ 4.70%) 330,480k 334,125k p=0.000 n=12
Parse Time 1.76s (± 1.20%) 1.75s (± 0.70%) ~ 1.73s 1.80s p=0.571 n=12
Bind Time 0.97s (± 2.96%) 0.99s (± 2.39%) ~ 0.89s 1.03s p=0.097 n=12
Check Time 6.60s (± 0.37%) 6.77s (± 0.43%) +0.17s (+ 2.55%) 6.69s 6.83s p=0.000 n=12
Emit Time 3.48s (± 0.89%) 3.57s (± 0.58%) +0.09s (+ 2.56%) 3.49s 3.60s p=0.000 n=12
Total Time 12.81s (± 0.38%) 13.08s (± 0.35%) +0.27s (+ 2.13%) 12.95s 13.19s p=0.000 n=12
material-ui - bun (v1.0.2, x64)
Memory used 488,043k (± 1.84%) 474,840k (± 2.32%) -13,203k (- 2.71%) 466,539k 526,188k p=0.004 n=12
Parse Time 2.23s (± 0.15%) 2.28s (± 0.27%) +0.06s (+ 2.58%) 2.27s 2.30s p=0.000 n=12
Bind Time 0.76s (± 2.51%) 0.78s (± 0.64%) +0.02s (+ 2.85%) 0.77s 0.80s p=0.017 n=12
Check Time 15.79s (± 0.58%) 15.96s (± 0.34%) +0.17s (+ 1.07%) 15.83s 16.12s p=0.004 n=12
Emit Time 0.00s (± 0.00%) 0.00s (±156.40%) ~ 0.00s 0.02s p=0.166 n=12
Total Time 18.78s (± 0.46%) 19.03s (± 0.31%) +0.25s (+ 1.34%) 18.88s 19.20s p=0.000 n=12
xstate - bun (v1.0.2, x64)
Memory used 415,527k (± 6.21%) 435,543k (± 5.45%) ~ 380,807k 465,152k p=0.194 n=12
Parse Time 3.25s (± 0.72%) 3.22s (± 0.17%) ~ 3.21s 3.23s p=0.062 n=12
Bind Time 1.26s (± 0.77%) 1.26s (± 0.80%) ~ 1.23s 1.29s p=0.460 n=12
Check Time 3.58s (± 0.29%) 3.65s (± 0.53%) +0.06s (+ 1.77%) 3.60s 3.71s p=0.000 n=12
Emit Time 0.21s (± 1.60%) 0.21s (± 4.37%) ~ 0.20s 0.25s p=0.571 n=12
Total Time 8.30s (± 0.34%) 8.34s (± 0.33%) +0.04s (+ 0.52%) 8.26s 8.42s p=0.026 n=12
System info unknown
Hosts
  • bun (v1.0.2, x64)
Scenarios
  • Angular - bun (v1.0.2, x64)
  • Compiler-Unions - bun (v1.0.2, x64)
  • Monaco - bun (v1.0.2, x64)
  • TFS - bun (v1.0.2, x64)
  • material-ui - bun (v1.0.2, x64)
  • xstate - bun (v1.0.2, x64)
Benchmark Name Iterations
Current pr 12
Baseline baseline 12

Startup

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
tsc-startup - bun (v1.0.2, x64)
Execution time 425.48ms (± 0.09%) 425.45ms (± 0.08%) ~ 424.24ms 434.30ms p=0.734 n=600
tsserverlibrary-startup - bun (v1.0.2, x64)
Execution time 658.46ms (± 0.10%) 658.48ms (± 0.14%) +0.02ms (+ 0.00%) 656.76ms 674.77ms p=0.046 n=600
typescript-startup - bun (v1.0.2, x64)
Execution time 657.96ms (± 0.11%) 657.86ms (± 0.13%) -0.10ms (- 0.01%) 656.18ms 674.96ms p=0.000 n=600
System info unknown
Hosts
  • bun (v1.0.2, x64)
Scenarios
  • tsc-startup - bun (v1.0.2, x64)
  • tsserverlibrary-startup - bun (v1.0.2, x64)
  • typescript-startup - bun (v1.0.2, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@typescript-bot
Copy link
Collaborator

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

Here they are:

Compiler

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Angular - node (v18.15.0, x64)
Memory used 294,934k (± 0.01%) 294,935k (± 0.01%) ~ 294,915k 294,958k p=1.000 n=6
Parse Time 2.63s (± 0.56%) 2.63s (± 0.31%) ~ 2.62s 2.64s p=0.666 n=6
Bind Time 0.84s (± 0.75%) 0.85s (± 0.48%) +0.01s (+ 0.99%) 0.84s 0.85s p=0.033 n=6
Check Time 7.99s (± 0.36%) 8.05s (± 0.26%) +0.05s (+ 0.67%) 8.01s 8.07s p=0.019 n=6
Emit Time 7.01s (± 0.37%) 7.02s (± 0.28%) ~ 6.99s 7.04s p=0.566 n=6
Total Time 18.47s (± 0.25%) 18.55s (± 0.18%) +0.07s (+ 0.39%) 18.50s 18.58s p=0.030 n=6
Compiler-Unions - node (v18.15.0, x64)
Memory used 190,663k (± 0.01%) 192,599k (± 1.53%) +1,935k (+ 1.02%) 190,686k 196,400k p=0.008 n=6
Parse Time 1.35s (± 0.30%) 1.36s (± 0.89%) ~ 1.35s 1.38s p=0.527 n=6
Bind Time 0.74s (± 0.00%) 0.74s (± 0.00%) ~ 0.74s 0.74s p=1.000 n=6
Check Time 9.08s (± 0.31%) 9.11s (± 0.44%) ~ 9.06s 9.16s p=0.335 n=6
Emit Time 2.60s (± 0.20%) 2.61s (± 0.64%) ~ 2.58s 2.63s p=0.059 n=6
Total Time 13.76s (± 0.21%) 13.81s (± 0.24%) +0.05s (+ 0.33%) 13.77s 13.86s p=0.040 n=6
Monaco - node (v18.15.0, x64)
Memory used 347,177k (± 0.01%) 347,176k (± 0.00%) ~ 347,158k 347,189k p=0.630 n=6
Parse Time 2.46s (± 0.43%) 2.46s (± 0.77%) ~ 2.44s 2.48s p=0.744 n=6
Bind Time 0.94s (± 0.43%) 0.94s (± 0.43%) ~ 0.93s 0.94s p=1.000 n=6
Check Time 6.90s (± 0.76%) 6.88s (± 0.17%) ~ 6.86s 6.89s p=0.627 n=6
Emit Time 4.04s (± 0.48%) 4.06s (± 0.40%) +0.03s (+ 0.66%) 4.04s 4.09s p=0.035 n=6
Total Time 14.34s (± 0.47%) 14.34s (± 0.10%) ~ 14.33s 14.37s p=1.000 n=6
TFS - node (v18.15.0, x64)
Memory used 302,454k (± 0.01%) 302,463k (± 0.01%) ~ 302,437k 302,485k p=0.688 n=6
Parse Time 2.02s (± 0.81%) 2.00s (± 1.39%) ~ 1.95s 2.03s p=0.413 n=6
Bind Time 0.99s (± 0.82%) 0.99s (± 0.55%) ~ 0.99s 1.00s p=0.859 n=6
Check Time 6.21s (± 0.44%) 6.27s (± 0.58%) +0.05s (+ 0.86%) 6.23s 6.32s p=0.019 n=6
Emit Time 3.52s (± 0.84%) 3.52s (± 0.69%) ~ 3.48s 3.54s p=0.936 n=6
Total Time 12.74s (± 0.25%) 12.78s (± 0.46%) ~ 12.70s 12.86s p=0.260 n=6
material-ui - node (v18.15.0, x64)
Memory used 470,456k (± 0.00%) 470,434k (± 0.00%) -23k (- 0.00%) 470,412k 470,455k p=0.031 n=6
Parse Time 2.58s (± 0.68%) 2.58s (± 0.75%) ~ 2.55s 2.61s p=1.000 n=6
Bind Time 1.00s (± 1.04%) 0.99s (± 0.52%) ~ 0.99s 1.00s p=0.437 n=6
Check Time 16.62s (± 0.39%) 16.88s (± 0.39%) +0.26s (+ 1.58%) 16.80s 16.99s p=0.005 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 20.20s (± 0.27%) 20.46s (± 0.33%) +0.25s (+ 1.26%) 20.38s 20.57s p=0.005 n=6
xstate - node (v18.15.0, x64)
Memory used 512,191k (± 0.02%) 512,259k (± 0.03%) ~ 512,177k 512,548k p=0.230 n=6
Parse Time 3.26s (± 0.25%) 3.26s (± 0.43%) ~ 3.24s 3.28s p=0.677 n=6
Bind Time 1.55s (± 0.33%) 1.55s (± 0.26%) ~ 1.55s 1.56s p=0.114 n=6
Check Time 2.78s (± 0.71%) 2.80s (± 0.95%) ~ 2.77s 2.84s p=0.191 n=6
Emit Time 0.08s (± 4.99%) 0.08s (± 0.00%) ~ 0.08s 0.08s p=0.405 n=6
Total Time 7.67s (± 0.16%) 7.70s (± 0.45%) ~ 7.67s 7.75s p=0.210 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)
  • xstate - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@jakebailey
Copy link
Member Author

oof

@jakebailey jakebailey marked this pull request as draft September 15, 2023 21:11
src/compiler/core.ts Outdated Show resolved Hide resolved
@jakebailey jakebailey closed this Mar 19, 2024
@jakebailey jakebailey deleted the frozen-empty-collections branch March 19, 2024 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants