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 C21DA1F4C1 for ; Sat, 30 Nov 2024 08:26:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1732955192; bh=KL9dZibmGqCIHiEMMeoofCyOgi989eFvchKl/RNh6dk=; h=Date:From:To:Subject:References:In-Reply-To:From; b=sslFaacPW1E2LmmR5nIguTTyZiKr61ETfXngg0uoyZlJS8RS3hHXBB0ai1gVNmBaJ 4rG7vPEHQ4g3sxgNWikPd0aMllIMMLJVHSv3FjrgKYP+sGSCF97vvMHDCWZKQctFCw 56d6dhLAHGDwS+/Z96aSkMVAJs++ijV/MM12knvI= Date: Sat, 30 Nov 2024 08:26:32 +0000 From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 3/2] wqblocked: use per-instance unique timer Message-ID: <20241130082632.M683063@dcvr> References: <20241129235400.138579-1-e@80x24.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20241129235400.138579-1-e@80x24.org> List-Id: It was possible to end up with multiple timers being armed on a busy system from LeiNoteEvent due to the often rapid nature of renames. Since ->flush_send will flush all pending messages for the WQ, it's only necessary to arm a single timer for a given WQ socket. This saves some memory and unnecessary wakeups by using the handy unique timer mechanism in DS. --- lib/PublicInbox/WQBlocked.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/WQBlocked.pm b/lib/PublicInbox/WQBlocked.pm index b2463898..3e4d67f2 100644 --- a/lib/PublicInbox/WQBlocked.pm +++ b/lib/PublicInbox/WQBlocked.pm @@ -30,8 +30,8 @@ sub flush_send { PublicInbox::DS::epwait($wq_s1, EPOLLOUT|EPOLLONESHOT); } elsif ($!{ENOBUFS} || $!{ENOMEM}) { - PublicInbox::DS::add_timer(0.1, \&flush_send, - $self); + PublicInbox::DS::add_uniq_timer($self + 0, + 0.1, \&flush_send, $self); } else { Carp::croak("sendmsg: $!"); }