diff options
author | Eric Wong <e@80x24.org> | 2023-10-17 23:38:02 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2023-10-18 20:50:32 +0000 |
commit | 48aca3659c248c936a978a8338cf19aacc9483a1 (patch) | |
tree | f58abcee6960e6f479f79f5d03f57469d479d0ac /lib/PublicInbox | |
parent | 5406e15b4de72644e4bedb73029c94cad7af5d0a (diff) | |
download | public-inbox-48aca3659c248c936a978a8338cf19aacc9483a1.tar.gz |
We use this in various places to minimize or maximize pipe size on Linux. So keep it all in one place.
Diffstat (limited to 'lib/PublicInbox')
-rw-r--r-- | lib/PublicInbox/CidxLogP.pm | 4 | ||||
-rw-r--r-- | lib/PublicInbox/EOFpipe.pm | 6 | ||||
-rw-r--r-- | lib/PublicInbox/LeiXSearch.pm | 2 | ||||
-rw-r--r-- | lib/PublicInbox/SearchIdxShard.pm | 14 | ||||
-rw-r--r-- | lib/PublicInbox/Syscall.pm | 16 |
5 files changed, 21 insertions, 21 deletions
diff --git a/lib/PublicInbox/CidxLogP.pm b/lib/PublicInbox/CidxLogP.pm index 7877d5ac..34f7201d 100644 --- a/lib/PublicInbox/CidxLogP.pm +++ b/lib/PublicInbox/CidxLogP.pm @@ -10,12 +10,12 @@ package PublicInbox::CidxLogP; use v5.12; use parent qw(PublicInbox::DS); -use PublicInbox::Syscall qw(EPOLLIN EPOLLONESHOT); +use PublicInbox::Syscall qw(EPOLLIN EPOLLONESHOT $F_SETPIPE_SZ); sub new { my ($cls, $rd, $cidx, $git, $roots) = @_; my $self = bless { cidx => $cidx, git => $git, roots => $roots }, $cls; - fcntl($rd, 1031, 1048576) if $^O eq 'linux'; # fatter pipes + fcntl($rd, $F_SETPIPE_SZ, 1048576) if $F_SETPIPE_SZ; $self->SUPER::new($rd, EPOLLIN|EPOLLONESHOT); } diff --git a/lib/PublicInbox/EOFpipe.pm b/lib/PublicInbox/EOFpipe.pm index 628e9366..3474874f 100644 --- a/lib/PublicInbox/EOFpipe.pm +++ b/lib/PublicInbox/EOFpipe.pm @@ -4,13 +4,13 @@ package PublicInbox::EOFpipe; use v5.12; use parent qw(PublicInbox::DS); -use PublicInbox::Syscall qw(EPOLLIN EPOLLONESHOT); +use PublicInbox::Syscall qw(EPOLLIN EPOLLONESHOT $F_SETPIPE_SZ); sub new { my (undef, $rd, $cb) = @_; my $self = bless { cb => $cb }, __PACKAGE__; - # 1031: F_SETPIPE_SZ, 4096: page size - fcntl($rd, 1031, 4096) if $^O eq 'linux'; + # 4096: page size + fcntl($rd, $F_SETPIPE_SZ, 4096) if $F_SETPIPE_SZ; $self->SUPER::new($rd, EPOLLIN|EPOLLONESHOT); } diff --git a/lib/PublicInbox/LeiXSearch.pm b/lib/PublicInbox/LeiXSearch.pm index d83a403c..25b66b3b 100644 --- a/lib/PublicInbox/LeiXSearch.pm +++ b/lib/PublicInbox/LeiXSearch.pm @@ -21,6 +21,7 @@ use Fcntl qw(SEEK_SET F_SETFL O_APPEND O_RDWR); use PublicInbox::ContentHash qw(git_sha); use POSIX qw(strftime); use autodie qw(open read seek truncate); +use PublicInbox::Syscall qw($F_SETPIPE_SZ); sub new { my ($class) = @_; @@ -536,7 +537,6 @@ sub do_query { if ($lei->{opt}->{augment} && delete $lei->{early_mua}) { $lei->start_mua; } - my $F_SETPIPE_SZ = $^O eq 'linux' ? 1031 : undef; if ($l2m->{-wq_nr_workers} > 1 && $l2m->{base_type} =~ /\A(?:maildir|mbox)\z/) { # setup two barriers to coordinate ->has_entries diff --git a/lib/PublicInbox/SearchIdxShard.pm b/lib/PublicInbox/SearchIdxShard.pm index 21bd56c2..1630eb4a 100644 --- a/lib/PublicInbox/SearchIdxShard.pm +++ b/lib/PublicInbox/SearchIdxShard.pm @@ -7,6 +7,7 @@ package PublicInbox::SearchIdxShard; 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 @@ -20,13 +21,12 @@ 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; diff --git a/lib/PublicInbox/Syscall.pm b/lib/PublicInbox/Syscall.pm index e83beb6a..78181bb6 100644 --- a/lib/PublicInbox/Syscall.pm +++ b/lib/PublicInbox/Syscall.pm @@ -28,7 +28,7 @@ our @EXPORT_OK = qw(epoll_ctl epoll_create epoll_wait EPOLLIN EPOLLOUT EPOLLET EPOLL_CTL_ADD EPOLL_CTL_DEL EPOLL_CTL_MOD EPOLLONESHOT EPOLLEXCLUSIVE - signalfd rename_noreplace %SIGNUM); + signalfd rename_noreplace %SIGNUM $F_SETPIPE_SZ); use constant { EPOLLIN => 1, EPOLLOUT => 4, @@ -55,13 +55,12 @@ use constant { my @BYTES_4_hole = BYTES_4_hole ? (0) : (); -our ( - $SYS_epoll_create, - $SYS_epoll_ctl, - $SYS_epoll_wait, - $SYS_signalfd4, - $SYS_renameat2, - ); +our ($SYS_epoll_create, + $SYS_epoll_ctl, + $SYS_epoll_wait, + $SYS_signalfd4, + $SYS_renameat2, + $F_SETPIPE_SZ); my ($SYS_sendmsg, $SYS_recvmsg); my $SYS_fstatfs; # don't need fstatfs64, just statfs.f_type @@ -70,6 +69,7 @@ my $SFD_CLOEXEC = 02000000; # Perl does not expose O_CLOEXEC our $no_deprecated = 0; if ($^O eq "linux") { + $F_SETPIPE_SZ = 1031; my (undef, undef, $release, undef, $machine) = POSIX::uname(); my ($maj, $min) = ($release =~ /\A([0-9]+)\.([0-9]+)/); $SYS_renameat2 = 0 if "$maj.$min" < 3.15; |