From a2d1619fcfe2bda6dd1c4d69ecf77516c23c3ffd Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 4 Sep 2025 19:22:26 +0000 Subject: [PATCH] ipc: add comment on pipe usage (vs socketpair) 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 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/PublicInbox/IPC.pm b/lib/PublicInbox/IPC.pm index b744b1aaa..5e6ff0ecb 100644 --- a/lib/PublicInbox/IPC.pm +++ b/lib/PublicInbox/IPC.pm @@ -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(); -- 2.47.3