diff options
author | Eric Wong <e@80x24.org> | 2021-01-03 20:58:29 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-01-04 04:02:54 +0000 |
commit | 7c73a09c6df674e389fb20fb57f63c6bb9695d31 (patch) | |
tree | ea0fa44e55b063b58aa98bccac9bca6662d7e80e /lib | |
parent | ddb34f3e901c2e93e9b02dbac31961225b33379f (diff) | |
download | public-inbox-7c73a09c6df674e389fb20fb57f63c6bb9695d31.tar.gz |
While our recv_3fds() implementation is more efficient syscall-wise, loading Inline takes nearly 50ms on my machine even after Inline::C memoizes the build. The current ~20ms in the fast path is barely acceptable to me, and 50ms would be unusable. Eventually, script/lei may invoke tcc(1) or cc(1) directly in the fast path, but it needs @INC for the slow path, at least. We'll encode the number of FDs into the socket name allow parallel installations, for now.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/PublicInbox/LEI.pm | 12 | ||||
-rw-r--r-- | lib/PublicInbox/Spawn.pm | 11 |
2 files changed, 9 insertions, 14 deletions
diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index 6f21da35..f41f63ed 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -660,7 +660,7 @@ sub noop {} # lei(1) calls this when it can't connect sub lazy_start { - my ($path, $errno) = @_; + my ($path, $errno, $nfd) = @_; if ($errno == ECONNREFUSED) { unlink($path) or die "unlink($path): $!"; } elsif ($errno != ENOENT) { @@ -675,8 +675,14 @@ sub lazy_start { my $dev_ino_expect = pack('dd', $st[0], $st[1]); # dev+ino pipe(my ($eof_r, $eof_w)) or die "pipe: $!"; my $oldset = PublicInbox::Sigfd::block_signals(); - $recv_3fds = PublicInbox::Spawn->can('recv_3fds') or die - "Inline::C not installed/configured or IO::FDPass missing\n"; + if ($nfd == 1) { + require IO::FDPass; + $recv_3fds = sub { map { IO::FDPass::recv($_[0]) } (0..2) }; + } elsif ($nfd == 3) { + $recv_3fds = PublicInbox::Spawn->can('recv_3fds'); + } + $recv_3fds or die + "IO::FDPass missing or Inline::C not installed/configured\n"; require PublicInbox::Listener; require PublicInbox::EOFpipe; (-p STDOUT) or die "E: stdout must be a pipe\n"; diff --git a/lib/PublicInbox/Spawn.pm b/lib/PublicInbox/Spawn.pm index 61e95433..cd94ba96 100644 --- a/lib/PublicInbox/Spawn.pm +++ b/lib/PublicInbox/Spawn.pm @@ -315,17 +315,6 @@ unless ($set_nodatacow) { *nodatacow_fd = \&PublicInbox::NDC_PP::nodatacow_fd; *nodatacow_dir = \&PublicInbox::NDC_PP::nodatacow_dir; } -unless (__PACKAGE__->can('recv_3fds')) { - eval { # try the XS IO::FDPass package - require IO::FDPass; - no warnings 'once'; - *recv_3fds = sub { map { IO::FDPass::recv($_[0]) } (0..2) }; - *send_3fds = sub ($$$$) { - my $sockfd = shift; - IO::FDPass::send($sockfd, shift) for (0..2); - }; - }; -} undef $set_nodatacow; undef $vfork_spawn; |