bees Configuration

The only configuration parameter that must be provided is the hash table size. Other parameters are optional or hardcoded, and the defaults are reasonable in most cases.

Hash Table Sizing

Hash table entries are 16 bytes per data block. The hash table stores the most recently read unique hashes. Once the hash table is full, each new entry in the table evicts an old entry.

Here are some numbers to estimate appropriate hash table sizes:

unique data size |  hash table size |average dedupe extent size
    1TB          |      4GB         |        4K
    1TB          |      1GB         |       16K
    1TB          |    256MB         |       64K
    1TB          |    128MB         |      128K <- recommended
    1TB          |     16MB         |     1024K
   64TB          |      1GB         |     1024K

Notes:

Factors affecting optimal hash table size

It is difficult to predict the net effect of data layout and access patterns on dedupe effectiveness without performing deep inspection of both the filesystem data and its structure--a task that is as expensive as performing the deduplication.

Scanning modes for multiple subvols

The --scan-mode option affects how bees divides resources between subvolumes. This is particularly relevant when there are snapshots, as there are tradeoffs to be made depending on how snapshots are used on the filesystem.

Note that if a filesystem has only one subvolume (i.e. the root, subvol ID 5) then the --scan-mode option has no effect, as there is only one subvolume to scan.

The default mode is mode 0, "lockstep". In this mode, each inode of each subvol is scanned at the same time, before moving to the next inode in each subvol. This maximizes the likelihood that all of the references to a snapshot of a file are scanned at the same time, which takes advantage of VFS caching in the Linux kernel. If snapshots are created very often, bees will not make very good progress as it constantly restarts the filesystem scan from the beginning each time a new snapshot is created.

Scan mode 1, "independent", simply scans every subvol independently in parallel. Each subvol's scanner shares time equally with all other subvol scanners. Whenever a new subvol appears, a new scanner is created and the new subvol scanner doesn't affect the behavior of any existing subvol scanner.

Scan mode 2, "sequential", processes each subvol completely before proceeding to the next subvol. This is a good mode when using bees for the first time on a filesystem that already has many existing snapshots and a high rate of new snapshot creation. Short-lived snapshots (e.g. those used for btrfs send) are effectively ignored, and bees directs its efforts toward older subvols that are more likely to be origin subvols for snapshots. By deduping origin subvols first, bees ensures that future snapshots will already be deduplicated and do not need to be deduplicated again.

If you are using bees for the first time on a filesystem with many existing snapshots, you should read about snapshot gotchas.

Threads and load management

By default, bees creates one worker thread for each CPU detected. These threads then perform scanning and dedupe operations. The number of worker threads can be set with the --thread-count and --thread-factor options.

If desired, bees can automatically increase or decrease the number of worker threads in response to system load. This reduces impact on the rest of the system by pausing bees when other CPU and IO intensive loads are active on the system, and resumes bees when the other loads are inactive. This is configured with the --loadavg-target and --thread-min options.

Log verbosity

bees can be made less chatty with the --verbose option.