diff options
author | Eric Wong <e@yhbt.net> | 2020-07-28 22:21:58 +0000 |
---|---|---|
committer | Eric Wong <e@yhbt.net> | 2020-07-29 11:32:57 +0000 |
commit | c106504309621b662ce6c7cd914718f7045edca4 (patch) | |
tree | c569ad56cfd8e192c9f087faf9a5e13482dcd27f /t | |
parent | a3391407c960e4bbd825a34b87d053de6ef3767a (diff) | |
download | public-inbox-c106504309621b662ce6c7cd914718f7045edca4.tar.gz |
SQLite and Xapian files are written randomly, thus they become fragmented under btrfs with copy-on-write. This leads to noticeable performance problems (and probably ENOSPC) as these files get big. lore/git (v2, <1GB) indexes around 20% faster with this on an ancient SSD. lore/lkml seems to be taking forever and I'll probably cancel it to save wear on my SSD. Unfortunately, disabling CoW also means disabling checksumming (and compression), so we'll be careful to only set the No_COW attribute on regeneratable data. We want to keep CoW (and checksums+compression) on git storage because current ref storage is neither checksummed nor compressed, and git streams pack output.
Diffstat (limited to 't')
-rw-r--r-- | t/nodatacow.t | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/t/nodatacow.t b/t/nodatacow.t new file mode 100644 index 00000000..87b6bdf7 --- /dev/null +++ b/t/nodatacow.t @@ -0,0 +1,34 @@ +#!perl -w +# Copyright (C) 2020 all contributors <meta@public-inbox.org> +# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt> +use strict; +use Test::More; +use File::Temp qw(tempfile); +use PublicInbox::TestCommon; +use PublicInbox::Spawn qw(which); +use_ok 'PublicInbox::NDC_PP'; + +SKIP: { + my $nr = 2; + skip 'test is Linux-only', $nr if $^O ne 'linux'; + my $dir = $ENV{BTRFS_TESTDIR}; + skip 'BTRFS_TESTDIR not defined', $nr unless defined $dir; + skip 'chattr(1) not installed', $nr unless which('chattr'); + my $lsattr = which('lsattr') or skip 'lsattr(1) not installed', $nr; + my ($fh, $name) = tempfile(DIR => $dir, UNLINK => 1); + BAIL_OUT "tempfile: $!" unless $fh && defined($name); + my $pp_sub = \&PublicInbox::NDC_PP::set_nodatacow; + $pp_sub->(fileno($fh)); + my $res = xqx([$lsattr, $name]); + like($res, qr/C/, "`C' attribute set with pure Perl"); + + my $ic_sub = \&PublicInbox::Spawn::set_nodatacow; + $pp_sub == $ic_sub and + skip 'Inline::C or Linux kernel headers missing', 1; + ($fh, $name) = tempfile(DIR => $dir, UNLINK => 1); + $ic_sub->(fileno($fh)); + $res = xqx([$lsattr, $name]); + like($res, qr/C/, "`C' attribute set with Inline::C"); +}; + +done_testing; |