Skip to content

TSServer high cpu usage #30004

Description

  • VSCode Version: 1.31.1
  • OS Version: Kubuntu 18.04

Steps to Reproduce:
These steps reproduce under heavy load:

  1. Press Control + Space to trigger Intellisense to autocomplete something(Or any action that triggers a request to TSServer)
  2. Cancel the request by moving the cursor somewhere else

I've also tested it with both with trace: verbose and off (thinking it might be just me having "typescript.tsserver.trace": "verbose" on TSServer)

TSServer creates an empty file under /tmp/vscode-typescript/tscancellation-session.tmpLastFileNumber

When files start to pile up, TSServer starts to lag/freeze, have very long delays in responding requests and making VSCode also unresponsive or slow and causing horrible CPU Spikes.

Removing those files restores VScode's speed and TSServer resolves requests under 200ms

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

Activity

  1. vscodebot commented on Feb 15, 2019

    @vscodebot

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

  2. mjbvz commented on Feb 15, 2019

    @mjbvz

    Those files are likely just a symptom, and not the cause, of any performance issues. 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

  3. brajuitorul commented on Feb 18, 2019

    @brajuitorul
    Author

    Would like to rectify,the amount of files is not affecting just VSCode or TSServer, is affecting my whole machine. Probably VSCode or TSServer is trying to read that folder and it starts to hang?

    No errors whatsoever in the logs, no stack traces, nothing out of the ordinary.

    Info 0    [13:6:29.539] Starting TS Server
    Info 1    [13:6:29.540] Version: 3.3.1
    Info 2    [13:6:29.540] Arguments: /usr/share/code/code /usr/share/code/resources/app/extensions/node_modules/typescript/lib/tsserver.js --useInferredProjectPerProjectRoot --enableTelemetry --cancellationPipeName /tmp/vscode-typescript/tscancellation-4a683f11eccf527696ae.tmp* --logVerbosity verbose --logFile /home/andrei/.config/Code/logs/20190218T105235/exthost1/vscode.typescript-language-features/tsserver-log-CIyVjR/tsserver.log --locale en --noGetErrOnBackgroundUpdate
    Info 3    [13:6:29.540] Platform: linux NodeVersion: 10 CaseSensitive: true
    Info 4    [13:6:29.549] Binding...
    

    --cancellationPipeName /tmp/vscode-typescript/tscancellation-4a683f11eccf527696ae.tmp*

    Which matches all the file names in /tmp/vscode-typescript
    (for this session at least)

    Shouldn't VSCode delete those temp files or signal TSServer the message was received and delete the files? Or shouldn't they be deleted when VSCode is closed? In 4hrs of work, it piled 1700 more empty files...

    Complete log split in 4:
    tsserver-00.log
    tsserver-01.log
    tsserver-02.log
    tsserver-03.log

  4. mjbvz commented on Feb 19, 2019

    @mjbvz

    Thanks for the logs. I see a few assertions in the logs but nothing that should cause this issue. I don't even see very many long running requests, which we would expect if TypeScript itself is misbehaving

    Can you also share the output of running code --status on the command line. You can follow these instructions for more information about performance issue

    One other thought, does the folder you are working in contain a literal *?

  5. brajuitorul commented on Feb 20, 2019

    @brajuitorul
    Author

    No, it does not contain *, it was a project name I've replaced with * forgot to mention that, sorry.
    Same story, the project name is replaced with *. The name doesn't contain any special characters or such.
    Here's the code --status , I managed to catch it when it went all out on the CPU.

    
    14:36:02 - andrei[~]$ code --status
    (code:15365): Gtk-WARNING **: 14:36:07.925: Theme parsing error: gtk.css:68:35: The style property GtkButton:child-displacement-x is deprecated and shouldn't be used anymore. It will be removed in a future version
    (code:15365): Gtk-WARNING **: 14:36:07.925: Theme parsing error: gtk.css:69:35: The style property GtkButton:child-displacement-y is deprecated and shouldn't be used anymore. It will be removed in a future version
    
    (code:15365): Gtk-WARNING **: 14:36:07.925: Theme parsing error: gtk.css:73:46: The style property GtkScrolledWindow:scrollbars-within-bevel is deprecated and shouldn't be used anymore. It will be removed in a future version
    [15398:0220/143608.530544:ERROR:sandbox_linux.cc(379)] InitializeSandbox() called with multiple threads in process gpu-process.
    
    Version:          Code 1.31.1 (1b8e8302e405050205e69b59abb3559592bb9e60, 2019-02-12T02:19:29.629Z)
    OS Version:       Linux x64 4.15.0-45-generic
    CPUs:             Intel(R) Core(TM) i3-7100U CPU @ 2.40GHz (4 x 2400)
    Memory (System):  11.62GB (2.18GB free)
    Load (avg):       4, 3, 2
    VM:               0%
    Screen Reader:    no
    Process Argv:     .
    GPU Status:       2d_canvas:                    enabled
                      checker_imaging:              disabled_off
                      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
                      surface_synchronization:      enabled_on
                      video_decode:                 unavailable_off
                      webgl:                        enabled
                      webgl2:                       enabled
    
    CPU %   Mem MB     PID  Process
        0      143    1753  code main
        0       24    1762     zygote
        0      464    1826       window (Popup.js - *-dashboard)
        0      250    1860         extensionHost
      102     2189    2192           electron_node tsserver.js 
        0       83    2275             electron_node typingsInstaller.js typesMap.js 
        0      119    2210           electron_node eslintServer.js 
        0       48    2503           /usr/share/code/code /usr/share/code/resources/app/extensions/json-language-features/server/dist/jsonServerMain --node-ipc --clientProcessId=1860
        0       71   12856           /usr/share/code/code /usr/share/code/resources/app/extensions/css-language-features/server/dist/cssServerMain --node-ipc --clientProcessId=1860
        0       48    1871         watcherService
        0       59    2143         searchService
        0      107    1910       shared-process
        0       71    1800     gpu-process
    
    Workspace Stats:
    |  Window (Popup.js - *-dashboard)
    |    Folder (*-dashboard): 363 files
    |      File types: js(256) svg(62) mp3(13) json(10) png(7) yml(2) css(2)
    |                  babelrc(1) local(1) html(1)
    |      Conf files: jsconfig.json(1) package.json(1)
    
    
  6. removed their assignment
    on Feb 20, 2019
  7. mjbvz commented on Feb 20, 2019

    @mjbvz

    Sheetal Nandi (@sheetalkamat) or someone else on the TS team: can you please take a look at the logs to see what may be causing the high cpu usage for the tsserver. I didn't see anything obvious

  8. changed the title [-][TSServer] TSServer creates countless empty files on Abort request[/-] [+]TSServer high cpu usage[/+] on Feb 20, 2019
  9. sheetalkamat commented on Mar 6, 2019

    @sheetalkamat
    Member

    Seems like we are getting too many invocations for /home/andrei/.cache/typescript/3.3/node_modules/.staging :: WatchInfo: /home/andrei/.cache/typescript/3.3/node_modules

    We do ignore those but on Linux because node doesn't support recursive directory watcher, we create recursive directory watcher of our own and that might be refreshing too many times.

    I think just like how we ignore directories in node_modules that start with "." we should ignore them in sys implementation of recursive directory watcher as well.

  10. added
    BugA bug in TypeScript
    and removed
    Needs InvestigationThis issue needs a team member to investigate its status.
    on Mar 6, 2019
  11. added a commit that references this issue on Mar 6, 2019
    79a1f29
  12. sublimator commented on Oct 15, 2019

    @sublimator

    Sheetal Nandi (@sheetalkamat)
    I'm still getting high cpu usage from tsserver even in latest TypeScript :(
    image

  13. sublimator commented on Oct 15, 2019

    @sublimator
  14. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions