How to get rid of freezes on low RAM PC’s.

  • This topic has 14 replies, 8 voices, and was last updated Oct 13-5:36 am by sybok.
Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #90458
    Member
    Mad Daimond

      I have an old laptop Dell Latitude 110l with Intel Pentium M 1.6 Ghz, 768mb RAM. And I had a problem with Antix-19 – when there was a little amount of free RAM the system was near in full freeze with HDD LED always turns on. The problem of this was a wrong setting for the swap file – when free RAM was near the end, the system aggressively tries to free it and of top of it it starts to write the swap file at the same time. To resolve this issue you need to do:
      sudo nano /etc/sysctl.conf
      find the line:
      vm.swappiness = 10
      and change it to:
      vm.swappiness = 60

      This makes your system to start using the SWAP much earlier (when there will be near 50% of free RAM) and when the free RAM will be at near end this is not overkill your system, like it was with swappiness 10 (which is recommends for the PC’s with near 16+GB RAM, by the way). Hope this will helps to someone.

      #90463
      Moderator
      BobC
        Helpful
        Up
        0
        ::

        Investigate zram.

        Minimize what programs you are running. Do you have the antix-goodies package installed? In a terminal try ps_mem.py (RAM usage script):
        ps_mem.py

        Investigate each of the larger programs you see. Maybe something is running (and using memory) that you don’t need. Be careful about changing things.

        #90466
        Forum Admin
        anticapitalista
          Helpful
          Up
          0
          ::

          … like it was with swappiness 10 (which is recommends for the PC’s with near 16+GB RAM, by the way). Hope this will helps to someone.

          Got a source for this recommendation? Preferably one that refers to using a modern 4/5 series kernel.
          Thanks.

          Philosophers have interpreted the world in many ways; the point is to change it.

          antiX with runit - leaner and meaner.

          #90469
          Member
          Mad Daimond
            Helpful
            Up
            0
            ::

            Investigate zram.

            Minimize what programs you are running. Do you have the antix-goodies package installed?

            Yes, I have AntiX-goodies installed. As far as I understand, to use the zram, you need to install and configure it. Instead of it can I just use:
            sudo zram start

            with AntiX-goddies installed?

            Got a source for this recommendation? Preferably one that refers to using a modern 4/5 series kernel.
            Thanks.

            The swappiness is somewhat debatable thing, and its often recommends to test the comfortable swappiness value by yourself to you system. But the general principle is “The more RAM you have – the less swappiness value you can set” and vice versa.

            • This reply was modified 7 months ago by Mad Daimond.
            #90471
            Forum Admin
            anticapitalista
              Helpful
              Up
              0
              ::

              The swappiness is somewhat debatable thing, and its often recommends to test the comfortable swappiness value by yourself to you system. But the general principle is “The more RAM you have – the less swappiness value you can set” and vice versa.

              Indeed, it is debatable and depends on many factors and not just on the ‘general principle’ of ‘The more RAM you have – the less swappiness value you can set’.

              Philosophers have interpreted the world in many ways; the point is to change it.

              antiX with runit - leaner and meaner.

              #90472
              Moderator
              BobC
                Helpful
                Up
                0
                ::

                The antix-goodies package includes the ps-memc.py program. Did you try it? Post the results.

                Here was where I saw zram for low memory machines mentioned https://www.antixforum.com/forums/topic/making-a-pentium-4-laptop-useful-with-antix/
                I see anticapitalista on this thread. I’m sure he knows more than I do.

                One suggestion, if you don’t want freezes, don’t ask more of the PC than it has to give.

                #90473
                Member
                oops
                  Helpful
                  Up
                  0
                  ::

                  I have an old laptop Dell Latitude 110l with Intel Pentium M 1.6 Ghz, 768mb RAM. And I had a problem with Antix-19 – when there was a little amount of free RAM the system was near in full freeze with HDD LED always turns on. The problem of this was a wrong setting for the swap file – when free RAM was near the end, the system aggressively tries to free it and of top of it it starts to write the swap file at the same time. To resolve this issue you need to do:
                  sudo nano /etc/sysctl.conf
                  find the line:
                  vm.swappiness = 10
                  and change it to:
                  vm.swappiness = 60

                  This makes your system to start using the SWAP much earlier (when there will be near 50% of free RAM) and when the free RAM will be at near end this is not overkill your system, like it was with swappiness 10 (which is recommends for the PC’s with near 16+GB RAM, by the way). Hope this will helps to someone.

                  In you case, maybe you can leave vm.swappiness = 10 (instead default 60)
                  and set:
                  vm.vfs_cache_pressure = 50 instead 100 by default


                  vm.swappiness = 10
                  vm.vfs_cache_pressure = 50

                  #90474
                  Member
                  Mad Daimond
                    Helpful
                    Up
                    0
                    ::

                    Indeed, it is debatable and depends on many factors and not just on the ‘general principle’ of ‘The more RAM you have – the less swappiness value you can set’.

                    Do you have some arguments for using swappiness 10 on machines with 700mb or lower RAM? If yes, I’ll be very happy to read it.

                    One suggestion, if you don’t want freezes, don’t ask more of the PC than it has to give.

                    Actually, I have posted the solution to my problem in the first post. But Zram is the thing to try, thank your for that!

                    #90475
                    Forum Admin
                    anticapitalista
                      Helpful
                      Up
                      0
                      ::

                      Do you have some arguments for using swappiness 10 on machines with 700mb or lower RAM? If yes, I’ll be very happy to read it.

                      No. I asked you for evidence that swappiness of 60 is better. You haven’t provided any yet.

                      Philosophers have interpreted the world in many ways; the point is to change it.

                      antiX with runit - leaner and meaner.

                      #90476
                      Moderator
                      Brian Masinick
                        Helpful
                        Up
                        0
                        ::

                        I don’t know what some story has to say about swap.

                        On one of my 64 bit UNIX workstations some ~25 years ago I was able to run virtually everything directly from memory and I set a kernel flag to NEVER swap. While that doesn’t work for all possible workloads it certainly worked on my workstation, which ALSO had a powerful UNIX server providing disk space and the heavy hitting networking and compute power so that the workstation could edit files, access server resources and the network.

                        Worked great and I was never close to consuming all of memory or running out of resources.

                        Your use cases may be different but in my opinion swapping out processes is RARELY a good idea.

                        --
                        Brian Masinick

                        #90477
                        Moderator
                        Brian Masinick
                          Helpful
                          Up
                          0
                          ::

                          Frequently swapping creates a heavily I/O bound workload, which makes the slowest resources also be the system’s resource constraint. Personally I don’t favor that approach; to everyone I suppose you can do whatever you want; be prepared for what happens though.

                          --
                          Brian Masinick

                          #90496
                          Member
                          ModdIt
                            Helpful
                            Up
                            0
                            ::

                            Original Poster seems unable to give a reasl answer 😉
                            Anyway Reducing swappiness to 10 is not the smartest idea for good overall desktop performance.
                            Upgrading memory or installing a modern SSD or NVME is whenever possible far better.
                            Even a modern SSD with IDE adapter is faster on long writes than an anchient HDD. Means faster swapping.

                            An Excerpt: From a very sensible discussion at https://askubuntu.com/questions/184217/why-most-people-recommend-to-reduce-swappiness-to-10-20
                            Reading the whole thread is recommended.

                            Because most believe that swapping = bad and that if you don’t reduce swappiness, the system will swap when it really doesn’t need to. Neither of those are really true. People associate swapping with times where their system is getting bogged down – however, it’s mostly swapping because the system is getting bogged down, not the other way around. When the system swaps, it will have already factored the performance cost in to its decision to swap, and decided that not doing so would have a greater overall penalty in system performance or stability.

                            Overall the default settings result in good overall performance and stability. I’d recommend leaving it at the default. There are further avenues for Linux to improve its memory management to solve some edge cases, but by and large the swappiness control isn’t a good workaround – adjust it in one direction and you may fix one issue and create other issues. If at all possible, simply installing more physical RAM (and leaving swappiness alone) eclipses all other remedies.

                            How Linux uses RAM

                            Any RAM that isn’t being used by applications may be used as “cache”. Cache is important for a fast, smooth running system, speeding up both reads and writes to disk.

                            If your applications increase their memory use to the point they are using almost all your RAM, your cache will shrink and on average disk operations will slow down as a result. It’s not enough to have just tens of megabytes, or less, for cache nowadays.

                            If applications increase their memory use even further – assuming you have no swap space – you will not only have no space for cache but you will eventually run out of memory and your system will have to kill running processes. Killing processes is worse than a slow down as it gives you an unstable, unpredictable system.

                            How Linux uses swap

                            To combat both of these problems, your system can re-allocate some seldom-used application memory to the swap space on your disk, freeing RAM. The additional RAM can prevent processes dying due to running out of memory, and can reclaim a little cache so disk operations can operate more smoothly.

                            This re-allocation isn’t done according to a definite cutoff though. You don’t reach a certain percentage of allocation after which Linux starts swapping. It has a “fuzzy” algorithm. It takes a lot of things into account, which can best be described by “how much pressure is there for memory allocation”. If there is a lot of “pressure” to allocate new memory, then it will increase the chances some will be swapped to make more room. If there is less “pressure” then it will decrease these chances.

                            Your system has a “swappiness” setting which helps you tweak how this “pressure” is calculated. It’s often falsely represented as a “percentage of RAM” but it’s not, it’s just a value that is used as part of the formula. Values around 40 to 60 are the recommended sane values, 60 being default nowadays.

                            Letting your system swap when it has to is overall a very good thing, even if you have a lot of RAM. Letting your system swap if it needs to gives you peace of mind that if you ever run into a low memory situation even temporarily (while running a short process that uses a lot of memory), your system has a second chance at keeping everything running. If you go so far as to disable swapping completely, then you risk processes being killed due to not being able to allocate memory.

                            What is happening when the system is bogged down and swapping heavily?

                            Swapping is a slow and costly operation, so the system avoids it unless it calculates that the trade-off in cache performance will make up for it overall, or if it’s necessary to avoid killing processes.

                            A lot of the time people will look at their system that is thrashing the disk heavily and using a lot of swap space and blame swapping for it. That’s the wrong approach to take. If swapping ever reaches this extreme, it means that swapping is your system’s attempt to deal with low memory problems, not the cause of the problem, and that without swapping your running process will just randomly die.

                            What about desktop systems? Don’t they require a different approach?

                            Users of a desktop system do indeed expect the system to “feel responsive” in response to user-initiated actions such as opening an application, which is the type of action that can sometimes trigger a swap due to the increase in memory required.

                            One way some people try to tweak this is to reduce the swappiness parameter which can increase the system’s tolerance to applications using up memory and running low on cache space.

                            However, this is just shifting goalposts. The first application may now load without a swap operation, but it will leave less slack for the next application that loads. The same swapping may just occur later, when you next open an application instead. In the meantime, the system performance is lower overall due to the reduced cache size. Thus, any benefit from the reduced swappiness setting may be hard to measure, reducing swapping delay at some times but causing other slow performance at other times. Reducing swappiness a little may be justified if you know what you’re doing, but reducing it to as low as 10 can leave the system tolerant to very low cache sizes and leave the system more liable to have to swap at short notice.

                            Disabling swap completely should be avoided as you lose the added protection against out-of-memory conditions which can cause processes to crash or be killed.

                            The most effective remedy by far is to install more RAM if you can afford it.

                            #90664
                            Member
                            Qwerty
                              Helpful
                              Up
                              0
                              ::

                              Making a system to start swapping earlier is called “vm.watermark_scale_factor”. I feel like it’s the most relevant setting that should be changed first. It should be high for low-RAM desktop systems. Its upper bound is 1000 (= 10% of memory), which seems to be a reasonable choice for something like a 2-Gb-RAM system that’s used with heavy software like modern browsers (and by “heavy” I mean allocating and deallocating big chucks of memory often). Depending on your hardware and software, other values can make sense.
                              As for “vm.swappiness”, I set it to 100 for my frugal antiX installation. I don’t know if I need it that high now, but I left kept it from the time I was doing experiments running a live system from a USB flash drive with a swap on an HDD, in which case swapping to HDD was strictly better. It works fine. In any case, setting it to any relatively large value should be a good idea in the context of low-RAM PCs.
                              Other settings to experiment with may be “vm.dirty_background_ratio”, “vm.dirty_ratio”, “vm.vfs_cache_pressure”, but it’s unclear to me if it’s worth the effort.

                              • This reply was modified 6 months, 4 weeks ago by Qwerty.
                              #90666
                              Member
                              oops
                                Helpful
                                Up
                                0
                                ::

                                … Good idea Qwerty .

                                An other workaround is to use zswap.

                                #90675
                                Member
                                sybok
                                  Helpful
                                  Up
                                  0
                                  ::

                                  Would running applications with ‘/usr/bin/nice -n <value> <app-command with all the switches>’ help?
                                  I assume that this would shift the behavior towards freezing the applications rather than the system itself.

                                Viewing 15 posts - 1 through 15 (of 15 total)
                                • You must be logged in to reply to this topic.