Skip to content

Find the end of multi-line comments with a substring search after the first line break - #64990

Open
Mateusz Burzyński (Andarist) wants to merge 1 commit into
microsoft:mainfrom
Andarist:andarist/scanner-block-comment-tail
Open

Mateusz Burzyński (Andarist) wants to merge 1 commit into
microsoft:mainfrom
Andarist:andarist/scanner-block-comment-tail

Conversation

@Andarist

Copy link
Copy Markdown
Contributor

This gives pretty nice improvements in the JSDoc-heavy sources. On my machine dom.generated.d.ts ends up being parsed up to 7% faster

Copilot AI balanced review requested due to automatic review settings October 28, 2026 09:50
@typescript-automation typescript-automation Bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Oct 28, 2026
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Oct 28, 2026
@typescript-automation

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.

Copilot AI left a comment

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.

🟢 Approval recommended

No active review issues remain for the multiline comment scanning optimization.

No open issues 🎉

What changed in this PR

This PR optimizes multi-line comment scanning in the native TypeScript compiler, targeting faster parsing of JSDoc-heavy files.

Changes:

  • Uses a substring search to locate the closing delimiter after the first line break.
  • Scans backward to identify the last line for comment-directive processing.
  • Adds tests covering line-break variants, Unicode text, directive placement, and unterminated comments.
File Description
tsc/​internal/​scanner/​scanner.go Adds the optimized multi-line comment tail scanner.
tsc/​internal/​scanner/​scanner_test.go Tests comment boundaries, token flags, and directive ranges.

Review effort: Balanced

@jakebailey

Copy link
Copy Markdown
Member

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

@typescript-automation

typescript-automation Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

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

Command Status Results
perf test this faster ✅ Started 👀 Results

@typescript-automation

Copy link
Copy Markdown
Contributor

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

Here they are:

Provisional hosted-runner results: these VMs are not the dedicated benchmark machines. Results may be noisier and are not comparable to the historical series. For comparisons, both revisions of each scenario ran on the same VM.

tsc

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Compiler-Unions - native
Errors 41 41 ~ ~ ~ p=1.000 n=12
Symbols 88,466 88,466 ~ ~ ~ p=1.000 n=12
Types 79,607 79,607 ~ ~ ~ p=1.000 n=12
Memory Used 104,122k (± 0.04%) 104,130k (± 0.03%) ~ 104,020k 104,200k p=0.478 n=12
Memory Allocs 2,200,773 (± 0.01%) 2,200,888 (± 0.01%) ~ 2,200,559 2,201,245 p=0.311 n=12
Config Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Parse Time 0.024s (± 4.03%) 0.025s (± 3.02%) ~ 0.023s 0.027s p=0.415 n=12
Bind Time 0.009s (± 5.99%) 0.010s (± 6.32%) ~ 0.008s 0.011s p=0.282 n=12
Check Time 0.239s (± 1.24%) 0.243s (± 1.48%) ~ 0.236s 0.254s p=0.091 n=12
Emit Time 0.164s (± 2.58%) 0.162s (± 2.46%) ~ 0.150s 0.170s p=0.467 n=12
Total Time 0.440s (± 1.51%) 0.444s (± 1.04%) ~ 0.430s 0.456s p=0.369 n=12
angular-1 - native
Errors 3 3 ~ ~ ~ p=1.000 n=12
Symbols 586,542 (± 0.02%) 586,496 (± 0.02%) ~ 586,256 586,819 p=0.551 n=12
Types 241,694 (± 0.00%) 241,692 (± 0.00%) ~ 241,690 241,700 p=0.374 n=12
Memory Used 518,011k (± 0.03%) 518,015k (± 0.03%) ~ 517,540k 518,308k p=0.702 n=12
Memory Allocs 13,114,931 (± 0.04%) 13,119,967 (± 0.07%) ~ 13,110,194 13,162,320 p=0.128 n=12
Config Time 0.009s (± 2.67%) 0.009s (± 2.67%) ~ 0.009s 0.010s p=1.000 n=12
Parse Time 0.139s (± 4.48%) 0.133s (± 5.33%) ~ 0.119s 0.156s p=0.146 n=12
Bind Time 0.041s (± 3.34%) 0.048s (±14.19%) ~ 0.039s 0.068s p=0.144 n=12
Check Time 0s 0s ~ ~ ~ p=1.000 n=12
Emit Time 0.932s (± 1.50%) 0.938s (± 1.94%) ~ 0.886s 0.983s p=0.451 n=12
Total Time 1.130s (± 1.35%) 1.142s (± 1.38%) ~ 1.093s 1.176s p=0.183 n=12
arktype - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 685,943 685,943 ~ ~ ~ p=1.000 n=12
Types 939,490 939,490 ~ ~ ~ p=1.000 n=12
Memory Used 497,291k (± 0.02%) 497,281k (± 0.01%) ~ 497,108k 497,379k p=1.000 n=12
Memory Allocs 12,805,130 (± 0.01%) 12,806,329 (± 0.02%) ~ 12,802,436 12,813,637 p=0.590 n=12
Config Time 0.001s 0.001s ~ ~ ~ p=1.000 n=12
Parse Time 0.045s (± 3.60%) 0.048s (± 4.45%) 🔻+0.003s (+ 6.33%) 0.043s 0.056s p=0.033 n=12
Bind Time 0.015s (±12.37%) 0.014s (± 8.25%) ~ 0.012s 0.018s p=0.249 n=12
Check Time 1.084s (± 1.39%) 1.063s (± 2.23%) ~ 1.010s 1.136s p=0.080 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 1.179s (± 1.09%) 1.155s (± 2.14%) ~ 1.097s 1.227s p=0.080 n=12
class-transformer - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 45,376 45,376 ~ ~ ~ p=1.000 n=12
Types 7,573 7,573 ~ ~ ~ p=1.000 n=12
Memory Used 27,841k (± 0.03%) 27,836k (± 0.01%) ~ 27,826k 27,845k p=0.541 n=12
Memory Allocs 323,258 (± 0.04%) 323,339 (± 0.04%) ~ 323,032 323,802 p=0.378 n=12
Config Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Parse Time 0.009s (± 3.96%) 0.009s (± 4.23%) ~ 0.008s 0.010s p=0.870 n=12
Bind Time 0.002s (±20.64%) 0.003s (±21.92%) ~ 0.002s 0.004s p=0.820 n=12
Check Time 0.008s (± 5.81%) 0.008s (± 5.31%) ~ 0.007s 0.009s p=0.960 n=12
Emit Time 0.010s (± 3.69%) 0.010s (± 4.01%) ~ 0.009s 0.011s p=0.870 n=12
Total Time 0.031s (± 1.87%) 0.031s (± 1.65%) ~ 0.029s 0.031s p=0.763 n=12
effect - native
Errors 12 12 ~ ~ ~ p=1.000 n=12
Symbols 1,235,117 1,235,117 ~ ~ ~ p=1.000 n=12
Types 894,115 894,115 ~ ~ ~ p=1.000 n=12
Memory Used 940,588k (± 0.03%) 940,548k (± 0.03%) ~ 939,840k 941,132k p=0.977 n=12
Memory Allocs 15,756,197 (± 0.06%) 15,754,324 (± 0.06%) ~ 15,742,560 15,789,694 p=0.266 n=12
Config Time 0.002s (±25.93%) 0.002s (±23.43%) ~ 0.002s 0.005s p=0.932 n=12
Parse Time 0.234s (± 6.06%) 0.226s (± 3.07%) ~ 0.207s 0.249s p=0.202 n=12
Bind Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Check Time 1.373s (± 2.94%) 1.397s (± 1.66%) ~ 1.334s 1.455s p=0.640 n=12
Emit Time 0.790s (± 5.55%) 0.774s (± 2.32%) ~ 0.722s 0.819s p=0.386 n=12
Total Time 2.537s (± 3.67%) 2.530s (± 1.34%) ~ 2.415s 2.620s p=0.340 n=12
mui-docs - native
Errors 11,405 11,405 ~ ~ ~ p=1.000 n=12
Symbols 3,784,027 3,784,027 ~ ~ ~ p=1.000 n=12
Types 1,355,982 1,355,982 ~ ~ ~ p=1.000 n=12
Memory Used 1,835,506k (± 0.11%) 1,835,757k (± 0.08%) ~ 1,832,228k 1,839,471k p=0.887 n=12
Memory Allocs 26,724,605 (± 0.08%) 26,726,901 (± 0.04%) ~ 26,697,505 26,764,394 p=0.799 n=12
Config Time 0.008s (± 3.00%) 0.008s (± 2.25%) ~ 0.008s 0.009s p=1.000 n=12
Parse Time 0.294s (± 4.74%) 0.296s (± 2.05%) ~ 0.286s 0.312s p=0.560 n=12
Bind Time 0.001s 0.001s ~ ~ ~ p=1.000 n=12
Check Time 3.229s (± 0.85%) 3.220s (± 0.49%) ~ 3.182s 3.261s p=0.832 n=12
Emit Time 0.243s (± 1.44%) 0.244s (± 1.08%) ~ 0.235s 0.250s p=0.719 n=12
Total Time 4.257s (± 0.66%) 4.254s (± 0.57%) ~ 4.198s 4.344s p=0.504 n=12
sentry - native
Errors 2 2 ~ ~ ~ p=1.000 n=12
Symbols 4,793,249 4,793,249 ~ ~ ~ p=1.000 n=12
Types 2,607,051 2,607,051 ~ ~ ~ p=1.000 n=12
Memory Used 2,880,451k (± 0.05%) 2,879,388k (± 0.02%) ~ 2,878,084k 2,880,944k p=0.291 n=12
Memory Allocs 75,850,386 (± 0.11%) 75,915,107 (± 0.11%) ~ 75,688,970 76,125,206 p=0.266 n=12
Config Time 0.025s (± 0.97%) 0.026s (± 1.97%) ~ 0.025s 0.027s p=0.349 n=12
Parse Time 0.484s (± 4.88%) 0.492s (± 7.99%) ~ 0.441s 0.668s p=0.943 n=12
Bind Time 0.149s (± 9.38%) 0.157s (±13.18%) ~ 0.130s 0.209s p=0.990 n=12
Check Time 6.863s (± 0.89%) 6.853s (± 1.12%) ~ 6.723s 7.093s p=0.562 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 7.577s (± 0.76%) 7.581s (± 1.04%) ~ 7.462s 7.795s p=0.799 n=12
social-app - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 1,883,075 1,883,075 ~ ~ ~ p=1.000 n=12
Types 1,158,171 1,158,171 ~ ~ ~ p=1.000 n=12
Memory Used 972,495k (± 0.02%) 972,377k (± 0.02%) ~ 972,056k 972,920k p=0.347 n=12
Memory Allocs 13,692,218 (± 0.11%) 13,714,560 (± 0.16%) ~ 13,662,605 13,780,114 p=0.089 n=12
Config Time 0.007s 0.007s ~ ~ ~ p=1.000 n=12
Parse Time 0.163s (± 6.35%) 0.163s (± 4.13%) ~ 0.150s 0.182s p=0.560 n=12
Bind Time 0.041s (±11.76%) 0.044s (±14.10%) ~ 0.034s 0.069s p=0.295 n=12
Check Time 1.552s (± 0.54%) 1.572s (± 1.82%) ~ 1.519s 1.703s p=0.054 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 1.781s (± 0.86%) 1.807s (± 1.91%) ~ 1.758s 1.965s p=0.139 n=12
strada-build-src - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 1,184,976 1,184,976 ~ ~ ~ p=1.000 n=12
Types 438,967 438,967 ~ ~ ~ p=1.000 n=12
Memory Used 1,174,575k (± 0.28%) 1,172,430k (± 0.32%) ~ 1,164,174k 1,187,986k p=0.198 n=12
Memory Allocs 77,501,245 (± 0.13%) 77,444,307 (± 0.15%) ~ 77,155,386 77,724,332 p=0.443 n=12
Config Time 0.002s (±22.34%) 0.002s (±23.23%) ~ 0.001s 0.003s p=0.532 n=12
Parse Time 0.150s (± 2.93%) 0.150s (± 2.41%) ~ 0.140s 0.160s p=0.639 n=12
Bind Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Check Time 0.906s (± 1.34%) 0.910s (± 1.27%) ~ 0.888s 0.956s p=0.468 n=12
Emit Time 0.189s (± 3.40%) 0.193s (± 2.78%) ~ 0.182s 0.206s p=0.183 n=12
Total Time 11.101s (± 1.98%) 10.982s (± 0.48%) ~ 10.789s 11.103s p=0.799 n=12
strada-compiler - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 263,513 263,513 ~ ~ ~ p=1.000 n=12
Types 196,118 196,118 ~ ~ ~ p=1.000 n=12
Memory Used 224,529k (± 0.04%) 224,632k (± 0.03%) ~ 224,471k 224,853k p=0.143 n=12
Memory Allocs 4,303,958 (± 0.01%) 4,304,488 (± 0.01%) ~ 4,303,575 4,305,631 p=0.198 n=12
Config Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Parse Time 0.050s (± 3.55%) 0.051s (± 4.70%) ~ 0.044s 0.059s p=0.697 n=12
Bind Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Check Time 0.395s (± 1.05%) 0.390s (± 0.87%) ~ 0.384s 0.404s p=0.108 n=12
Emit Time 0.076s (± 3.52%) 0.079s (± 2.19%) ~ 0.076s 0.084s p=0.333 n=12
Total Time 0.551s (± 0.58%) 0.550s (± 0.70%) ~ 0.541s 0.562s p=0.679 n=12
t3code-server - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 4,350,705 4,350,705 ~ ~ ~ p=1.000 n=12
Types 3,040,691 3,040,691 ~ ~ ~ p=1.000 n=12
Memory Used 2,433,894k (± 0.02%) 2,434,138k (± 0.03%) ~ 2,432,437k 2,436,187k p=0.713 n=12
Memory Allocs 37,871,841 (± 0.05%) 37,895,181 (± 0.08%) ~ 37,826,547 37,975,620 p=0.378 n=12
Config Time 0.003s 0.003s ~ ~ ~ p=1.000 n=12
Parse Time 0.257s (± 1.78%) 0.258s (± 2.63%) ~ 0.237s 0.272s p=0.831 n=12
Bind Time 0.083s (± 8.37%) 0.085s (± 8.08%) ~ 0.075s 0.108s p=0.595 n=12
Check Time 7.594s (± 0.77%) 7.620s (± 0.56%) ~ 7.536s 7.744s p=0.156 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 7.948s (± 0.78%) 7.977s (± 0.55%) ~ 7.893s 8.092s p=0.219 n=12
tanstack-router - native
Errors 1 1 ~ ~ ~ p=1.000 n=12
Symbols 571,760 571,760 ~ ~ ~ p=1.000 n=12
Types 397,693 397,693 ~ ~ ~ p=1.000 n=12
Memory Used 331,426k (± 0.01%) 331,405k (± 0.02%) ~ 331,209k 331,541k p=0.977 n=12
Memory Allocs 5,091,150 (± 0.06%) 5,090,640 (± 0.05%) ~ 5,086,940 5,100,429 p=0.932 n=12
Config Time 0.001s 0.001s ~ ~ ~ p=1.000 n=12
Parse Time 0.040s (± 5.67%) 0.040s (± 5.98%) ~ 0.035s 0.045s p=0.966 n=12
Bind Time 0.012s (±11.42%) 0.012s (± 8.27%) ~ 0.011s 0.015s p=0.784 n=12
Check Time 0.581s (± 1.25%) 0.578s (± 1.20%) ~ 0.562s 0.601s p=0.541 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 0.659s (± 0.99%) 0.655s (± 1.27%) ~ 0.633s 0.670s p=0.744 n=12
ts-pre-modules - native
Errors 87 87 ~ ~ ~ p=1.000 n=12
Symbols 231,617 231,617 ~ ~ ~ p=1.000 n=12
Types 181,196 181,196 ~ ~ ~ p=1.000 n=12
Memory Used 193,537k (± 0.03%) 193,490k (± 0.02%) -47k (- 0.02%) 193,425k 193,564k p=0.030 n=12
Memory Allocs 1,372,876 (± 0.01%) 1,372,966 (± 0.02%) ~ 1,372,663 1,373,635 p=0.713 n=12
Config Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Parse Time 0.052s (± 6.56%) 0.051s (± 3.02%) ~ 0.047s 0.056s p=0.593 n=12
Bind Time 0.027s (±17.60%) 0.025s (±10.46%) ~ 0.019s 0.030s p=0.700 n=12
Check Time 0.375s (± 3.23%) 0.374s (± 1.71%) ~ 0.355s 0.390s p=0.541 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 0.461s (± 3.32%) 0.457s (± 1.82%) ~ 0.433s 0.484s p=0.898 n=12
vscode - native
Errors 10 10 ~ ~ ~ p=1.000 n=12
Symbols 7,338,354 7,338,354 ~ ~ ~ p=1.000 n=12
Types 4,333,029 4,333,029 ~ ~ ~ p=1.000 n=12
Memory Used 5,110,529k (± 0.03%) 5,109,329k (± 0.02%) ~ 5,106,605k 5,111,226k p=0.198 n=12
Memory Allocs 64,291,918 (± 0.02%) 64,295,614 (± 0.03%) ~ 64,279,243 64,392,962 p=0.932 n=12
Config Time 0.035s (± 1.08%) 0.035s (± 2.23%) ~ 0.033s 0.037s p=0.999 n=12
Parse Time 0.949s (± 2.26%) 0.917s (± 3.44%) ~ 0.825s 0.991s p=0.124 n=12
Bind Time 0.308s (± 1.90%) 0.380s (±18.41%) 🔻+0.071s (+23.14%) 0.292s 0.591s p=0.047 n=12
Check Time 8.262s (± 0.67%) 8.306s (± 1.23%) ~ 7.976s 8.664s p=0.370 n=12
Emit Time 2.972s (± 3.39%) 3.200s (± 7.44%) ~ 2.839s 3.873s p=0.178 n=12
Total Time 12.585s (± 1.05%) 12.897s (± 2.10%) +0.312s (+ 2.48%) 12.420s 13.719s p=0.045 n=12
webpack - native
Errors 619 619 ~ ~ ~ p=1.000 n=12
Symbols 925,776 925,776 ~ ~ ~ p=1.000 n=12
Types 649,119 649,119 ~ ~ ~ p=1.000 n=12
Memory Used 696,438k (± 0.02%) 696,325k (± 0.02%) ~ 695,868k 696,502k p=0.434 n=12
Memory Allocs 6,686,585 (± 0.02%) 6,685,615 (± 0.02%) ~ 6,682,800 6,688,931 p=0.242 n=12
Config Time 0.004s 0.004s ~ ~ ~ p=1.000 n=12
Parse Time 0.158s (± 3.86%) 0.148s (± 3.32%) 🟩-0.010s (- 6.49%) 0.133s 0.162s p=0.032 n=12
Bind Time 0.044s (± 5.77%) 0.043s (± 5.63%) ~ 0.039s 0.051s p=0.466 n=12
Check Time 1.295s (± 1.14%) 1.295s (± 1.50%) ~ 1.258s 1.351s p=0.921 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 1.526s (± 1.15%) 1.516s (± 1.50%) ~ 1.469s 1.582s p=0.340 n=12
xstate-main - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 640,494 640,494 ~ ~ ~ p=1.000 n=12
Types 387,992 387,992 ~ ~ ~ p=1.000 n=12
Memory Used 350,994k (± 0.04%) 351,007k (± 0.03%) ~ 350,798k 351,236k p=0.641 n=12
Memory Allocs 4,066,851 (± 0.05%) 4,065,406 (± 0.09%) ~ 4,058,550 4,078,468 p=0.143 n=12
Config Time 0.001s 0.001s ~ ~ ~ p=1.000 n=12
Parse Time 0.062s (± 4.04%) 0.061s (± 3.06%) ~ 0.056s 0.066s p=0.781 n=12
Bind Time 0.021s (±14.55%) 0.019s (±10.81%) ~ 0.017s 0.028s p=0.415 n=12
Check Time 0.427s (± 1.88%) 0.419s (± 1.17%) ~ 0.407s 0.431s p=0.155 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 0.516s (± 1.72%) 0.504s (± 1.20%) -0.012s (- 2.37%) 0.489s 0.518s p=0.032 n=12
System info unknown
Hosts
  • native
Scenarios
  • Compiler-Unions - native
  • angular-1 - native
  • arktype - native
  • class-transformer - native
  • effect - native
  • mui-docs - native
  • sentry - native
  • social-app - native
  • strada-build-src - native
  • strada-compiler - native
  • t3code-server - native
  • tanstack-router - native
  • ts-pre-modules - native
  • vscode - native
  • webpack - native
  • xstate-main - native
Benchmark Name Iterations
Current pr 12
Baseline baseline 12

Developer Information:

Download Benchmarks

@jakebailey Jake Bailey (jakebailey) added the Domain: Performance Reports of unusually slow behavior label Oct 28, 2026

This branch has not been deployed

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

Labels

Domain: Performance Reports of unusually slow behavior For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

3 participants