]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
ipc: add comment on pipe usage (vs socketpair)
authorEric Wong <e@80x24.org>
Thu, 4 Sep 2025 19:22:26 +0000 (19:22 +0000)
committerEric Wong <e@80x24.org>
Sat, 6 Sep 2025 18:36:02 +0000 (18:36 +0000)
Using pipes here isn't ideal for developer ergonomics, but the
increased buffer size for non-privileged processes on Linux is
still worth the extra performance with expensive indexing done
in each shard.

lib/PublicInbox/IPC.pm

index b744b1aaab2740ec2c8ae1f6f7c1e20a72ece0b5..5e6ff0ecbcfd27b9d5d50594912e5929755816a7 100644 (file)
@@ -102,6 +102,11 @@ sub ipc_worker_spawn {
        my ($self, $ident, $oldset, $fields, @cb_args) = @_;
        return if $self->{-ipc_res} && $self->{-ipc_res}->can_reap; # idempotent
        delete(@$self{qw(-ipc_req -ipc_res)});
+
+       # n.b. we use 2 pipes here instead of a single socketpair since
+       # Linux (as of v6.15) allows a 1MB pipe buffer but only 0.5MB
+       # socket buffer for unprivileged processes.  The extra buffer
+       # space improves parallel indexing performance by 5-10%
        pipe(my $r_req, my $w_req);
        pipe(my $r_res, my $w_res);
        my $sigset = $oldset // PublicInbox::DS::block_signals();