]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/SearchIdxPart.pm
searchidxpart: increase pipe size for partitions
[public-inbox.git] / lib / PublicInbox / SearchIdxPart.pm
index d5a3fd1769d7038f10845fa116a6c8f294cfbcc3..5582d672d0de343b19dfc297446056ed8217407c 100644 (file)
@@ -20,6 +20,11 @@ sub new {
                }
                $v2writable = undef;
                close $w;
+
+               # F_SETPIPE_SZ = 1031 on Linux; increasing the pipe size here
+               # speeds V2Writable batch imports across 8 cores by nearly 20%
+               fcntl($r, 1031, 1048576) if $^O eq 'linux';
+
                eval { partition_worker_loop($self, $r) };
                die "worker $part died: $@\n" if $@;
                die "unexpected MM $self->{mm}" if $self->{mm};
@@ -63,8 +68,10 @@ sub partition_worker_loop ($$) {
 # called by V2Writable
 sub index_raw {
        my ($self, $len, $msgref, $artnum, $object_id) = @_;
-       print { $self->{w} } "$len $artnum $object_id\n", $$msgref or die
+       my $w = $self->{w};
+       print $w "$len $artnum $object_id\n", $$msgref or die
                "failed to write partition $!\n";
+       $w->flush or die "failed to flush: $!\n";
 }
 
 1;