about summary refs log tree commit homepage
path: root/lib/PublicInbox/SearchIdxShard.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/PublicInbox/SearchIdxShard.pm')
-rw-r--r--lib/PublicInbox/SearchIdxShard.pm43
1 files changed, 15 insertions, 28 deletions
diff --git a/lib/PublicInbox/SearchIdxShard.pm b/lib/PublicInbox/SearchIdxShard.pm
index 8635f585..ea261bda 100644
--- a/lib/PublicInbox/SearchIdxShard.pm
+++ b/lib/PublicInbox/SearchIdxShard.pm
@@ -1,13 +1,13 @@
-# Copyright (C) 2018-2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 
 # Internal interface for a single Xapian shard in V2 inboxes.
 # See L<public-inbox-v2-format(5)> for more info on how we shard Xapian
 package PublicInbox::SearchIdxShard;
-use strict;
-use v5.10.1;
+use v5.12;
 use parent qw(PublicInbox::SearchIdx PublicInbox::IPC);
 use PublicInbox::OnDestroy;
+use PublicInbox::Syscall qw($F_SETPIPE_SZ);
 
 sub new {
         my ($class, $v2w, $shard) = @_; # v2w may be ExtSearchIdx
@@ -21,24 +21,21 @@ sub new {
         if ($v2w->{parallel}) {
                 local $self->{-v2w_afc} = $v2w;
                 $self->ipc_worker_spawn("shard[$shard]");
-                # F_SETPIPE_SZ = 1031 on Linux; increasing the pipe size for
-                # inputs speeds V2Writable batch imports across 8 cores by
-                # nearly 20%.  Since any of our responses are small, make
-                # the response pipe as small as possible
-                if ($^O eq 'linux') {
-                        fcntl($self->{-ipc_req}, 1031, 1048576);
-                        fcntl($self->{-ipc_res}, 1031, 4096);
+                # Increasing the pipe size for requests speeds V2 batch imports
+                # across 8 cores by nearly 20%.  Since many of our responses
+                # are small, make the response pipe as small as possible
+                if ($F_SETPIPE_SZ) {
+                        fcntl($self->{-ipc_req}, $F_SETPIPE_SZ, 1048576);
+                        fcntl($self->{-ipc_res}, $F_SETPIPE_SZ, 4096);
                 }
         }
         $self;
 }
 
-sub _worker_done {
+sub _worker_done { # OnDestroy cb
         my ($self) = @_;
-        if ($self->need_xapian) {
-                die "$$ $0 xdb not released\n" if $self->{xdb};
-        }
-        die "$$ $0 still in transaction\n" if $self->{txn};
+        die "BUG: $$ $0 xdb active" if $self->need_xapian && $self->{xdb};
+        die "BUG: $$ $0 txn active" if $self->{txn};
 }
 
 sub ipc_atfork_child { # called automatically before ipc_worker_loop
@@ -47,8 +44,8 @@ sub ipc_atfork_child { # called automatically before ipc_worker_loop
         $v2w->atfork_child; # calls ipc_sibling_atfork_child on our siblings
         $v2w->{current_info} = "[$self->{shard}]"; # for $SIG{__WARN__}
         $self->begin_txn_lazy;
-        # caller must capture this:
-        PublicInbox::OnDestroy->new($$, \&_worker_done, $self);
+        # caller (ipc_worker_spawn) must capture this:
+        on_destroy \&_worker_done, $self;
 }
 
 sub index_eml {
@@ -65,7 +62,7 @@ sub echo {
 
 sub idx_close {
         my ($self) = @_;
-        die "transaction in progress $self\n" if $self->{txn};
+        die "BUG: $$ $0 txn active" if $self->{txn};
         $self->idx_release if $self->{xdb};
 }
 
@@ -75,14 +72,4 @@ sub shard_close {
         $self->ipc_worker_stop;
 }
 
-sub shard_over_check {
-        my ($self, $over) = @_;
-        if ($self->{-ipc_req} && $over->{dbh}) {
-                # can't send DB handles over IPC, and use read-only to avoid
-                # create_tables lock conflict:
-                $over = PublicInbox::Over->new($over->{dbh}->sqlite_db_filename)
-        }
-        $self->ipc_do('over_check', $over);
-}
-
 1;