Instead of using ->requeue to emulate level-triggered wakeups in
userspace, just use level-triggered wakeups in the kernel to
save some user time at the expense of system (kernel) time.  Of
course, the ready list implementation in the kernel via C is
faster than a Perl one on our end.

We must still use requeue if we've got buffered data, however.

Followup-to: 1181a7e6a853 (listener: switch to level-triggered epoll)
---
 lib/PublicInbox/Gcf2Client.pm | 4 ++--
 lib/PublicInbox/Git.pm        | 7 ++++---
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/lib/PublicInbox/Gcf2Client.pm b/lib/PublicInbox/Gcf2Client.pm
index 8f442787..8ac44a5e 100644
--- a/lib/PublicInbox/Gcf2Client.pm
+++ b/lib/PublicInbox/Gcf2Client.pm
@@ -9,7 +9,7 @@ use PublicInbox::Git;
 use PublicInbox::Gcf2; # fails if Inline::C or libgit2-dev isn't available
 use PublicInbox::Spawn qw(spawn);
 use Socket qw(AF_UNIX SOCK_STREAM);
-use PublicInbox::Syscall qw(EPOLLIN EPOLLET);
+use PublicInbox::Syscall qw(EPOLLIN);
 use PublicInbox::ProcessPipe;
 
 # fields:
@@ -35,7 +35,7 @@ sub new  {
        my $sock = PublicInbox::ProcessPipe->maybe_new($pid, $s1);
        $self->{inflight} = [];
        $self->{epwatch} = \undef; # for Git->cleanup
-       $self->SUPER::new($sock, EPOLLIN|EPOLLET);
+       $self->SUPER::new($sock, EPOLLIN);
 }
 
 sub gcf2_async ($$$;$) {
diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm
index 3062f293..5003be53 100644
--- a/lib/PublicInbox/Git.pm
+++ b/lib/PublicInbox/Git.pm
@@ -650,15 +650,16 @@ sub event_step {
        if ($inflight && @$inflight) {
                $self->cat_async_step($inflight);
                return $self->close unless $self->{sock};
-               # more to do? requeue for fairness:
-               $self->requeue if @$inflight || exists($self->{rbuf});
+               # don't loop here to keep things fair, but we must requeue
+               # if there's already-read data in rbuf
+               $self->requeue if exists($self->{rbuf});
        }
 }
 
 # idempotently registers with DS epoll/kqueue/select/poll
 sub watch_async ($) {
        $_[0]->{epwatch} //= do {
-               $_[0]->SUPER::new($_[0]->{sock}, EPOLLIN|EPOLLET);
+               $_[0]->SUPER::new($_[0]->{sock}, EPOLLIN);
                \undef;
        }
 }

Reply via email to