Score:2

Exploiting the potential of RAM in a computer with a large amount of it

pe flag

I have a machine with 64 GB of RAM and I would like to be able to take full advantage of it in Ubuntu.

Is there any application or way to achieve this? I mean something that leaves loaded in RAM applications or processes to run very fast.

Thank you.

BЈовић avatar
us flag
is 64GB a large amount of ram?
OmarL avatar
sy flag
@BЈовић I think so. My build server at work has 4GB. My personal laptop has 12GB and this is barely ever even half-full.
RonJohn avatar
cn flag
@BЈовић that, of course, depends on the kind of system.
user3553031 avatar
in flag
@Героямслава Then your build server is woefully underspecced. My desktop **20 years ago** had 1 GiB; 4 GiB would have cost another $USD 500 or so but the main limiting factors would have been motherboard compatibility and 32-bit software. My current desktop, built in fall 2021, has 32 GiB. A very quick search at a computer components dealer showed 64 GiB of RAM available starting at about $USD 200. 64 GiB is larger than average for a new desktop in 2023 but nothing unusual.
ax flag
_“I mean something that leaves loaded in RAM applications or processes to run very fast.”_ Is there anything making you think this is not done by default?
OmarL avatar
sy flag
@user3553031 You're not wrong. I do get the occasional OOM, and have to make efforts to get it running well. I just wanted to add a pauper's point of view.
cn flag
@user3553031 if the OP is used to the pitiful amount most corporate laptops have, 64GB will sound like a lot. I've just specced a number-crunching box with 512GB, but the "high-spec" laptops we can get as standard are 8GB. My 8-year-old desktop has 3× that
Score:16
ky flag
chp

You could try to use RAM-disk, but that is generally a very poor idea.

In principle, Ubuntu is already taking advantage of your memory. It allocates so-called cache to load applications and data from RAM instead of much slower storage (SSD/HDD).

bdsl avatar
ru flag
Ram is wiped when the machine is powered off - so I suspect taking full advantage of the ram may require leaving the machine powered on for a long time. Will ubuntu eventually fill the ram with a cached copy of whatever parts of the hard disk were most recently used?
chp avatar
ky flag
chp
No, the memory management in Linux is optimised to use the RAM most efficiently, to cache as much as possible but also to leave empty space in case a new application is started. So, unless you open too much for your RAM, you should never reach 100% memory utilisation, but leaving everything on default you are already using the RAM very efficiently.
bdsl avatar
ru flag
I thought it didn't need to leave space free, the cached disk blocks in memory would just instantly be replaced with application data when required for a running app.
Ben Voigt avatar
vg flag
@bdsl: That's very nearly true. Unmodified cache blocks don't need to be flushed out, they can simply be discarded which is much cheaper. But they still have to be zeroed out before they can be reused, or else a process may learn contents of the file that was in the cache, even though it didn't have permission to open and read that file. So the kernel tries to have a non-empty list of pages that have already been zeroed in the background and are ready for immediate commitment.
RonJohn avatar
cn flag
@bdsl "I suspect taking full advantage of the ram may require leaving the machine powered on for a long time." What's wrong with that?
RonJohn avatar
cn flag
@bdsl "Will ubuntu eventually fill the ram with a cached copy of whatever parts of the hard disk were most recently used?" Sure. As long as the system is busy reading a lot of disk files.
bdsl avatar
ru flag
@RonJohn nothing wrong with that - it just means that a fuller answer to the question might involve recommending leaving the machine on while using it for hours in the hope of it speeding up slightly. At least not turning off just for short breaks. Or maybe the effect is so minuscule that there's no point.
RonJohn avatar
cn flag
@bdsl the problem is that you don’t notice the speed; you only notice the *slowness* when you *don’t* have enough memory. A desktop example: open lots of Chrome tabs (back before it freed up memory on sleeping tabs) on s system with 8GB RAM. Performance will tank at some point when it starts swapping. Add another 8GB and it pushes the problem down to even more open tabs. I now have 32GB RAM and never see the **slowness**.
Ommadawn avatar
pe flag
What about `preload` program? Would it give some performance in this scenario?
Score:1
zw flag
aaa

The primary factor here is your usage pattern for this machine. If it's a desktop machine, and you simply leave applications running without closing them, then of course they will stay in memory. Moreover, in this case hibernating the machine will restore all the apps to the memory afterwards (though since this will dump the memory to disk and read it afterwards, it's not too much faster than launching the app anew).

Otherwise, as the other answer mentioned, Linux already allocates as much cache as it can—not only for apps, but for any and all files and directories that are read from the filesystem. Questions on how to optimize this caching pop up regularly on Linux discussion sites—but this endeavor is pretty much pointless, since the system itself is highly tuned already by the programmers.

Since desktop usage doesn't see much variation in its patterns from the viewpoint of the system, there isn't really much sense in bothering about tuning for RAM usage. The situation is different on servers, where programmers and admins may allocate almost all of the memory to a database application and tune it so that it performs little disk i/o.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.