microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
101.03k stars 12.49k forks source link

Slow Intellisense with TypeScript #35364

Closed zdila closed 4 years ago

zdila commented 4 years ago

Steps to Reproduce:

  1. git clone https://github.com/FreemapSlovakia/freemap-v3-react && cd freemap-v3-react && npm i
  2. run clean VS Code: rm -rf ../tmp123 && code-insiders --disable-extensions --user-data-dir ../tmp123 .
  3. start developing

Does this issue occur when all extensions are disabled?: Yes

The problem is that IntelliSense and validation is very slow. At the beginning I need to wait couple of seconds to see IntelliSense hints. After slightly more code editing the time increases to tens of seconds. I often have to invoke action Typescript: Restart TS server.

You can see it in a screencast: https://www.dropbox.com/s/njldg7q5w3cm03p/Screencast%202019-11-26%2010%3A17%3A24.mp4

I am working on powerful desktop PC with SSD, 16 GB RAM...

✔ bono:~/freemap-v3-react [master|✔]> free
              total        used        free      shared  buff/cache   available
Mem:       16256392     5224768     5868172      389524     5163452    10402544
Swap:       7157756           0     7157756

✔ bono:~/freemap-v3-react [master|✔]> cat /proc/cpuinfo 
processor   : 0
vendor_id   : GenuineIntel
cpu family  : 6
model       : 58
model name  : Intel(R) Core(TM) i7-3770K CPU @ 3.50GHz
stepping    : 9
microcode   : 0x17
cpu MHz     : 1596.398
cache size  : 8192 KB
physical id : 0
siblings    : 8
core id     : 0
cpu cores   : 4
apicid      : 0
initial apicid  : 0
fpu     : yes
fpu_exception   : yes
cpuid level : 13
wp      : yes
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm cpuid_fault epb pti tpr_shadow vnmi flexpriority ept vpid fsgsbase smep erms xsaveopt dtherm ida arat pln pts
bugs        : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs
bogomips    : 6984.16
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management:

processor   : 1
vendor_id   : GenuineIntel
cpu family  : 6
model       : 58
model name  : Intel(R) Core(TM) i7-3770K CPU @ 3.50GHz
stepping    : 9
microcode   : 0x17
cpu MHz     : 1596.450
cache size  : 8192 KB
physical id : 0
siblings    : 8
core id     : 1
cpu cores   : 4
apicid      : 2
initial apicid  : 2
fpu     : yes
fpu_exception   : yes
cpuid level : 13
wp      : yes
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm cpuid_fault epb pti tpr_shadow vnmi flexpriority ept vpid fsgsbase smep erms xsaveopt dtherm ida arat pln pts
bugs        : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs
bogomips    : 6984.16
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management:

// repeated 8x for every CPU core
sheetalkamat commented 4 years ago

Two issues here:

  1. Vscode doesn't request for cancellation on encodedSemanticClassifications-full when completions are asked. @mjbvz you would want to look into that.
  2. We don't check cancellation token when we encounter arrow functions
Info 1330 [12:33:13.47] request:
    {"seq":126,"type":"request","command":"updateOpen","arguments":{"changedFiles":[{"fileName":"c:/temp/freemap-v3-react/src/components/ObjectsResult.tsx","textChanges":[{"newText":"\n            ","start":{"line":43,"offset":60},"end":{"line":43,"offset":60}}]}],"closedFiles":[],"openFiles":[]}}
Perf 1331 [12:33:13.48] 126::updateOpen: elapsed time (in milliseconds) 0.5508
Info 1332 [12:33:13.48] response:
    {"seq":0,"type":"response","command":"updateOpen","request_seq":126,"success":true,"body":true}
Info 1333 [12:33:13.108] request:
    {"seq":127,"type":"request","command":"encodedSemanticClassifications-full","arguments":{"file":"c:/temp/freemap-v3-react/src/components/ObjectsResult.tsx","start":0,"length":2322}}
Info 1334 [12:33:13.108] Starting updateGraphWorker: Project: c:/temp/freemap-v3-react/tsconfig.json
Info 1335 [12:33:13.156] Finishing updateGraphWorker: Project: c:/temp/freemap-v3-react/tsconfig.json Version: 6 structureChanged: false Elapsed: 48ms
Info 1336 [12:33:13.156] Different program with same set of files:: oldProgram.structureIsReused:: 2
Perf 1337 [12:33:23.58] 127::encodedSemanticClassifications-full: elapsed time (in milliseconds) 9950.2389
Info 1338 [12:33:23.59] response:
    {"seq":0,"type":"response","command":"encodedSemanticClassifications-full","request_seq":127,"success":true,"performanceData":{"updateGraphDurationMs":48},"body":{"spans":[453,5,1537,461,10,1552,479,15,2824,500,10,1552,518,18,2824,546,1,3073,549,10,1536,573,16,2057,591,5,1024,597,2,1536,600,5,1536,614,7,1793,625,1,2817,630,8,1793,642,8,2817,654,8,1793,697,7,1792,705,3,3088,712,2,1793,716,3,1793,721,3,1793,726,4,1793,732,6,1793,761,2,2089,766,10,2816,777,6,1792,800,3,2089,806,2,2088,811,7,2816,841,2,2088,844,4,2560,881,4,2089,887,3,2089,895,4,1792,915,2,2089,920,4,1040,925,12,272,938,8,1792,960,21,2561,996,21,2561,1098,2,1792,1128,3,2561,1133,3,2561,1138,3,1792,1164,3,2088,1196,8,2816,1205,2,1792,1229,8,1792,1242,2,1792,1369,2,2088,1418,1,2816,1445,2,2088,1448,2,2560,1476,4,2088,1513,4,2088,1540,3,2088,1576,3,2088,1586,2,2088,1589,6,3088,1596,10,2832,1607,3,2088,1688,4,2088,1825,15,2825,1844,5,1793,1851,9,1536,1870,7,2561,1879,5,1792,1885,7,2560,1893,7,2560,1904,8,2561,1914,5,1792,1920,4,2560,1925,8,2560,1937,8,2561,1951,5,1792,1957,4,2560,1962,9,2560,1973,4,2560,2000,5,1792,2006,4,2560,2011,9,2560,2021,2,2560,2057,18,2825,2079,8,2817,2089,8,768,2098,10,1536,2119,8,3073,2128,2,1793,2146,8,2816,2155,13,2824,2171,4,2561,2188,2,2561,2219,13,2057,2235,7,2824,2246,15,2824,2265,18,2824,2287,14,2824,2302,16,2056],"endOfLineState":0}}
Info 1339 [12:33:23.59] request:
    {"seq":133,"type":"request","command":"completionInfo","arguments":{"file":"c:/temp/freemap-v3-react/src/components/ObjectsResult.tsx","line":44,"offset":13,"includeExternalModuleExports":true,"includeInsertTextCompletions":true}}
Info 1340 [12:33:23.61] getCompletionData: Get current token: 0
Info 1341 [12:33:23.61] getCompletionData: Is inside comment: 0
Info 1342 [12:33:23.62] getCompletionData: Get previous token 1: 0
Info 1343 [12:33:23.62] getCompletionsAtPosition: isCompletionListBlocker: 0
Info 1344 [12:33:23.68] getCompletionData: Semantic work: 6
Info 1345 [12:33:23.75] getCompletionsAtPosition: getCompletionEntriesFromSymbols: 4
Perf 1346 [12:33:23.76] 133::completionInfo: elapsed time (in milliseconds) 17.1248
zdila commented 4 years ago

Is it released already? Intellisense is still unuseable for me in clean Code Insiders installation.

Version: 1.48.0-insider
Commit: 20cba51fb305868238eddc69758d259c29b3230d
Date: 2020-08-07T05:39:52.666Z
Electron: 7.3.2
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Linux x64 5.7.0-2-amd64
zdila commented 4 years ago

Oh, sorry, now I see milestone TypeScript 4.0.1.