Echilibrul dintre ram si swap: Swappiness

Pe langa faptul ca realizeaza o punte intre utilizator si componentele hardware, kernelul linux ne ofera de asemenea si o cale de a ajusta echilibrul dintre ram si swap, astfel incat sa maximizam performantele calculatorului avut in dotare. Componenta care realizeaza acest echilibru poarta numele de Swappiness. Totusi inainte de a intelege ce face componenta trebuie sa stim cateva delatii despre RAM si swap. Astfel, pe scurt memoria RAM: Random-access memory (RAM) is a form of computer data storage. Today, it takes the form of integrated circuits that allow stored data to be accessed in any order with a worst case performance of constant time. Despre SWAP se stiu urmatoarele: In computer operating systems, paging is one of the memory-management schemes by which a computer can store and retrieve data from secondary storage for use in main memory.

Ca si utilizator de distributii linux, am putut observa cat de important este SWAP-ul atunci cand se mai intampla sa raman fara memorie RAM libera, astfel ca va recomand sa aveti o partitie de SWAP existenta pe hard disk chiar daca exista sanse sa nu o folositi prea mult. Unele distributii linux creaza automat partitia de SWAP in functie de cata memorie RAM are calculatorul pe cand altele nu. Daca nu stiti cat de mare sa creati partitia SWAP aflati ca in mod normal este dublul memoriei RAM avute pana la un anumit nivel. De exemplu: pentru un PC cu 1Gb sau 2Gb de RAM, SWAP-ul poate avea dimensiunea maxima de 2Gb; daca vorbim de PC-uri mai slabe care au intre 256 si 512 Mb de RAM atunci partitia SWAP trebuie sa aibe 1Gb. Privind catre partea opusa PC-urile mai noi, in functie si de pret, au de la 2Gb de RAM in sus asa ca marimea partitiei SWAP nu are de ce sa depaseasca 2Gb. Daca articolul meu nu va plictisit pana acum o sa incepeti sa realizati ca Swappiness, este mai util PC-urilor cu RAM mai putin dar poate fi folosit si de cei cu RAM mai mult care pur si simplu doresc ca memoria RAM sa fie mai libera.

Swappiness is a property for the Linux kernel that changes the balance between swapping out runtime memory, as opposed to dropping pages from the system page cache. Swappiness can be set to values between 0 and 100 inclusive. A low value means the kernel will try to avoid swapping as much as possible where a higher value instead will make the kernel aggressively try to use swap space. The default value is 60, and for most desktop systems, setting it to 100 may help to improve overall performance, whereas setting it lower (even 0) may improve interactivity (decreasing response latency. Pentru a putea folosi Swappiness in timp ce sunteti logat, fara a salva permanent setarea, comanda echo valoarea-dorita-in-cifre > /proc/sys/vm/swappiness, va poate fi utila. Pentru a salva permanent setarea pentru aceasta componenta, este necesar sa editati fisierul /etc/sysctl.conf, in care adaugati urmatoarea linie: vm.swappiness=valoarea-dorita-in-cifre.

Leave a Reply

Your email address will not be published. Required fields are marked *