Announcement

Collapse
No announcement yet.

Yes, Linux Does Bad In Low RAM / Memory Pressure Situations On The Desktop

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Originally posted by skeevy420 View Post

    It's exactly how I'd expect it to behave.

    A system with the memory all used up and no swap space available runs like shit...you don't say...
    I expect it to RECOVER.. The problem is that Linux doesn't recover after the overcommit of memory passes. The fact that you need to run "swapoff -a; swapon -a" to recover is the problem, combined with that swapoff -a runs ~100 times slower than it should considering the available SSD disk-speed.

    Comment


    • Originally posted by latalante View Post
      ...
      2. If you made this mistake and turned off swap, run resource-consuming programs with a memory limit.
      systemd-run --user -p MemoryLimit=3G google-chrome
      ...

      Code:
      > systemd-run --user -p MemoryLimit=100M chromium-browser
      
      > ps -e -o rss,comm --sort -rss | grep chrom
      433840 chromium-browse
      400108 chromium-browse
      227212 chromium-browse
      191332 chromium-browse
      182840 chromium-browse
      139124 chromium-browse
      120764 chromium-browse
      96780 chromium-browse
      89604 chromium-browse
      74584 chromium-browse
      72324 chromium-browse
      47516 chromium-browse
      42988 chromium-browse
      12476 chromium-browse

      Comment


      • Originally posted by atomsymbol

        Ok. Let's retrace the steps from the beginning, maybe it will resolve some issues in our communication:
        1. You read (past tense) https://lkml.org/lkml/2019/8/4/15 which contains the text "I think that's not how the system should behave in this situation"
        2. You responded with "It's exactly how I'd expect it to behave"
        3. I replied with "This is interpreting serious unsolved operating system deficiencies as positive features of the operating system"
        4. You wrote "In this case they removed a safe guard and pushed it beyond its limit"
          1. I believe they didn't remove any safeguard. Which safeguard do you believe they removed? Enabling swap only postpones it to a later time, the end result (unusable system) being the same.
          2. If the working set of running applications exceeds the size of system memory, any large amount of swap space on HDD/SSD is unable to prevent a significant system slowdown (unless the swap is located on something like 3D XPoint memory, but still the cost of copying pages from/to such a device is unavoidable and can result in slowdowns in certain scenarios).
        5. You wrote "No matter how many safe guards are in place, it doesn't help it if a user pushes something beyond its limits"
          1. It seems to me that the first part of the sentence is contradicting the second part. If safe guards are in place, it is impossible for the user the push the system beyond its limits.
        6. You wrote "How is the kernel supposed to know if it needs to halt Plasma, Firefox, ...? All it can do is juggle stuff with what little resources it has available" and "IMHO, this is really a problem that should be solved by a daemon"
          1. It is true that solution to OOM issues can be in user-space and/or/xor in kernel-space. However, it seems to me that a partially-kernel-based solution is more deterministic and less likely to fail than a user-space daemon with no assistance from the kernel. The only entity on the machine that precisely knows whether free memory is available or not available is the Linux kernel (Linux kernel is a monolithic kernel, not a microkernel).
        Do you not know any stupid people? They're why we have safeguards in the first place.

        You think you have it all nice and safe and working good. Nope, nope, nope. Some stupid motherf*cker will come along any minute and teach you three new dangers you never even considered because why would someone be that f*cking stupid; but they are that stupid. They are that stupid.

        A safeguard is like a safety on a gun. There's a good chance you'll shoot yourself in the foot if you're stupid and play with the gun like it's a toy.

        Comment


        • Originally posted by skeevy420 View Post

          Do you not know any stupid people? They're why we have safeguards in the first place.

          You think you have it all nice and safe and working good. Nope, nope, nope. Some stupid motherf*cker will come along any minute and teach you three new dangers you never even considered because why would someone be that f*cking stupid; but they are that stupid. They are that stupid.

          A safeguard is like a safety on a gun. There's a good chance you'll shoot yourself in the foot if you're stupid and play with the gun like it's a toy.
          But the way Linux currently behaves in regards to OOM is basically like a loaded gun without safety on the counter of a supermarket.

          Comment


          • Originally posted by elatllat View Post


            Code:
            > systemd-run --user -p MemoryLimit=100M chromium-browser
            
            > ps -e -o rss,comm --sort -rss | grep chrom
            433840 chromium-browse
            400108 chromium-browse
            227212 chromium-browse
            191332 chromium-browse
            182840 chromium-browse
            139124 chromium-browse
            120764 chromium-browse
            96780 chromium-browse
            89604 chromium-browse
            74584 chromium-browse
            72324 chromium-browse
            47516 chromium-browse
            42988 chromium-browse
            12476 chromium-browse
            I'm not sure but it works only with cgroup v2 (systemd.unified_cgroup_hierarchy=1).
            systemd version the issue has been seen with systemd 238 +PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN...


            Maybe try it
            Code:
            sudo systemd-run -p MemoryMax=512M /usr/bin/sudo -u $username env DISPLAY=:0 google-chrome --user-data-dir=/tmp/chrome
            systemctl show run-r5fdff4a5a5864f47bebf05bb6b233007.service
            systemctl status run-r5fdff4a5a5864f47bebf05bb6b233007.service
            Maybe better to use --uid= and --gid= with sudo systemd-run. Check.
            Code:
            sudo systemd-run -t -p MemoryMax=512M --uid=1000 --gid=100 env DISPLAY=:0 google-chrome --user-data-dir=/tmp/chrome

            Code:
            cat /usr/lib/systemd/system/user\@.service
            ...
            Delegate=pids memory
            ...
            Last edited by latalante; 08 August 2019, 10:39 AM.

            Comment


            • Originally posted by skeevy420 View Post

              It's exactly how I'd expect it to behave.

              A system with the memory all used up and no swap space available runs like shit...you don't say...
              You are a moron.

              A system with memory used up and no swap available is supposed to run the OOM killer to "sacrifice children" (actual error message it prints in the dmesg), killing non-critical processes to stay functional and responsive, so that someone can actually do something about it.

              I can't go in and fix shit if the GUI does not work, or if SSH is unresponsive.

              On anything remotely new I always had to run without swap partition to have the OOM killer wake up and do its job, if I leave swap the system will start swapping like crazy and lock down everything even on a SSD.

              Comment


              • Originally posted by latalante View Post
                ...only with cgroup v2...
                Code:
                > mount | grep -c cgroup/memory
                1
                Originally posted by latalante View Post
                ...
                Code:
                sudo systemd-run -p MemoryMax=512M /usr/bin/sudo -u $username env DISPLAY=:0 google-chrome --user-data-dir=/tmp/chrome...
                Code:
                > sudo systemd-run -p MemoryMax=512M /usr/bin/sudo -u $USER env DISPLAY=:0 chromium-browser --user-data-dir=/home/$USER/.config/chromium/
                
                > group_mem.sh chrom
                1,045 MB chromium-browse
                
                > systemctl show run-r4c138899383242ad9f92331b51d24c41.service | grep -i Memory
                MemoryCurrent=[not set]
                MemoryAccounting=no
                MemoryLow=0
                MemoryHigh=infinity
                MemoryMax=536870912
                MemorySwapMax=infinity
                MemoryLimit=infinity
                MemoryDenyWriteExecute=no
                Maybe you should try before you recommend.
                I think I'll try cgroup_enable/cgcreate/cgexec next

                Comment


                • Originally posted by starshipeleven View Post
                  You are a moron.

                  A system with memory used up and no swap available is supposed to run the OOM killer to "sacrifice children" (actual error message it prints in the dmesg), killing non-critical processes to stay functional and responsive, so that someone can actually do something about it.

                  I can't go in and fix shit if the GUI does not work, or if SSH is unresponsive.

                  On anything remotely new I always had to run without swap partition to have the OOM killer wake up and do its job, if I leave swap the system will start swapping like crazy and lock down everything even on a SSD.
                  I also think that a big part of the problem is how damn near every process runs with 0 and there really isn't any good solution for that; like all programs into their own group and using group policies, aliasing programs and append a nice/renice function to them, and other similar fustercluck solutions.

                  When the kernel is in an OOM situation and is also being told that everything is equal, that can make it more difficult for it to decide what to kill and what not to kill. That's where some sort of user-level monitor would come in handy (which is what a lot of Android methods do) because that's a lot easier for most people to use and figure out, some sort of save state method that can cache a program to disk and kill it off like others have suggested, use lots of nice levels and killing of higher numbers first.

                  Comment


                  • Originally posted by elatllat View Post

                    Code:
                    > mount | grep -c cgroup/memory
                    1


                    Code:
                    > sudo systemd-run -p MemoryMax=512M /usr/bin/sudo -u $USER env DISPLAY=:0 chromium-browser --user-data-dir=/home/$USER/.config/chromium/
                    
                    > group_mem.sh chrom
                    1,045 MB chromium-browse
                    
                    > systemctl show run-r4c138899383242ad9f92331b51d24c41.service | grep -i Memory
                    MemoryCurrent=[not set]
                    MemoryAccounting=no
                    MemoryLow=0
                    MemoryHigh=infinity
                    MemoryMax=536870912
                    MemorySwapMax=infinity
                    MemoryLimit=infinity
                    MemoryDenyWriteExecute=no
                    Maybe you should try before you recommend.
                    I think I'll try cgroup_enable/cgcreate/cgexec next
                    there needs to be a -E to pass an environment variable

                    Code:
                     -E --setenv=NAME=VALUE Set environment

                    Comment


                    • Originally posted by tildearrow View Post

                      Please don't bring the Windows mentality of "if it doesn't work well, bring better hardware" to the Linux world.
                      As an example, Linux makes an HDD look fast, while Windows needs an SSD to be fast.

                      Also, please note that this was in 2015 when I only had 8GB RAM in my system. I then upgraded to 16.
                      (This still occurs with my dad's 1GB laptop, however, and we'd love to fix it but sometimes we have fights and not enough money which distances us from the solution)
                      Linux uses memory extremely well. Not giving machine proper amount of ram, is like putting Reno engine in half million Ferrari.
                      Now I won't disagree that things can improve. But getting frustrated over switching off RAM is like throwing shovels around and play hide and seek with eyes shut.

                      Comment

                      Working...
                      X