]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei_mail_sync: set nodatacow on btrfs
authorEric Wong <e@80x24.org>
Sat, 18 Sep 2021 09:33:26 +0000 (09:33 +0000)
committerEric Wong <e@80x24.org>
Sat, 18 Sep 2021 20:25:27 +0000 (20:25 +0000)
As with other SQLite3 databases, copy-on-write with
files experiencing random writes leads to write amplification
and low performance.

lib/PublicInbox/LeiMailSync.pm

index 690c6477efa9c3be76242392d39fcdad90d1378e..f185b585f5e240b02cda3e01f69340741220f50b 100644 (file)
@@ -14,6 +14,11 @@ sub dbh_new {
        my ($self, $rw) = @_;
        my $f = $self->{filename};
        my $creat = $rw && !-s $f;
+       if ($creat) {
+               require PublicInbox::Spawn;
+               open my $fh, '+>>', $f or Carp::croak "open($f): $!";
+               PublicInbox::Spawn::nodatacow_fd(fileno($fh));
+       }
        my $dbh = DBI->connect("dbi:SQLite:dbname=$f",'','', {
                AutoCommit => 1,
                RaiseError => 1,