0

Let me start with some context. I am running Ubuntu 24.04 on a Dell XPS 9500 with a six core i7, 64gb of RAM and over 500gb of free space. The thermals are fine, mostly around 70 degrees Celsius (does hit 100 briefly), both when running fine and slow. I am using disk encryption, although I don't notice any performance hit from it and had this problem across multiple reinstalls and 2 machines, with and without encryption.

Most of the work I do is web apps development with VS Code in Node.js + Angular and Firefox.

When I turn on my machine everything is running fine. The start-up is quick, the system is responsive and all is well. As I start working, after 2-3 hours, the system slows down to a point where a simple Alt+Tab switch takes 2 seconds and every character I type takes half a second to register in VS Code.

At this time, the CPU load is nowhere near 100%, ram usage is usually above 30gb, but also nowhere near 100%. I do notice that this seems to happen when the prefetch cache fills up the free ram. Then, ubuntu starts swapping instead of freeing the cache, even though I have swappiness set to 10.

To solve this, I have to restart the machine and start over. At this point it is getting annoying.

Am I correct in assuming that the reason for this is the cache that is filling the free RAM? I have read about how this is a good thing, but I fail to see how exactly, when it is causing my system so go to swap with plenty of free RAM?

EDIT: I am not sure if it is relevant, but during development I am using nodemon that monitors source changes, recompiles (NestJS projects) and reloads the projects. This happens for Angular projects too.

Also, I have Angular CLI cache disabled, so the compiler will probably be generating a lot of small files on every recompile/reload. Could this be somehow confusing the prefetch system?

tivanov
  • 56

1 Answers1

1

For anyone having the same problem, It seems that the solution is to clean the prefetch cache periodically. My system has been running smooth for several days without slowdowns.

So basically, I set up a cron job that runs this command every 30m:

sync && echo 3 | sudo tee /proc/sys/vm/drop_caches

After this the cache usage stays around 10gb and the rest of the ram remains free to use.

You can read more about how to do this here: How do I clean or disable the memory cache?

I know this is very much not recommended, but in my case it works.

tivanov
  • 56