]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
git+gcf2client: switch to level-triggered wakeups
authorEric Wong <e@80x24.org>
Sat, 30 Sep 2023 15:20:40 +0000 (15:20 +0000)
committerEric Wong <e@80x24.org>
Sun, 1 Oct 2023 07:05:23 +0000 (07:05 +0000)
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
lib/PublicInbox/Git.pm

index 8f44278765cc7d925205e1764c23e29d64d89f44..8ac44a5e5aa8bc1c3581907111efadd446c02b40 100644 (file)
@@ -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 ($$$;$) {
index 3062f293f8e3fde9dafba6250ae25162dfebd37a..5003be537379741b06aa52c68468f1368da427a8 100644 (file)
@@ -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;
        }
 }