All Projects → wiedemannc → deswappify-auto

wiedemannc / deswappify-auto

Licence: GPL-3.0 license
automatically swap-in pages when enough memory is available

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to deswappify-auto

Daemonize
daemonize is a library for writing system daemons in Python.
Stars: ✭ 396 (+1220%)
Mutual labels:  system, daemon
Heim
Cross-platform async library for system information fetching 🦀
Stars: ✭ 572 (+1806.67%)
Mutual labels:  system, swap
Daemonize
Library for writing system daemons
Stars: ✭ 210 (+600%)
Mutual labels:  system, daemon
ansible-role-dns
Install and configure dns on your system.
Stars: ✭ 39 (+30%)
Mutual labels:  system
sway-alttab
Simple Alt-Tab daemon for SwayWM/i3. Switches back to previous focused window on Alt-Tab or SIGUSR1
Stars: ✭ 36 (+20%)
Mutual labels:  daemon
awesome-cs
计算机优质书籍搜罗+学习路线推荐!
Stars: ✭ 1,925 (+6316.67%)
Mutual labels:  system
Kolbot-SoloPlay
<The one bot to rule them all> This repo is depreciated. New development is at https://github.com/blizzhackers/kolbot-SoloPlay
Stars: ✭ 26 (-13.33%)
Mutual labels:  system
sasutils
Serial Attached SCSI (SAS) Linux utilities and Python library
Stars: ✭ 36 (+20%)
Mutual labels:  system
touchtest
MacOS Touch Bar Control Strip daemon
Stars: ✭ 22 (-26.67%)
Mutual labels:  daemon
rubysu
Give Ruby objects superuser privileges
Stars: ✭ 15 (-50%)
Mutual labels:  system
installer
remote.it command line installer tool
Stars: ✭ 21 (-30%)
Mutual labels:  daemon
KubeArmor
Cloud-native Runtime Security Enforcement System
Stars: ✭ 434 (+1346.67%)
Mutual labels:  system
ProxySwitcher
Easily enable / disable WiFi proxy on a jailbroken iOS device
Stars: ✭ 55 (+83.33%)
Mutual labels:  daemon
zram-swap-manager
A versatile zRAM swap manager with dynamic swappiness - for Android and GNU/Linux systems.
Stars: ✭ 43 (+43.33%)
Mutual labels:  swap
ggr-ui
The missing /status API for Ggr
Stars: ✭ 37 (+23.33%)
Mutual labels:  daemon
WSD-python
Web Services for Devices (WSD) tools and utilities for cross platform support
Stars: ✭ 22 (-26.67%)
Mutual labels:  daemon
disfetch
Yet another *nix distro fetching program, but less complex.
Stars: ✭ 45 (+50%)
Mutual labels:  system
oskrhq-design-system
A mostly reasonable although opinionated approach to building responsive Digital Interfaces sharing the same anatomy.
Stars: ✭ 60 (+100%)
Mutual labels:  system
icmpmon
A simple ICMP monitor with web interface.
Stars: ✭ 33 (+10%)
Mutual labels:  daemon
daemonize
Template code for writing UNIX-daemons.
Stars: ✭ 33 (+10%)
Mutual labels:  daemon

deswappify-auto

Automatically fetch swapped pages to physical memory when enough memory is available.

The code is inspired by https://gist.github.com/WGH-/91260f6d65db88be2c847053c49be5ae and the discussion on https://unix.stackexchange.com/questions/45673/how-can-swapoff-be-that-slow.

It is ment to be used as a daemon on linux. It continuously scans the memory and load situation and performs a deswap operation when there the situation allows (enough available memory and not too many active processes). This might be seen as a workaround for high swap usages after resume from hibernation, even if there is enough physical memory available.

Dependencies

The script has been developed in python 3.5 (it might run also with python 2.7).

Recommended python packages are systemd (for logging) and psutil (for setting an appropriate ionice level). If these packages are not installed, the functionality is slightly limited.

The script expects the linux commands free, swapoff and swapon to be in PATH, the latter two are optional and only used if -e option is set.

Obviously, the script has to be run with root privileges.

Help

Help is available via deswappify_auto.py -h:

usage: deswappify_auto [-h] [--version] [-v {error,warning,info,dump}]
                       [-m MEM_THRESHOLD] [-s MAX_ACCEPTED_SWAP_SIZE]
                       [-p POLL_PROC_SWAP_INTERVAL]
                       [-P POLL_PROC_ACTIVE_INTERVAL] [-b IDLE_AFTER_BUSY]
                       [-c IDLE_AFTER_COMPLETED] [-a MAX_ACTIVE_PROCESSES]
                       [-n] [-l] [-e] [-j NUM_PARALLEL] [-t SPAWN_TIMEOUT]
                       [-d] [--pc_during_deswap PC_DURING_DESWAP]
                       [--pc_during_idle PC_DURING_IDLE]
                       [pids [pids ...]]

positional arguments:
  pids                  If pids are specified, the program is run in one-shot
                        mode. Otherwise it's run as a daemon. (default: [])

optional arguments:
  -h, --help            show this help message and exit
  --version             show program's version number and exit
  -v {error,warning,info,dump}, --verbose {error,warning,info,dump}
                        set verbosity (default: warning)
  -m MEM_THRESHOLD, --mem_threshold MEM_THRESHOLD
                        set minimal amount of extra memory which should be
                        available after deswapping. Sizes can be suffixed with
                        k,M,G and T for bytes and with % for percentage of
                        physical memory. (default: 25%)
  -s MAX_ACCEPTED_SWAP_SIZE, --max_accepted_swap_size MAX_ACCEPTED_SWAP_SIZE
                        set maximum amount of swap size which is acceptable
                        before leaving idle state. Sizes can be suffixed with
                        k,M,G and T for bytes and with % for percentage of
                        physical memory. (default: 100M)
  -p POLL_PROC_SWAP_INTERVAL, --poll_proc_swap_interval POLL_PROC_SWAP_INTERVAL
                        minimum number of seconds between two polls of the
                        /proc directory for swap information. (default: 60)
  -P POLL_PROC_ACTIVE_INTERVAL, --poll_proc_active_interval POLL_PROC_ACTIVE_INTERVAL
                        minimum number of seconds between two polls of the
                        /proc directory for active process information.
                        (default: 3)
  -b IDLE_AFTER_BUSY, --idle_after_busy IDLE_AFTER_BUSY
                        number of seconds to sleep after system busy
                        detection. (default: 5)
  -c IDLE_AFTER_COMPLETED, --idle_after_completed IDLE_AFTER_COMPLETED
                        number of seconds to sleep after successful
                        deswappify. (default: 60)
  -a MAX_ACTIVE_PROCESSES, --max_active_processes MAX_ACTIVE_PROCESSES
                        maximum number of active processes for system idle
                        detection. (default: 4)
  -n, --avoid_renicing  avoid renicing this process. (default: False)
  -l, --systemd_logger  use systemd logger instead of python stream logger.
                        (default: False)
  -e, --swapoffon       if given, a swapoff -a followed by a swapon -a will be
                        issued after successfully completing a deswapping.
                        (default: False)
  -j NUM_PARALLEL, --num_parallel NUM_PARALLEL
                        Number of parallel readers. In theory, more readers
                        should be more efficient on HDD's because the parallel
                        accesses can be sorted. (default: 1)
  -t SPAWN_TIMEOUT, --spawn_timeout SPAWN_TIMEOUT
                        Timeout for spawned processes. Only available in
                        python3. (default: 0)
  -d, --develop         use in development mode, after a possible bug is
                        detected, the application exits. (default: False)
  --pc_during_deswap PC_DURING_DESWAP
                        Optimize swap read-ahead in /proc/sys/vm/page-cluster
                        during deswap operation. This is the value to be used
                        during deswappifying. The actual number of bytes can
                        be calculated by pagesize*2^value. For page sizes of 4
                        kB, the default value of 16 is 256 MB. Use negative
                        sizes to not modify the value stored in
                        /proc/sys/vm/page-cluster. (default: 16)
  --pc_during_idle PC_DURING_IDLE
                        Optimize swap read-ahead in /proc/sys/vm/page-cluster
                        during deswap operation. This is the value to be used
                        during idle operation. Use negative arguments to
                        return to the original value stored in
                        /proc/sys/vm/page-cluster. (default: -1)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].