From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 1/4] wqworker: favor level-triggered epoll for fairness
Date: Sat, 16 Oct 2021 09:29:50 +0000 [thread overview]
Message-ID: <20211016092953.32649-2-e@80x24.org> (raw)
In-Reply-To: <20211016092953.32649-1-e@80x24.org>
Sigfd->event_step needs priority over WQWorkers (and everything
else). Do that by running once per event_loop iteration rather
than looping inside event_step. This lowers throughput since it
requires more syscalls, but that's the price of fairness.
---
lib/PublicInbox/WQWorker.pm | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/lib/PublicInbox/WQWorker.pm b/lib/PublicInbox/WQWorker.pm
index 48b901bb139f..950bd17052a5 100644
--- a/lib/PublicInbox/WQWorker.pm
+++ b/lib/PublicInbox/WQWorker.pm
@@ -6,7 +6,7 @@ package PublicInbox::WQWorker;
use strict;
use v5.10.1;
use parent qw(PublicInbox::DS);
-use PublicInbox::Syscall qw(EPOLLIN EPOLLEXCLUSIVE EPOLLET);
+use PublicInbox::Syscall qw(EPOLLIN EPOLLEXCLUSIVE);
use Errno qw(EAGAIN ECONNRESET);
use IO::Handle (); # blocking
@@ -14,19 +14,19 @@ sub new {
my ($cls, $wq, $sock) = @_;
$sock->blocking(0);
my $self = bless { sock => $sock, wq => $wq }, $cls;
- $self->SUPER::new($sock, EPOLLEXCLUSIVE|EPOLLIN|EPOLLET);
+ $self->SUPER::new($sock, EPOLLEXCLUSIVE|EPOLLIN);
$self;
}
sub event_step {
my ($self) = @_;
- my $n;
- do {
- $n = $self->{wq}->recv_and_run($self->{sock});
- } while ($n);
- return if !defined($n) && $! == EAGAIN; # likely
- warn "wq worker error: $!\n" if !defined($n) && $! != ECONNRESET;
- $self->{wq}->wq_atexit_child if $self->{sock} == $self->{wq}->{-wq_s2};
+ my $n = $self->{wq}->recv_and_run($self->{sock}) and return;
+ unless (defined $n) {
+ return if $! == EAGAIN;
+ warn "recvmsg: $!" if $! != ECONNRESET;
+ }
+ $self->{sock} == $self->{wq}->{-wq_s2} and
+ $self->{wq}->wq_atexit_child;
$self->close; # PublicInbox::DS::close
}
next prev parent reply other threads:[~2021-10-16 9:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-16 9:29 [PATCH 0/4] lei: prioritize signals Eric Wong
2021-10-16 9:29 ` Eric Wong [this message]
2021-10-16 9:29 ` [PATCH 2/4] pkt_op: favor level-triggered epoll for fairness Eric Wong
2021-10-16 9:29 ` [PATCH 3/4] input_pipe: do not loop in ->event_step " Eric Wong
2021-10-16 9:29 ` [PATCH 4/4] lei sockets: favor level-triggered epoll " Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211016092953.32649-2-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).