Skip to content

outline view is always slow and loading, code cannot be folded. #28389

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

Closed
qdechochen opened this issue Jul 18, 2018 · 29 comments
Closed

outline view is always slow and loading, code cannot be folded. #28389

qdechochen opened this issue Jul 18, 2018 · 29 comments
Assignees
Labels
Bug A bug in TypeScript Domain: Performance Reports of unusually slow behavior Domain: TSServer Issues related to the TSServer Fix Available A PR has been opened for this issue

Comments

@qdechochen
Copy link

Issue Type: Bug

  • VSCode Version: 1.25.1
  • OS Version: Mac OS 10.13.5

Steps to Reproduce:

Since my last post was closed, I have to post again.
I need to say first: I have disabled all extensions, and I've never installed the local history extension.

  1. open a js file.
  2. change something, and save
  3. outline is loading..... and code cannot be folded until outline view is ready (nothing happends when click -/+. Sometimes, the fold symbols( -, +) disappear, and when outline view is ready, they will be back.

it's annoying especially when i want to see some code which is folded, and i can't unfold it.

wx20180717-130338 2x

VS Code version: Code 1.25.1 (1dfc5e557209371715f655691b1235b6b26a06be, 2018-07-11T15:33:29.235Z)
OS version: Darwin x64 17.6.0

System Info
Item Value
CPUs Intel(R) Core(TM) i5-7267U CPU @ 3.10GHz (4 x 3100)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: enabled
rasterization: enabled
video_decode: enabled
video_encode: enabled
vpx_decode: enabled
webgl: enabled
webgl2: enabled
Load (avg) 3, 4, 4
Memory (System) 16.00GB (1.65GB free)
Process Argv /Applications/Visual Studio Code.app/Contents/MacOS/Electron --disable-extensions
Screen Reader no
VM 0%
Extensions disabled
@vscodebot
Copy link

vscodebot bot commented Jul 18, 2018

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

@jrieken
Copy link
Member

jrieken commented Jul 18, 2018

@qdechochen
Copy link
Author

qdechochen commented Jul 18, 2018

@jrieken Here's the tracking file. thank you.

As what i mentioned before, i disabled all extensions, while problem is still there.

PS: i got my macbook hot all the time. mmmmm, maybe i can bake something on it 😂

CPU-20180718T082407.627Z.cpuprofile.txt
vscode-cpu
for convenience:
profile-vs

@jrieken
Copy link
Member

jrieken commented Jul 18, 2018

Looks pretty idle doesn't seems to be in the extension host. Please check via code --status as described here: https://github.com/Microsoft/vscode/wiki/Performance-Issues#collect-information-about-the-running-vs-code

@qdechochen
Copy link
Author

@jrieken Here's the screenshot, thank you.

vscode-status

@jrieken
Copy link
Member

jrieken commented Jul 19, 2018

Hm, if at all it's the TypeScript extension (or its server) but 62% CPU doesn't sound outrageous...

@jrieken jrieken assigned mjbvz and unassigned jrieken Jul 19, 2018
@qdechochen
Copy link
Author

qdechochen commented Jul 19, 2018

60-70% CPU can lasts for serveral minutes, and the outline is not shown correctly, i can't fold or unfold code. When CPU take up rate comes to 0, everything becomes normal.

PS: there are no ts files in the folder, only js files.

@qdechochen
Copy link
Author

Hello? Anything else that I can do here? @mjbvz

@mjbvz
Copy link
Contributor

mjbvz commented Jul 23, 2018

Does this reproduce in the latest VS Code insiders build with all extensions disabled?

@qdechochen
Copy link
Author

@mjbvz Latest VS Code insiders build has the same problem on my mac.

@richsilv
Copy link

richsilv commented Jul 25, 2018

I believe I have a similar problem. Profiling the extensions reveals nothing - they all seem to be behaving themselves, but code outline and autocompletion are taking minutes to refresh, the latter displaying Loading... for ages if I Ctrl-Space. This is a new issue which I've only just started to experience - previously, everything ran fine in the same workspace.

Here's my --status output in case it's helpful:

--- platform/documentation ‹documentation-site-emotion* M?› » code --status
Gtk-Message: 11:39:28.795: Failed to load module "overlay-scrollbar"
Gtk-Message: 11:39:28.808: Failed to load module "canberra-gtk-module"

Version:          Code 1.25.1 (1dfc5e557209371715f655691b1235b6b26a06be, 2018-07-11T15:40:20.190Z)
OS Version:       Linux x64 4.15.0-29-generic
CPUs:             Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz (4 x 2872)
Memory (System):  15.40GB (6.90GB free)
Load (avg):       2, 2, 1
VM:               0%
Screen Reader:    no
Process Argv:     /usr/share/code/code . --inspect-extensions=9333
GPU Status:       2d_canvas:                    enabled
                  flash_3d:                     enabled
                  flash_stage3d:                enabled
                  flash_stage3d_baseline:       enabled
                  gpu_compositing:              enabled
                  multiple_raster_threads:      enabled_on
                  native_gpu_memory_buffers:    disabled_software
                  rasterization:                disabled_software
                  video_decode:                 unavailable_software
                  video_encode:                 enabled
                  vpx_decode:                   unavailable_software
                  webgl:                        enabled
                  webgl2:                       enabled
CPU %	Mem MB	   PID	Process
    2	   110	  4832	code main
    0	    16	  4843	   zygote
    6	   284	  4920	     window (● button.tsx - documentation - Visual Studio Code)
    0	    47	  4961	       watcherService
    0	   205	  4964	       extensionHost
    0	   110	  5063	         electron_node tslintServer.js 
    0	    47	  5113	         electron_node jsonServerMain.js 
    0	    47	  5049	       searchService
    0	   110	  5015	     shared-process
    3	    63	  4909	   gpu-process
Workspace Stats:
|  Window (● button.tsx - documentation - Visual Studio Code)
|    Folder (documentation): 121 files
|      File types: json(56) js(37) md(6) tsx(6) png(3) ts(2) svg(2) snap(1)
|                  gitignore(1) log(1)
|      Conf files: package.json(1) tsconfig.json(1) tslint.json(1)
|                  settings.json(1)

@mjbvz
Copy link
Contributor

mjbvz commented Jul 28, 2018

@richsilv Please open a separate issue

@qdechochen Can you please try collecting the TS Server log:

  1. Set "typescript.tsserver.log": "verbose",
  2. Restart VS Code and reproduce the problem
  3. In VS Code, run the TypeScript: Open TS Server log command
  4. This should open a folder with a tsserver.log file in it

Look through that log file for errors or stack traces. If you can share the log, I can also take a look to see if anything stands out

⚠️Warning: The TypeScript log may include information from your workspace, including file paths and source code. If you have any concerns about posting this publicly on Github, just let me know and we can arrange something else. On our side, we only use these logs to investigate issues like this

@qdechochen
Copy link
Author

qdechochen commented Jul 31, 2018

tsserver.log

@mjbvz Log file is attached here. I don't understand the log details, but I think I give you some info about the timestamp which may help.

10:13:0.xxx is the time I opened VSCODE.
Then the layout was loading, and loading, fold or unfold didn't work.
About 10:13:15.xxx - 10:13:30.xxx, I added some simple code.
The layout was still loading and loading, fold or unfold didn't work.
About 10:14:00.xx (which maybe the timestamp of [10:14:4.941] shown in the log file), layout was shown correctly, I could fold/unfold.

But in the log, there's a time gap between 10:13:0.714 and 10:14:4.941

structureChanged: false Elapsed: 0ms
Info 132 [10:13:0.714] Starting updateGraphWorker: Project: /dev/null/inferredProject1*
Info 133 [10:13:0.714] Finishing updateGraphWorker: Project: /dev/null/inferredProject1* Version: 1 structureChanged: false Elapsed: 0ms
Info 134 [10:13:0.714] event:
{"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/Users/echo.chen/Projects/open-source/osql/lib/command.js","diagnostics":[]}}
Info 135 [10:13:0.714] Starting updateGraphWorker: Project: /dev/null/inferredProject1*
Info 136 [10:13:0.714] Finishing updateGraphWorker: Project: /dev/null/inferredProject1* Version: 1 structureChanged: false Elapsed: 0ms
Info 137 [10:14:4.941] event:
{"seq":0,"type":"event","event":"suggestionDiag","body":{"file":"/Users/echo.chen/Projects/open-source/osql/lib/command.js","diagnostics":[{"start":{"line":1,"offset":23},"end":{"line":1,"offset":50},"text":"文件是 CommonJS 模块;它可能会转换为 ES6 模块。","code":80001,"category":"suggestion"}]}}
Info 138 [10:14:4.942] event:

@qdechochen
Copy link
Author

@mjbvz anything else I can do to help?

@mjbvz
Copy link
Contributor

mjbvz commented Aug 3, 2018

Thank you for the logs! From the logs, it looks like TypeScript 2.9 is being used. Was the log collected from a vscode insiders build or from the current VS Code 1.25 release? If these logs are from vscode insiders, have you configured your workspace to use a different version of typescript?

@qdechochen
Copy link
Author

qdechochen commented Aug 6, 2018

@mjbvz I do have insider version installed on my mac, but the log was from version 1.25.1. I don't think I did the configuration to change to another version of ts, because I didn't know how to do that.

Now I tried selecting ts version, it only shows use vs code's version 2.9.2.

image

then I tried install and switch to typescript 3.0.1, problem still there.

@qdechochen
Copy link
Author

I installed typescript 3.0.1 to my project, and switch to it, problem is still there.
Then I installed typescript 2.8.4, switch to it. GUESS WHAT, it's working NORMAL.

I changed to 2.9.2, problem comes out again.
So I will use 2.8.4 for now. Maybe my problem is caused by something not woking well with typescript 2.9.2?

Since 2.9.2 comes from vs code 1.25. How can I change it to 2.8 by default, without install it in my every project?

@mjbvz
Copy link
Contributor

mjbvz commented Sep 18, 2018

Can you please share the logs from the most recent version of typescript, which is not 3.1.0. This version of typescript is included in the latest vscode insiders build

@qdechochen
Copy link
Author

Can you please share the logs from the most recent version of typescript, which is not 3.1.0. This version of typescript is included in the latest vscode insiders build

Hi @mjbvz, I installed latest insider version, TS version is 3.1.0. but you said it's not 3.1.0??

with ts 3.1.0, problem is still there. here's the new log.
tsserver.log

@mjbvz
Copy link
Contributor

mjbvz commented Sep 19, 2018

Sorry, 'not' should have been 'now'

I cannot repo this issue and it unclear from the logs what is going wrong. The project seems to load properly and folding ranges + the outline are computed properly by the server. Are you able to share a small example project that demonstrates this issue so I can try debugging on my machine?

@qdechochen
Copy link
Author

qdechochen commented Sep 20, 2018

Hi @mjbvz,

please clone this repository to debug.

(https://github.com/qdechochen/osql.git)

Open it in code, then open ast-translator.js (or some other files), outline will be loading and loading. (sometimes, this step may be short.) Then you type something, do some change, outline will then be loading and loading, and may last for 30+ seconds after you stop typing.

Sorry, 'not' should have been 'now'

I cannot repo this issue and it unclear from the logs what is going wrong. The project seems to load properly and folding ranges + the outline are computed properly by the server. Are you able to share a small example project that demonstrates this issue so I can try debugging on my machine?

@lvegerano
Copy link

Im having the same issue where sometimes ever 2 CodeHelpers are running at a 100%. And I have to close Code to get is to go.
screen shot 2018-11-06 at 3 51 05 pm
screen shot 2018-11-06 at 3 52 08 pm

@mjbvz mjbvz transferred this issue from microsoft/vscode Nov 7, 2018
@mjbvz mjbvz removed their assignment Nov 7, 2018
@mjbvz
Copy link
Contributor

mjbvz commented Nov 7, 2018

I verified this in the latest typescript version using: https://github.com/qdechochen/osql.git

It includes a some very large and highly nested files which cause the navtree request to be queued for a very long time. I confirmed that this seems to be happening in the tsserver based on cpu usage

@weswigham weswigham added Bug A bug in TypeScript Domain: TSServer Issues related to the TSServer labels Nov 7, 2018
@rbuckton
Copy link
Member

@sheetalkamat: Can you verify whether this might also be resolved by #28629, given the large number of paths involved in the project? If it isn't, then either you or I can take a look at this for 3.3.

@sheetalkamat
Copy link
Member

@mjbvz @qdechochen The link to git repository is not working. Do I need to do anything special?

@qdechochen
Copy link
Author

@mjbvz @qdechochen The link to git repository is not working. Do I need to do anything special?

https://github.com/qdechochen/o2sql

@sheetalkamat
Copy link
Member

sheetalkamat commented Nov 30, 2018

@qdechochen I don't see any lag with typescript@next . Can you give it a try. Here is documentation on
using typescript nightly drop.

Was able to repro this.

@sheetalkamat
Copy link
Member

Assigning to @sandersn since I found out that tsserver gets stuck in suggestion diagnostics of ast-translator.js and upon breaking noticed that its doing some narrowing. @sandersn to look at improving perf or may be handling cancellation token if needed.

@sandersn
Copy link
Member

@sheetalkamat narrowed the problem to the checker.

From discussion with @sheetalkamat we came up with a few things for investigation:

  1. Does this repro with tsc as well?
  2. Does this repro with 3.1 or earlier?
  3. The code consists of a number of small, non-nested functions. It should check the cancellation token fairly often. I suspect a bug in auto type analysis, which is backed by control flow. This is probably another case where we should not be using checkExpressionCached, but checkExpression instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Performance Reports of unusually slow behavior Domain: TSServer Issues related to the TSServer Fix Available A PR has been opened for this issue
Projects
None yet
Development

No branches or pull requests