18

I have installed Ubuntu 18.04 LTS I used to use Visual Studio Code for my projects but the problem is that it is very slow. It hooks or locks, I do not know how to put it so that they understand me, because I use the translator and I do not know what will be better. The fact is that it is very bad, both in this version and in 16.04. I also have it in Windows and it works perfectly. Sometimes it crashes, blocking all processes and denying access to the computer. Does that have something to do with Ubuntu, should I optimize it in any way? If you give me some idea, well, as I said, I got used to Visual Studio and I tried Sublime text-3 which is much better, but I should get used to it and I do not like it very much. Forgive the syntax, I must use the translator. Thank you.

6
  • 1
    Please edit your question to include output from top and free. Capture the output while VS is running slow.
    – user535733
    Commented Jul 2, 2018 at 21:08
  • 1
    Your question is why VS is slow on your system, and we need troubleshooting information to answer that question. Are you saying that you won't troubleshoot the problem? Or are you saying that you are unfamiliar with top and free? Or are you merely asking if VS runs slow for everybody?
    – user535733
    Commented Jul 2, 2018 at 22:37
  • 1
    Is this the same 248MB RAM laptop you previously asked about? If so, then VS is likely running slow for an obvious reason.
    – user535733
    Commented Jul 2, 2018 at 23:27
  • 1
    Open a terminal window. Run top and free in that terminal. Look at their manpages. Learn what they do. Why VS is slow may have many possible causes. You must provide additional information to determine which cause is affecting you.
    – user535733
    Commented Jul 2, 2018 at 23:32
  • No @user535733, it's an Acer with 2 GB DDR2 Commented Jul 2, 2018 at 23:45

5 Answers 5

16

From https://code.visualstudio.com/docs/editor/integrated-terminal:

By default, the integrated terminal will render using GPU acceleration on most machines. It does this using multiple elements, which are better tuned than the DOM for rendering interactive text that changes often.

However, Electron/Chromium are slower rendering to canvas on some environment and so VS Code also provides a fallback DOM-renderer experience. VS Code will try to detect slow performance and give you the option to change via a notification.

You can also change the rendering directly by setting terminal.integrated.gpuAcceleration in your user or workspace settings. (On Windows/Linux: File > Preferences > Settings)

{
    "terminal.integrated.gpuAcceleration`": "off"
}

Something else that might improve performance is to ignore Chromium's GPU blacklist by launching VS Code with code --ignore-gpu-blacklist.

It worked for me, not like a real terminal but better than nothing, I hope this helps!

6
  • Thank you @FernandoDuz for your suggestion. Currently I do not have a laptop for breakdown, when I manage to solve the fault, I will try your idea. But much of the problem is due to RAM. Commented Sep 22, 2018 at 15:43
  • I never use the integrated terminal, only the editor and it's still super slow. Does this advice still apply?
    – Daniel V
    Commented Aug 10, 2020 at 21:28
  • Yeap, this advice apply for the editor, but, with the las versión of Vscode and Ubuntu 18.04 all goes ok now. I can confirm that from new installations Commented Aug 11, 2020 at 22:34
  • starting with gpu option .. got this: Warning: 'ignore-gpu-blacklist' is not in the list of known options, but still passed to Electron/Chromium. got this warning on ubuntu 20.04 gnome and also on manjaro 21 xfce.
    – alexzander
    Commented May 28, 2021 at 9:17
  • 1
    have the same problem with vs code, but for me just writing text and selecting text in editor area has bad performance. meaning that sometimes just works fine and sometimes freezes for just 0.5 seconds.
    – alexzander
    Commented May 28, 2021 at 9:20
3

special thanks to this reddit post.

my problem with vs code: bad performance when writing text and selecting text in the editor. freezes about 0.5 seconds

there are several causes for this problem:

  • monitor refresh rate

(desktop user case) check you graphics card refresh rate. if you GPU has a max of 60hz then configure your monitor to 60hz.

if you have a secondary external monitor (laptop user case), then:

  1. check your gpu refresh rate. (for example you find 60hz)
  2. go to settings
  3. make secondary monitor primary
  4. disable built-in display (laptop display)
  5. set secondary monitor to 60hz
  6. reboot

for me, this option with refresh rate worked like a charm. right now its not lagging anymore when typing/selectin text and im using manaro 21 xfce. i know, why talking about manjaro on askubuntu, but i had the same problem in ubuntu 20.04 gnome too, but at that time i wasnt stroke with a refresh rate idea.


  • vim emulator vs code extension

usually, vs code is handling the keypresses by itself, but when vim extension is installed it overrides the control. vim extension is single-threaded and not very well optimized and when you type you may have bad performance, so uninstall vim extension.

  • too many extensions

try uninstalling the unimportant extensions or make a sacrifice to reduce the total number.

  • bad graphics driver

try using other graphics driver. use open-source ones, try performance. use proprietary ones, try performance.

  • laptop is in power saving mode

try setting your cpu to performance mode.

EDIT date: (11.05.2022)

the problem was my HDD, was too slow. after moved to SSD, performance of writing text is good, because write and read speed from the SSD is faster.

but vs code is still slow. performance is really bad (compared to sublime + im very impatient).

solution: move to sublime text 4.

done.

indeed, vs code is slow

1

As of Feb 2022, some systems still experience poor performance in the latest VS Code with default settings on Ubuntu 20.04. However, the options below have been known to resolve the issue. YMMV, depending on system configuration and hardware.

The most likely culprit for general slowness of Electron apps on Linux is a lack of GPU acceleration, which is (often? always?) disabled by default. To check whether the underlying Chromium engine provides hardware acceleration to VS Code:

  1. Open a VS Code window
  2. In a separate terminal window, run code --status
  3. Check the output for errors, and note the "GPU Status" section.

If hardware acceleration appears to be disabled, (e.g., webgl: disabled_software, skia_renderer: enabled), performance will likely suffer until that's addressed.

Option 1: Ignore GPU Blacklist

In some cases, Electron/Chromium may prevent VS Code from enabling GPU acceleration due to a blacklist, which can be disabled by launching VS Code with code --ignore-gpu-blacklist. It's expected that the following warning appears:

Warning: 'ignore-gpu-blacklist' is not in the list of known options, but still passed to Electron/Chromium

The difference will be very noticeable if this worked, particularly in the integrated terminal.

Option 2: Edit Terminal Rendering Setting

According to the vscode docs, the integrated terminal renderer can be changed with the setting, terminal.integrated.gpuAcceleration. The default value is "auto".

The terminal features 3 renderers that fallback if they are detected to perform poorly in this order:

  1. WebGL ("terminal.integrated.gpuAcceleration": "on" or "auto")
  2. Canvas ("terminal.integrated.gpuAcceleration": "canvas"
  3. DOM ("terminal.integrated.gpuAcceleration": "off")

Note that it can be difficult to confirm whether vscode is obeying this setting. (Please, someone update this answer if you know how to check this!)

(Older versions of vscode had a similar setting, terminal.integrated.rendererType, which no longer exists.)

Option 3: Check Video Card Drivers

Linux tools provide many ways to check video card drivers, and the methods for updating drivers vary by manufacturer and preferences about third party. That's outside the scope of this question, but

  1. Which display drivers are in use? sudo lshw -c video
  2. Can the system render something basic at 60fps? sudo apt-get install mesa-tools; glxgears
  3. Where do I find more? In Firefox, the about:support page has heaps of video card & driver info.
  4. Even more???? Look elsewhere.

Option 4: Look for Misbehaving Extensions

Sometimes it crashes, blocking all processes and denying access to the computer

Even though that symptom hints at another problem, start with the GPU acceleration options above because other performance issues may be harder to track down. Next, disable extensions to narrow down whether the performance drag comes from vscode itself or a misbehaving extension. Tools like top can also be used to determine which process is overusing resources.

Option 5: Reinstall VS Code

I'm almost embarrassed to add this option, but it saved me today. After some updates (and a system restart), --ignore-gpu-blacklist stopped working, and nothing I tried could fix it. After tracking down a few of the errors in code --status, I concluded that there might be something wrong with the Snap package for VS Code. I downloaded the .tar.gz from the website, and thankfully the hardware acceleration is working again.

Option 6: Profile VS Code

I haven't gotten this far down the list, but if nothing else works, there is a way to profile vscode itself with dev tools.

0
0

In my case that was the workspace issue, It had become too big - a lot of data including photos was in a folder. After I moved the data folder outside the workspace, it became so much smoother with nearly no delay.

0

I have a RTX GPU and laptop (Nitro 5) having 144Hz display, connected to a Dell Ultrasharp monitor with 60 Hz display.

I had performance problem, that is lagging with first Chrome.I thought it was something to do with memory and deleted the kubernetes kind cluster running in my machine. But still there was this problem. Then installed firefox and was happy with that.

But then I opened VS Code and the same problem there. I read somewhere that both Chrome and VSCode has this Electron based backend. So I figured it was not the memory but something else. I tried to disable the GPU setting as was given in other answers. To no avail.

Then I just made the laptop screen as primary and my extended display as secondary and the problem disappeared !

Note i use PopOS which is based on Ubuntu

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .