about summary refs log tree commit homepage
path: root/lib/PublicInbox/LeiStore.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-09-19 12:50:22 +0000
committerEric Wong <e@80x24.org>2021-09-19 19:52:45 +0000
commitcbc2890cb89b81cb6b9e8fabf3f196d9a6110dce (patch)
tree5e8fc56e04b6b52d28c5853aca1bb5f9b98f36b7 /lib/PublicInbox/LeiStore.pm
parent12775b5be53db1244b9cb32ae2ef90f105735e1b (diff)
downloadpublic-inbox-cbc2890cb89b81cb6b9e8fabf3f196d9a6110dce.tar.gz
This has several advantages:

* no need to use ipc.lock to protect a pipe for non-atomic writes

* ability to pass FDs.  In another commit, this will let us
  simplify lei->sto_done_request and pass newly-created
  sockets to lei/store directly.

disadvantages:

- an extra pipe is required for rare messages over several
  hundred KB, this is probably a non-issue, though

The performance delta is unknown, but I expect shards
(which remain pipes) to be the primary bottleneck IPC-wise
for lei/store.
Diffstat (limited to 'lib/PublicInbox/LeiStore.pm')
-rw-r--r--lib/PublicInbox/LeiStore.pm10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/PublicInbox/LeiStore.pm b/lib/PublicInbox/LeiStore.pm
index 08add8f5..4ec63699 100644
--- a/lib/PublicInbox/LeiStore.pm
+++ b/lib/PublicInbox/LeiStore.pm
@@ -552,6 +552,12 @@ sub ipc_atfork_child {
         $self->SUPER::ipc_atfork_child;
 }
 
+sub recv_and_run {
+        my ($self, @args) = @_;
+        local $PublicInbox::DS::in_loop = 0; # waitpid synchronously
+        $self->SUPER::recv_and_run(@args);
+}
+
 sub write_prepare {
         my ($self, $lei) = @_;
         $lei // die 'BUG: $lei not passed';
@@ -560,14 +566,14 @@ sub write_prepare {
                 require PublicInbox::PktOp;
                 my ($s2d_op_c, $s2d_op_p) = PublicInbox::PktOp->pair;
                 my $dir = $lei->store_path;
-                $self->ipc_lock_init("$dir/ipc.lock");
                 substr($dir, -length('/lei/store'), 10, '');
                 pipe(my ($r, $w)) or die "pipe: $!";
                 $w->autoflush(1);
                 # Mail we import into lei are private, so headers filtered out
                 # by -mda for public mail are not appropriate
                 local @PublicInbox::MDA::BAD_HEADERS = ();
-                $self->ipc_worker_spawn("lei/store $dir", $lei->oldset, {
+                $self->{-wq_no_bcast} = 1;
+                $self->wq_workers_start("lei/store $dir", 1, $lei->oldset, {
                                         lei => $lei,
                                         -err_wr => $w,
                                         to_close => [ $r, $s2d_op_c->{sock} ],