diff options
Diffstat (limited to 'lib/PublicInbox/SearchIdxShard.pm')
-rw-r--r-- | lib/PublicInbox/SearchIdxShard.pm | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/lib/PublicInbox/SearchIdxShard.pm b/lib/PublicInbox/SearchIdxShard.pm index 000abd94..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}; } |