zswap – compcache, compressed swap for better performance

First, here is a link to article on compcache.

http://code.google.com/p/compcache/wiki/CompilingAndUsingNew

zswap is already in the kernel and you can see the documentation in the kernel documentation. Here is the name of the file if you need:

/usr/share/doc/kernel-doc-$(uname -r)/Documentation/vm/zswap.txt

Here is the overview, in case you do not want to install kernel-doc

Overview:

Zswap is a lightweight compressed cache for swap pages. It takes pages that are
in the process of being swapped out and attempts to compress them into a
dynamically allocated RAM-based memory pool.  zswap basically trades CPU cycles
for potentially reduced swap I/O.  This trade-off can also result in a
significant performance improvement if reads from the compressed cache are
faster than reads from a swap device.

NOTE: Zswap is a new feature as of v3.11 and interacts heavily with memory
reclaim.  This interaction has not be fully explored on the large set of
potential configurations and workloads that exist.  For this reason, zswap
is a work in progress and should be considered experimental.

Some potential benefits:
* Desktop/laptop users with limited RAM capacities can mitigate the
    performance impact of swapping.
* Overcommitted guests that share a common I/O resource can
    dramatically reduce their swap I/O pressure, avoiding heavy handed I/O
    throttling by the hypervisor. This allows more work to get done with less
    impact to the guest workload and guests sharing the I/O subsystem
* Users with SSDs as swap devices can extend the life of the device by
    drastically reducing life-shortening writes.

Zswap evicts pages from compressed cache on an LRU basis to the backing swap
device when the compressed pool reaches it size limit.  This requirement had
been identified in prior community discussions.

To enabled zswap, the “enabled” attribute must be set to 1 at boot time.  e.g.
zswap.enabled=1

 

Enhanced by Zemanta

force recheck on reboot – fsck

If you want to force a fsck re-check on reboot, then just

touch /forcefsck

 

Enhanced by Zemanta

Set some disk params to be safe

It is always “Better safe than sorry” so, here are some things you
should do..

First check fstab, if you have partitions other than root then use UUID instead of device:

 UUID=a8f13a0d-3f1f-42e4-b076-f44b4163306c /mnt/Backup     ext4 defaults,relatime 1 2

Then entries for all your mounts should be like above.
Points to note here :

Disk is mounted using the UUID and not with /dev/sdXX. This ensures
that even if your disk ids change, you will be able to mount them. To
get the partition UUID, you can execute :

lsblk -f
#OR
blkid /dev/sdXX

disk mouting params include relatime ( this is really optional and
depends on your personal preference.) When this option is set, basically
the acess time for the file and directories are update only on writes.
There is also a noatime option, but that has its own demerits. By
default the option is “atime” which means for each acess (even reads)
there will be a write ( to update the atime). So, setting this should
improve performance.
Make sure that last param is 2 and not zero. This would mean that
fsck checks are done and they are done after “/” checks

Now, we do little more to make sure that we are not delayed with fsck
every time the system boots. So, lets check some params for the
patitions, using tune2fs:

tune2fs -l /dev/sdXX |egrep -i '(Check|mount count)'

You should see output like below :

Mount count:              0
Maximum mount count:      40     
Last checked:             Wed Sep  4 08:37:24 2013     
Check interval:           2592000 (1 month)     
Next check after:         Fri Oct  4 08:37:24 2013

Here, points to note::

  • maximum mount count is set. This means that after every 40 mounts, the disk will be checked.
  • Check interval is set, so it means that after 1 month disk will be checked even if it was not mounted for 40 times in this period.

Now, if you dont have those, then you can execute:

 tune2fs -c 40 /dev/sdXX             # to set maximum mount count
tune2fs -i 1m /dev/sdXX             # to set the check interval
tune2fs -c 40 -i 1m /dev/sdXX       # to set both of above.

Now, one thing to keep in mind is to make sure that if you have multiple
partitions, which will be the case, then sparse the interval durations
and do not plan on using the same duration. This will ensure that your
fsck checks at boot time do not “ALL” happen on the same day, same time.

Was a bit tad longer than usual but thats all for today.
(In case you are still worried then you can always check for bad blocks with command “badblocks” and if you too worried then you should google
for “Why Linux does not need defragmentation”)

 

 

Enhanced by Zemanta