Solved Is it possible to disable and re-enable ZFS compression?

When I upgrade ports (not packages) I saw that CPU is working a lot, expecially when decompressing dist files. Some threads here talk about disabling compression but I'm not a ZFS expert at all, I do not really know how ZFS works.

My intention is to make things works that way:
  • disable ZFS compression
  • install one or more ports / upgrade some or all ports
  • remove all /usr/ports/*/*/work directories and content (eventually)
  • re-enable ZFS compression
I actually have two FreeBSD installation: one server (bare metal) and one workstation (VirtualBox guest). The server does not need to disable compression (it has enough resources), while the workstation does, the virtual disk is on an 10 year old SATA 300GB HD, very slow respect to brand new SSD. They are installed in the same way (automatic full disk ZFS as in bsdinstall), so I will show only the VM disk layout:
Code:
root at elopao-vm
~> gpart show
=>       40  167772080  ada0  GPT  (80G)
         40     532480     1  efi  (260M)
     532520       1024     2  freebsd-boot  (512K)
     533544        984        - free -  (492K)
     534528    8388608     3  freebsd-swap  (4.0G)
    8923136  158846976     4  freebsd-zfs  (76G)
  167770112       2008        - free -  (1.0M)

root at elopao-vm
~> df -achT
Filesystem          Type       Size    Used   Avail Capacity  Mounted on
zroot/ROOT/default  zfs         32G     18G     14G    56%    /
devfs               devfs      1.0K      0B    1.0K     0%    /dev
/dev/gpt/efiboot0   msdosfs    260M    1.3M    259M     1%    /boot/efi
procfs              procfs     8.0K      0B    8.0K     0%    /proc
zroot/tmp           zfs         14G    2.5M     14G     0%    /tmp
zroot               zfs         14G     96K     14G     0%    /zroot
zroot/home          zfs         14G     96K     14G     0%    /home
zroot/usr/ports     zfs         41G     27G     14G    66%    /usr/ports
zroot/var/log       zfs         14G    4.3M     14G     0%    /var/log
zroot/usr/src       zfs         15G    853M     14G     6%    /usr/src
zroot/var/audit     zfs         14G     96K     14G     0%    /var/audit
zroot/var/crash     zfs         14G     96K     14G     0%    /var/crash
zroot/var/mail      zfs         14G    136K     14G     0%    /var/mail
zroot/var/tmp       zfs         14G     96K     14G     0%    /var/tmp
zroot/home/paolo    zfs         15G    1.2G     14G     8%    /home/paolo
fdescfs             fdescfs    1.0K      0B    1.0K     0%    /var/run/samba4/fd
total                          214G     47G    168G    22%

There is a zroot/usr/ports, can I temporarily disable that only or I have to disable all the zroot and what commands are appropriate? Thaks for your intrest.
 
Yes, you can enable and disable compression on specific datasets. But it will not compress or decompress existing files. It will only happen on new writes.

And the default lz4 compression is actually fairly smart, it won't compress files that aren't going to benefit from it (because the files themselves are already compressed for example).
 
Ok, so if I understood which command to run:
  • zfs set compression=off zpool/usr/ports
  • do everything to do in /usr/ports
  • zfs set compression=on zpool/usr/ports
right?
 
Only files that you newly write to the zpool will obey the compression setting.

Since you have a slow disk it is likely that you actually get a speed benefit out of compression - except for distfiles, which are already compressed. To optimize you might want to create a separate dataset with compression off for usr/ports/distfiles and compression on for the rest of /usr/ports.

Be sure to use a lightweight compression algorithm.
 
Another option is to set WRKDIRPREFIX to a tmpfs(5) filesystem. But, depending on the port, this could use a humongous amount of memory.

Code:
     WRKDIRPREFIX  Where to create any temporary files.  Useful if PORTSDIR is
                   read-only (perhaps mounted from a CD-ROM).
ports(7)
 
Well, I can disable and re-enable that location only while compile ports, I also think do always delete distfile, I do not re-install ports, when ports are out-of-date the distfiles will be downloaded. However, only disabling compression on /zpool/usr/ports while ports are compiled and re-enabling when finished I guess it is enough, only distfile and compiled packages are not compressed but this is not much space, the ports tree per se occupy a lot of disk but can be compressed when I run git.

But the commands I wrote in #3 (zfs compression=off/on zpool/usr/ports) are correct?
 
Another option is to set WRKDIRPREFIX to a tmpfs(4) filesystem. But, depending on the port, this could use a humongous amount of memory.

Code:
     WRKDIRPREFIX  Where to create any temporary files.  Useful if PORTSDIR is
                   read-only (perhaps mounted from a CD-ROM).
ports(7)
Yes, I know and tought that but it's better to leave the default, it's not a problem
 
Well, I can disable and re-enable that location only while compile ports, I also think do always delete distfile, I do not re-install ports, when ports are out-of-date the distfiles will be downloaded.

A lot of updates are done because of updated dependencies, changes to makefiles and new patches in the port's files directory. Distfiles do tend to get reused quite a lot if you keep them.
 
A lot of updates are done because of updated dependencies, changes to makefiles and new patches in the port's files directory. Distfiles do tend to get reused quite a lot if you keep them.
yes, I re-thought about what I written. HD is 80GB, it is not necessary to wipe out all distfiles, I keep them.
 
Back
Top