From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 4CAD51F565 for ; Sun, 1 Oct 2023 02:43:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1696128204; bh=b1GauJ1A+1CGgOsrWsAddFB56LHQwv3HbwKq/pu33sg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=3uyyIn2VX+vyqwpgWBwRF8TDdVTNX95HiNk2NnDYLN2Uwil/HCGwr4UnIuGy+Hj7g 17HM8qg0xDL3DjWgV3SoeBUwRutdilwfSmbbk+WIaWi3MzSIy5HrXtx9ppvuG6iFad nA+ZIBQs7lxTHRuYrLulJpPftq0LbOUlGdZ5wmrk= From: Eric Wong To: spew@80x24.org Subject: [PATCH 03/16] git+gcf2client: switch to level-triggered wakeups Date: Sun, 1 Oct 2023 02:43:10 +0000 Message-ID: <20231001024323.1960491-3-e@80x24.org> In-Reply-To: <20231001024323.1960491-1-e@80x24.org> References: <20231001024323.1960491-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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; } }