VSCode: Difference between revisions
No edit summary |
sync from iihe-scripts docs/user (wiki-push) |
||
| Line 12: | Line 12: | ||
When several people have such sessions open, the MDS saturates: simple operations that should take ~10 ms take seconds, for everyone. This page tells you how to reduce your own contribution. | When several people have such sessions open, the MDS saturates: simple operations that should take ~10 ms take seconds, for everyone. This page tells you how to reduce your own contribution. | ||
== Open a project folder, not your whole home — the most important step == | |||
The single biggest source of metadata requests is opening your ''whole home directory'' (<code>/user/<your-username></code>) as the VS Code workspace. When the workspace root is your home, VS Code's file watcher and language server keep an eye on and scan ''everything'' you have. No amount of settings can fix that — the config below helps, but only if the workspace is a specific project folder. | |||
* '''What to open:''' a project folder, e.g. <code>/user/<your-username>/<project></code>, not your home. | |||
* '''How:''' <code>File → Open Folder…</code> and pick the project directory. | |||
* '''How to tell what's open:''' the folder shown in the top-left corner of the window is the workspace root. If it is just your username (<code>/user/<you></code>) rather than a project folder, that is the problem. | |||
* '''After changing:''' Command Palette (<code>Ctrl+Shift+P</code>) → <code>Developer: Restart Extension Host</code>. | |||
This one change does more to keep the shared area fast than all the other settings on this page combined. | |||
== Server-side baseline (admin-managed, janitor) == | == Server-side baseline (admin-managed, janitor) == | ||
| Line 144: | Line 155: | ||
* Keep only a light VS Code window on /user (watchers excluded) and do heavy work (search, indexing, big git operations) on a ''local scratch copy'' of the project under /tmp, copying results back when done. | * Keep only a light VS Code window on /user (watchers excluded) and do heavy work (search, indexing, big git operations) on a ''local scratch copy'' of the project under /tmp, copying results back when done. | ||
* For very large source trees, work on local scratch entirely and treat /user as the results area only. | * For very large source trees, work on local scratch entirely and treat /user as the results area only. | ||
* Avoid opening your whole home directory (<code>/user/<your-username></code>) as the workspace root — open the specific project folder instead. | * Avoid opening your whole home directory (<code>/user/<your-username></code>) as the workspace root — open the specific project folder instead. This is the most important step; see ''Open a project folder, not your whole home'' above. | ||
Latest revision as of 12:14, 8 September 2026
VS Code on the /user CephFS filesystem — reduce your metadata load
Why this matters
The shared /user area is a CephFS filesystem served by a single metadata server (MDS). Ordinary editor operations (stat, ls, open, reading directory entries) turn into metadata requests that the MDS must serve for all users — on the login machines and on the worker nodes. A few VS Code features are notoriously chatty:
- the file watcher polls watched directories in the background;
- Pylance (the Python language server) indexes and scans the whole workspace;
- the npm / task auto-detection runs a recursive search for package.json files across the whole tree.
When several people have such sessions open, the MDS saturates: simple operations that should take ~10 ms take seconds, for everyone. This page tells you how to reduce your own contribution.
Open a project folder, not your whole home — the most important step
The single biggest source of metadata requests is opening your whole home directory (/user/<your-username>) as the VS Code workspace. When the workspace root is your home, VS Code's file watcher and language server keep an eye on and scan everything you have. No amount of settings can fix that — the config below helps, but only if the workspace is a specific project folder.
- What to open: a project folder, e.g.
/user/<your-username>/<project>, not your home. - How:
File → Open Folder…and pick the project directory. - How to tell what's open: the folder shown in the top-left corner of the window is the workspace root. If it is just your username (
/user/<you>) rather than a project folder, that is the problem. - After changing: Command Palette (
Ctrl+Shift+P) →Developer: Restart Extension Host.
This one change does more to keep the shared area fast than all the other settings on this page combined.
Server-side baseline (admin-managed, janitor)
The admins deploy a baseline of the settings below into every account on the mX login machines via a janitor script. Two things to know:
- It is injected only if your file does not exist yet:
~/.vscode-server/data/Machine/settings.json. Existing files are never overwritten, so anything you have already configured stays yours. - About 15 users currently already have their own file. For those, nothing is injected — see the section below: I already have a settings.json — what do I need to check?
Where to put the settings
- Recommended (per project, versioned): create a file
.vscode/settings.jsonat the root of your project and paste the settings there. It only affects that project. - Your account on one machine (overrides / complements the baseline): Command Palette → Preferences: Open Remote Settings (SSH: mX) → switch to the JSON editor.
- Baseline (managed by admins, do not delete):
~/.vscode-server/data/Machine/settings.json
After applying: Command Palette → Developer: Restart Extension Host.
Complete settings.json
The file below is commented and safe to paste as-is. Replace <your-username> and <project> with your own values where indicated. Settings in this file are pure JSON-with-comments (VS Code accepts them).
{
// ---- 1. File watching (the single biggest source of metadata requests) ----
// Never watch generated, dependency or cache directories.
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/node_modules/**": true,
"**/__pycache__/**": true,
"**/.mypy_cache/**": true,
"**/.pytest_cache/**": true,
"**/.ruff_cache/**": true,
"**/.venv/**": true,
"**/.conda/**": true,
"**/*.egg-info/**": true,
"**/build/**": true,
"**/dist/**": true,
"**/htmlcov/**": true,
"**/.cache/**": true
},
// Optional: whitelist ONLY the directories you actually edit.
// Leave the array empty to keep the default (watch everything except the
// excludes above). If you fill it, only these paths are watched at all.
"files.watcherInclude": [
"/user/<your-username>/<project>/src"
],
// ---- 2. Pylance / Python language server ----
// "default" keeps basic IntelliSense; "none" disables it completely
// (cheapest option).
"python.languageServer": "default",
// Analyse only the files you have open, not the whole workspace.
"python.analysis.diagnosticMode": "openFilesOnly",
// No background workspace index.
"python.analysis.indexing": false,
// No automatic import searches across the tree.
"python.analysis.autoSearchPaths": false,
"python.analysis.autoImportCompletions": false,
"python.analysis.useLibraryCodeForTypes": false,
// ---- 3. npm / task auto-detection ----
// This is what launches the recursive `rg --files -g **/package.json`
// scans. Turn it off unless you actively use the NPM Scripts panel.
"npm.autoDetect": "off",
"task.autoDetect": "off",
"gulp.autoDetect": "off",
"grunt.autoDetect": "off",
"jake.autoDetect": "off",
// ---- 4. Search (Ctrl+Shift+F) ----
// Respect .gitignore so searches don't walk everything.
"search.useIgnoreFiles": true,
"search.useGlobalIgnoreFiles": true,
"search.exclude": {
"**/.git": true,
"**/node_modules": true,
"**/__pycache__": true,
"**/.venv": true,
"**/build": true,
"**/dist": true
},
// ---- 5. Git ----
// Don't re-stat the whole working tree in the background.
"git.autorefresh": false,
// Disable Git integration entirely for repositories you don't need it on.
"git.enabled": true,
// ---- 6. Editor / autosave ----
// Batch saves instead of writing on every keystroke.
"files.autoSave": "afterDelay",
"files.autoSaveDelay": 5000
}
I already have a settings.json — what do I need to check?
If your account already had a ~/.vscode-server/data/Machine/settings.json before the janitor went live, the baseline was not injected for you. Please open that file (or Preferences: Open Remote Settings) and make sure these keys are present. You can copy this minimal block and merge it into your existing file:
{
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/node_modules/**": true,
"**/__pycache__/**": true,
"**/.venv/**": true,
"**/build/**": true,
"**/dist/**": true
},
"python.analysis.diagnosticMode": "openFilesOnly",
"python.analysis.indexing": false,
"npm.autoDetect": "off",
"task.autoDetect": "off",
"search.useIgnoreFiles": true,
"git.autorefresh": false
}
These are the keys that matter most. Everything else in the full example above is optional tuning.
What each block does
files.watcherExclude/files.watcherInclude— stops the background file watcher from polluting cache/dependency folders, or restricts it to the few directories you edit. This alone removes the majority of requests from a typical session.python.analysis.*— Pylance walks the tree for imports and indexing.openFilesOnly+indexing:falseremoves nearly all of that traffic while keeping completion in the files you have open.npm/task auto-detect off— removes the recursive package.json search.search.useIgnoreFiles— searches stop descending into ignored dirs.git.autorefresh:false— avoids background stat() storms on large repos.
Still slow? The strongest options
- Keep only a light VS Code window on /user (watchers excluded) and do heavy work (search, indexing, big git operations) on a local scratch copy of the project under /tmp, copying results back when done.
- For very large source trees, work on local scratch entirely and treat /user as the results area only.
- Avoid opening your whole home directory (
/user/<your-username>) as the workspace root — open the specific project folder instead. This is the most important step; see Open a project folder, not your whole home above.