Comment 120 for bug 1208993

Revision history for this message
Yug (hugolpz) wrote :

# Objective
Monitor dirty files memory,
Change to more suitable values.

What it does: change from default 10 and 50%.

My understanding:
If `(vm.dirty_background_ratio/100) * memory size > largest file size`, then it should be ok.[reference needed]

Note: `memory size` may be *available* memory size. Closing your memory-eating browsers may help.[reference needed]

After editing the dirty values, reboot your system. It helped me.

# Sources:
- https://lonesysadmin.net/2013/12/22/better-linux-disk-caching-performance-vm-dirty_ratio/
- http://fooo.fr/~vjeux/github/github-recommandation/db/doc/manual/html/linux-performance-guide.html

# Helpful commands
```
# View one dirty setting
sudo sysctl -n vm.dirty_ratio # default 10
sudo sysctl -n vm.dirty_background_ratio # default 50

# View/monitor several settings
cat /etc/sysctl.conf | egrep "dirty|writeback" # config file's dirty, if loaded.
cat /proc/vmstat | egrep "dirty|writeback" # print dirty
cat /proc/vmstat | egrep "nr_" # print all nr

# View/monitor several settings : dynamic
watch grep -A 1 dirty /proc/vmstat

# Soft edit dirty ratios
sudo sysctl vm.dirty_background_ratio=50 # set variable's value
sudo sysctl vm.dirty_ratio=80 # set variable's value

# Hard edit config file
sudoedit /etc/sysctl.conf # hard edit config file.
#vm.dirty_background_ratio = 50 # add without the hashtag
#vm.dirty_ratio = 80 # add without the hashtag
# # Save with nano : CTRL+X, then y
sudo sysctl -p # reload current config file. Resets soft variables.

# Check changes
cat /etc/sysctl.conf | egrep "dirty|writeback" #
cat /proc/vmstat | egrep "dirty|writeback" #
```

# Proposed diagnosize for your steps
Before and after changing dirty values.

```
# 1. System is waiting
cat /proc/vmstat | egrep "dirty|writeback"

# 2. Just started copy
cat /proc/vmstat | egrep "dirty|writeback"

# 3. Copy is staled
cat /proc/vmstat | egrep "dirty|writeback"

# 4. Just cancelled copy via mouse
cat /proc/vmstat | egrep "dirty|writeback"

# 5. Waiting = nr_dirt goes down
cat /proc/vmstat | egrep "dirty|writeback"

# 6. Back to normal.
cat /etc/sysctl.conf | egrep "dirty|writeback"
```