Honestly, Linux distros ( CatchyOS in my case) are getting so good at managing ram that now i’m just curious to know if i could use that extra free ram to remove some work load from my old pc cpu.

  • tal@lemmy.today
    link
    fedilink
    English
    arrow-up
    1
    arrow-down
    1
    ·
    1 day ago

    Yes, though usually it’s harder to make that tradeoff than it is to avoid disk I/O contention or network bandwidth.

    RAM-based caching of disk contents will have some minimal impact that way, though the main goal is reducing disk I/O; using something in RAM will use slightly less CPU time than pulling it off a disk, especially if you are using an encrypted filesystem or encrypted block device. Your system will already be using otherwise-unused RAM to cache content on disks.

    If application software is smart enough to have its own caching based on free memory or based on a number that the user uses, you can go twiddling that. IIRC, Bethesda’s engine (Skyrim, etc) has some setting that lets one keep a given number of cells loaded (though I don’t know whether all loaded cells are active or not, so it might be aimed more at limiting how many areas the computer is dealing with). But that’s at an application level, not a systemwide toggle.

    There isn’t really a great systemwide Linux feature that I’m aware of that gives you major CPU usage reduction by expending memory. The problem is, I think, that in general, if you want to avoid costly recomputation, it’s often preferable from an application standpoint to use a disk cache rather than a memory cache. If the cost is large enough, it’s preferable to just use a disk-based cache, which permits for persistent caching (I don’t wipe my cache every time I terminate, as a process) and usually permits for larger cache and still gets some of the benefits of RAM-based cache by letting the kernel handle sticking frequently-used disk contents into RAM. Plus, SSD storage has far lower latency (and somewhat-higher throughput) than rotational disk storage, so the cost of using a disk cache versus a memory cache is lower than it once was.

    Firefox is one program that I can think of that has both a disk-based cache and a memory-based cache, and looking at my current about:cache output on a new Linux laptop, it looks like these days, the default is to have the memory cache off by default, as I’ve got no entries in the memory cache.