Skip to content
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

workspaceStorage storage leak #134532

Closed
hinell opened this issue Oct 6, 2021 · 3 comments
Closed

workspaceStorage storage leak #134532

hinell opened this issue Oct 6, 2021 · 3 comments
Assignees
Labels
workbench-state UI state across restarts

Comments

@hinell
Copy link

hinell commented Oct 6, 2021

// file: $HOME/.config/Code/User/workspaceStorage/xxxxxxxxxxxxxxhash/workspace.json
{
  "folder": "file:///path/to/projects/2021/foo/project-name-fork"
}

The above is the only way that VS Code currently associates workspace cache with a specific project residing in the folder: .....

Once the project's folder path gets renamed VS Code loses its reference to the project cache. Upon launching the cache gets rebuilt from scratch once again (ignoring the previous one). If repeated for several times the cache will grow enormously, wasting the startup-time and HDD storage space. C/C++ projects will turn into a storage killer (see related issues below).

Discovery

I got a C++ project that got indexed (including dependencies) multiple times. Later I've moved it into another place so it got indexed once again. The same thing happened to a whole range of other C++ projects and forks I have. I ended up with having a significant amount of gigabytes wasted. 😑

Steps to Reproduce:

Assuming you are using Linux-based OS and zsh/bash.

  1. Install C/C++ tools extension
  2. Get any C/C++ project: e.g.
    $ git clone --depth 1 --no-tags https://github.com/madler/zlib /tmp/zlib-0
  3. Remember the number of dirs in .../workspaceStorage, like so:
    $ dir -d $HOME/.config/Code/User/workspaceStorage/* | wc -l
  4. Open in VS Code, wait until cache gets indexed, close VS Code, rename the folder, open it up once again
    $ code /tmp/zlib-0
    $ mv /tmp/zlib-0 /tmp/zlib-1
    $ code /tmp/zlib-1
  5. Repeat the last 2 steps and see the number of folders in .../workspaceStorage growing

Solutions proposal

  1. Make it configurable so one can keep cache in the .vscode folder
  2. Somehow mark the workspace (e.g. by a cookie) and keep its value both inside workspace.json and .vscode, making the cache a workspace-path-independent
  3. Regularly clean stale caches - should be very cheap to implement and maintain

Workaround

As a temporarily solution I've made a simple bash script to audit cache files, checkout: code.workspaces.cache.filter


Versions

  • VS Code Version: 1.60.2 and earlier
  • OS Version: Kubuntu 20.04 - Kubuntu 21.04 / x64

Extensions

  • C/C++ tools [v1.6.0] - Not a culprit in this case for sure

Related issues

@sandy081 sandy081 assigned bpasero and unassigned sandy081 Oct 12, 2021
@bpasero bpasero assigned dbaeumer and unassigned bpasero Oct 12, 2021
@bpasero bpasero added the workbench-state UI state across restarts label Oct 12, 2021
@bpasero
Copy link
Member

bpasero commented Oct 12, 2021

I think #32461 is related.

@hinell
Copy link
Author

hinell commented Oct 13, 2021

@bpasero Thanks for letting me know. I've updated the OP.

@dbaeumer
Copy link
Member

Marking as as dup of #32461

@github-actions github-actions bot locked and limited conversation to collaborators Dec 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
workbench-state UI state across restarts
Projects
None yet
Development

No branches or pull requests

4 participants