Skip to content

Conversation

dzbarsky
Copy link

Noticed we weren't using buffers while trying the Kibana repro.

Before:

➜  kibana git:(main) ✗ time ../typescript-go/tsgo -p tsconfig.json -pprofDir /tmp/pprof                    
tsconfig.json:3:3 - error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?

3   "compilerOptions": {
    ~~~~~~~~~~~~~~~~~
tsconfig.json:3:3 - error TS5102: Option 'baseUrl' has been removed. Please remove it from your configuration.
  Use '"paths": {"*": ["./*"]}' instead.

3   "compilerOptions": {
    ~~~~~~~~~~~~~~~~~

Found 2 errors in the same file, starting at: tsconfig.json:3

CPU profile: /tmp/pprof/92848-cpuprofile.pb.gz
Memory profile: /tmp/pprof/92848-memprofile.pb.gz
../typescript-go/tsgo -p tsconfig.json -pprofDir /tmp/pprof  273.49s user 45.88s system 299% cpu 1:46.77 total
image

After:

../typescript-go/tsgo -p tsconfig.json -pprofDir /tmp/pprof  237.25s user 40.39s system 286% cpu 1:36.83 total
image

@jakebailey
Copy link
Member

jakebailey commented Aug 27, 2025

This should only matter in erroring code. Are you silencing a whole bunch of errors?

@dzbarsky
Copy link
Author

I'm not sure? The output above shows the only 2 errors that are reported.

@jakebailey
Copy link
Member

If possible I'd print something out each time he function is called and count how often it is, or look around for ts-ignores/ts-expect-error.

I think we can totally accept an optimization like this, but we certainly aren't expecting the diagnostic code paths to be hot.

@dzbarsky
Copy link
Author

dzbarsky commented Aug 27, 2025

There are around 3.1K ts-expect-error but I see GetSpellingSuggestion called around 750K times. I checked how many options were considered for each call (i.e. how many calls we executed to compute levenshtein distance, not just how many were provided):

count=751877 min=0 max=1060 avg=41.9747

A majority of calls only execute up to 2-3 computations, but for some reason there's 122K calls that consider exactly 175 possibilities...

Freq.   # of distances computed
325284 0
129899 1
122505 175
59133 2
26471 3
17585 26
14454 4
7951 211
7901 7
6482 47
5141 5
4515 87
4057 6
1774 375
1191 8
 935 538
 920 555
 890 9
 870 584
 832 514
 819 486
 807 431
 790 551
 790 522

@jakebailey
Copy link
Member

That many ignored errors is terrifying; I would strongly suggest converting those to casts or similar.

But, would be good to improve nevertheless...

@RyanCavanaugh
Copy link
Member

There are around 3.1K ts-expect-error

Can you characterize these for us? Why so many? We only compute spelling suggestions we can't find an identifier or property with that name -- situations that should be very, very uncommon in theory (and usually have straightforward type-side fixes available, e.g. declare missingVar: any).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants