microsoft / microsoft/vscode

Performance loss in the VS Code `fs` abstraction that potentionally hits all extensions

Open
#324,223 0 comments 5 reactions 1 assignee Claimed by @alexdima View on GitHub
Dominant language
TypeScript
Stars
193k
Forks
42.4k
PR merge metrics
PR metrics pending

Description

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

- VS Code Version: 1.127.0
- OS Version: Arch Linux (but also reproduced on Windows)

the `workspace.fs` api has a dedicated fast path for extension host specific `file://` and vfs operations. Except that it still sends a request to the rendering process and waits for that. In extensions with a lot of FS operations, the effect can be quite extreme. Performance profiling showed the extension host idling 50--70% of the time, waiting for the rendering process to return the rpc call.

I've written a [repo extension show case the impact](https://github.com/SWAT-engineering/vscode-vfs-slow-vfs-overhead). It registers a very small VFS, and then hits both `file` uri's and the vfs, both via the `vscode.workspace.fs` abstraction and skipping it, The impact is quite extreme, but it greatly depends on the performance of the IO operation that has to happen. If the IO takes much longer than the rpc call to the rendering process, the difference is less pronounced. We noticed it when writing typecheckers and other language features in typescript that interacted with a lot of small files (and a case where we had a VFS that was simulating a lot of files without requiring a lot of real world IO).

Note that I've prepared a PR to fix this: #324070 and it contains a further analysis of the specific problem.

The benchmark results:

```
[info] **** Starting new round of benchmark ***
[info] starting file:/// benchmark
[info] [readDirectory] via workspace.fs: 333.0ms
[info] [readDirectory] direct: 153.1ms
[info] [readDirectory] Direct is 179.9ms faster (2.2x speedup)
[info] [stat] via workspace.fs: 1911.8ms
[info] [stat] direct: 323.6ms
[info] [stat] Direct is 1588.3ms faster (5.9x speedup)
[info] [readFile] via workspace.fs: 2960.5ms
[info] [readFile] direct: 1722.1ms
[info] [readFile] Direct is 1238.4ms faster (1.7x speedup)
[info] starting VFS benchmark
[info] [readDirectory] via workspace.fs: 76.9ms
[info] [readDirectory] direct: 6.1ms
[info] [readDirectory] Direct is 70.9ms faster (12.6x speedup)
[info] [stat] via workspace.fs: 1003.3ms
[info] [stat] direct: 15.4ms
[info] [stat] Direct is 987.9ms faster (65.3x speedup)
[info] [readFile] via workspace.fs: 888.1ms
[info] [readFile] direct: 10.6ms
[info] [readFile] Direct is 877.5ms faster (84.0x speedup)```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.