-
Notifications
You must be signed in to change notification settings - Fork 6.2k
-
Hello!
I am very grateful to this project, as it has completely transformed the way I develop. Today, I run my development directly on the VM where the code is deployed. It is simply fantastic.
However, the more dependant I became on Code Server, the more I needed it to perform reliably. This has been a sore point lately.
As you can see below, Chrome's task manager shows a CPU utilisation of 300 percent on my MacBook Pro (with an M2 chip):
imageThe issue also seems to be accompanied by this message:
imageThe good news is that the VM is healthy and have plenty of resources. So the issue is on the machine using the code server as a PWA (a progressive web app):
image imageI would appreciate any hints on how to troubleshoot this issue, it has been killing my productivity in the last few days.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 4 comments 4 replies
-
To be completely transparent I do something non-standard which I do not think would in any way cause this issue but I am stating it here anyway. I just hate your icon! And it does not help me reorient myself around my deployed servers so one thing I have been doing is replacing the icon in Mac OS X:
imageTo ensure the icon is not overwritten when the PWA is updated I added this to my .bashrc
(seems like a really bad practice, I know!):
# Overwrite code-server's icon with my own
cp ~/.icons/code-server.icns ~/Applications/Chrome\ Apps.localized/pgvector.app/Contents/Resources/app.icns
The replacing icon is just a Sepia-color-adjusted copy of the standard VS Code icon.
Beta Was this translation helpful? Give feedback.
All reactions
-
Some other folks have reported resource issues with the client as well, but I am not sure what causes it. You might have better luck asking the VS Code folks upstream, we just wrap the web version of VS Code and do a bit of patching so we are not nearly as knowledgeable as they are.
If you can, reproducing with VS Code web directly (run code serve-web
using native VS Code) could help identify if the issue is VS Code core or if the problem is only in code-server due to one of our patches or something.
Either way, to debug probably some browser profiling will be required. Do you have a specific way to reproduce? Does it happen after specific actions, or randomly?
Beta Was this translation helpful? Give feedback.
All reactions
-
Hello and thank you so much for the response.
Now it happens every half hour so I am unable to do development anymore.
I reload the window then it's good again. After half hour the memory usage and the CPU utilization skyrocket.
I am very interested in what you said. You said that native vscode can run in the browser? And in this case how do I connect it to my code-server? Or you are just saying that I can try to use vs code locally but in a browser to see how it behaves.
I never experienced this when running vscode locally.
Do code-server offer troubleshooting commands on the server side? How to see the active sessions and the running processes. I really need to figure out what is causing this.
Beta Was this translation helpful? Give feedback.
All reactions
-
You said that native vscode can run in the browser
Yup, you just run code serve-web
. What code-server does is take VS Code's web server and patch it a little to make it easier to self-host, but the core is all in VS Code itself.
Or you are just saying that I can try to use vs code locally but in a browser to see how it behaves.
Yup exactly, this is to determine if the problem is in VS Code itself (in which case we want to report upstream) or if it is a problem with the changes we make to VS Code here in code-server.
Do code-server offer troubleshooting commands on the server side?
Nope, on the server side all that is available are the logs. I am not sure they will show anything since the memory leak appears to be client-side.
Beta Was this translation helpful? Give feedback.
All reactions
-
I was using a vs code extension from this project https://github.com/evidence-dev/evidence
I have disabled it and since then, I have not experienced this issue once. I think you were right and this had nothing to do with this project. I guess I was quick to assume it was being caused by code-server.
Beta Was this translation helpful? Give feedback.
All reactions
-
It is still happening, even though less frequently than before. I do not have many extensions enabled so I am not sure how to troubleshoot this. When the issue kicks in it becomes difficult to open the process explorer so it is hard to know what is causing it.
imageAre you familiar of ways to narrow down on what might be causing this?
Beta Was this translation helpful? Give feedback.
All reactions
-
The issue is still here and not gone.
@code-asher I would really appreciate some information on the following:
- So what I understand is that vscode is built in a way that makes it possible for you to make it run in the browser, hence Coder did not have reinvent anything to make this happen. Fantastic! Speaking of which, where is the actual vscode process on the server? is it completely wrapped by the code-server command? is the code-server command made by you? what is the difference between the code-server used when connecting over SSH to the one used by Coder? Many questions!
- In the code-server command line options, there is a mention of an update check that happens automatically every 6 hours, how is this ensured not to interrupt ongoing sessions and is it possible that it is the cause of this screen that I always see every next morning:
- After checking my vscode version it turned out to be 3 months old 1.103.2 so does this mean that I have to do something manually to keep it updated? I just now manually installed the
.deb
release and reinstalled it, reloading the systemd service unit. Seems like something you could have pointed out to me. Or maybe I was too stupid to mention it. I am just learning! - How to see and manage the ongoing sessions when using vscode via code-server. I mean, unlike native vscode, closing the window does not shut down the processes (and the terminal sessions). So this obviously creates a very different situation and requires different tooling. Does the code-server cli offer ways to do such things?
- Is there a way to troubleshoot the connection between the PWA and the code-server? sometimes code-server PWA gets suddenly very slow and I have no visibility as to what might be causing this.
I am sorry to overwhelm you with so many questions but if my life depends on this thing I have to understand in order to help you keeping it polished and working!
Beta Was this translation helpful? Give feedback.
All reactions
-
So what I understand is that vscode is built in a way that makes it possible for you to make it run in the browser
Yes exactly! Basically we take VS Code's web server (which is maintained in the VS Code core) and patch it a little to make it more friendly to self-host. You can run VS Code's web server directly with code serve-web
. It mostly works the same, except as I mentioned we make some changes, for example these: https://github.com/coder/code-server/blob/main/docs/FAQ.md#whats-the-difference-between-code-server-and-github-codespaces (it mentions Codespaces specifically, but the list applies to running code serve-web
locally as well, since that is what Codespaces is using).
Speaking of which, where is the actual vscode process on the server? is it completely wrapped by the code-server command
Yes, we import VS Code directly (on demand) so it runs as part of the main code-server process. We have a parent/wrapper process, then the main process right below that, which is code-server/VS Code. Below that more process can be spawned, like the extension host, terminal host, etc.
is the code-server command made by you
There a code-server
command made by us (the main one which imports/spawns VS Code and runs the web server, analogous to code serve-web
) and another code-server
command made by VS Code which is used to open files in the current instance from the integrated terminal (it can only interact with the current instance, it cannot spawn new ones, all it does is send a bit of JSON to code-server's control socket). So they share the same name but are different (actually we would like to replace VS Code's with ours so there is always just one command, as it can be confusing).
what is the difference between the code-server used when connecting over SSH to the one used by Coder
They share the same remote code. The difference is just the frontend, whether a browser or a local VS Code window.
there is a mention of an update check
Yeah this just checks GitHub for the latest release. It does not actually perform any updates though, that has to be done manually. It is purely informational, so it is probably not related to the memory issues, although it may be worth disabling the update notice just to see and be sure.
is it possible that it is the cause of this screen that I always see every next morning
Hmm the image seems to not load for me.
does this mean that I have to do something manually to keep it updated
Yup exactly. We actually used to have automatic updates, but we decided it was better to let system package managers handle it.
Seems like something you could have pointed out to me
Fair, we should add information on how to actually update to the update notification, or at least a link to the documentation.
How to see and manage the ongoing sessions when using vscode via code-server
The only way really would be to look at the process listing and see what is running, I think. We do have endpoints for session management, but they are meant for internal use (we use them when you want to open a file in a running instance of code-server from an external terminal), and there is no endpoint to list all sessions. We have no cli commands that would help here, but VS Code does have a --status
command which we might want to expose.
Is there a way to troubleshoot the connection between the PWA and the code-server
The best way I think would be to use the browser profiling tool. But, if the slowness ends up being on the server side, then it will be trickier, you would need to profile the server end instead. I am not 100% sure if Node's --prof
flag can be passed to code-server though, might be something we have to look into.
VS Code themselves have some guidelines on debugging performance issues. For example, using "disable all extensions" then reproducing, checking the built-in process explorer, etc. But in my experience some of these are unavailable or straight-up broken on the web version of VS Code.
https://github.com/microsoft/vscode/wiki/performance-issues
I am sorry to overwhelm you with so many questions
No worries at all, I am happy to answer any questions and glad to have folks so interested in how things work!
Beta Was this translation helpful? Give feedback.