vscode: Storage migration is slow and happens on each new window

This one only took 2.8s, but sometimes I get 4s startup times:

image

  • VSCode Version: Code - Insiders 1.29.0-insider (5438af145cf480ce0162bda0799435684b293ec5, 2018-11-07T00:54:27.213Z)
  • OS Version: Darwin x64 17.7.0
  • CPUs: Intel® Core™ i7-4870HQ CPU @ 2.50GHz (8 x 2500)
  • Memory(System): 16.00 GB(2.71GB free)
  • Memory(Process): 315.69 MB working set(0.00MB peak, 166.49MB private, 149.20MB shared)
  • Load(avg): 2, 2, 2
  • VM: 0%
  • Initial Startup: yes
  • Screen Reader: no
  • Empty Workspace: yes
  • Timings:
Component Task Duration(ms) Info
[main] start => app.isReady 70 true
[main] nls:start => nls:end 1 true
[main] app.isReady => window.loadUrl() 318 true
[main->renderer] window.loadUrl() => begin to require(workbench.main.js) 344 NewWindow
[renderer] require(workbench.main.js) 1257 cached data: NO
[renderer] require workspace storage 4
[renderer] require & init workspace storage 13
[renderer] register extensions & spawn extension host 256
[renderer] restore viewlet 0
[renderer] restore panel 0
[renderer] restore editors 268 1: workbench.editors.untitledEditorInput
[renderer] overall workbench load 494
[main->renderer] workbench ready 2541
[renderer] extensions registered 2810

⚠️ Make sure to attach these files from your home-directory: ⚠️ -prof-cda2.extHost.cpuprofile.txt -prof-cda2.main.cpuprofile.txt -prof-cda2.renderer.cpuprofile.txt

prof.zip

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (15 by maintainers)

Commits related to this issue

Most upvoted comments

@kieferrm and I looked into optimizing the parseStorage function further: https://github.com/Microsoft/vscode/tree/mjbvz/62733 Using @octref’s workspace data, parseStorage goes from 4 seconds to 30ms, while total new window time goes from 6.5 seconds to 2.5 seconds .

Main optimization points:

  • We were computing data for all storage but then immediately discarding almost all of it. This change splits parseStorage into 4 functions, one for empty, noResource, folder, and multiRoot which allows us to compute only the data that we really need

  • We also ultimately only care about a specific workspace. In the folder case, this lets us avoid iterating over a large number of workspaces; all we need to iterate over are the workspaces that have the target folder as a prefix. In the empty case, this lets us avoid creating extra maps that we then pick one from and discard

  • Optimize some of the inner loops by removing now redundant checks

Still needs much more testing and review