5

BTRFS (or ZFS, which I have no experience of) has checksum functionality "built-in", which seems like a very good feature. My Synology NAS gives me the option of enabling it for any given folder, so it begs the question of: should I enable it for data that I don't really care that much about?

Which leads to the actual question: What is the cost of enabling BTRFS checksum's? Does it take up more space? If so how much? Does it take up more CPU time for reading or writing?

1 Answers1

3

Short version: leave checksum enabled, disabling it will not give you any real advantage.

Long version: Checksum calculation on modern CPU is very fast, and easily in the "absolutely don't worry" territory. For comparison, my ancient Ryzen 7 1700X does ZFS fletcher4 computation at >9GB/s. CRC32C on recent processors should be even faster, due to dedicated instructions.

The real cost of checksummed filesystem or block devices (ie: dm-integrity) is not in the checksum calculation itself, rather in the CoW or read/modify/write machinery and layout needed to correlate data with checksum. Disabling checksum will not change that, and will only provide an extremely small speedup (if any).

shodanshok
  • 47,711
  • 7
  • 111
  • 180
  • thanks, it was the no checksum but still CoW = no difference I was struggling to find the answer to. Re the CPU load though, my old Syno NAS has a dual Atom from 2013 which I think does not have a CRC32 instruction (that NAS line was not rolled out with btrfs support either, it was added later). And before I was even half through that sentence I realized I should probably run a quick performance test haha – Johan Sonesson Jul 22 '23 at 22:08
  • Bulk checksum bandwidth is arguably not as useful in this case as extra time spent per block, because the blocks being checksummed are small enough that the setup is a nontrivial percentage of the time spent. From my own testing though, CRC32c on most modern x86 chips that have native instructions for it works out to needing roughly 1500-2000 cycles for a 4 kiB block (the default block size for BTRFS on x86), so having checksums on translates to a few microseconds of additional time spent on each read or write (which is probably not enough to matter for most users). – Austin Hemmelgarn Jul 23 '23 at 02:13