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 0A6751F4CA for ; Tue, 26 Nov 2024 21:29:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1732656564; bh=pBEP2QG02KaMVddDdX5Fmrvd2UqJ3+dSVepCZhS8inM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=g40B3aQQ1TXoi4QpqS6NhIY+1oDx9SuVFuGnqgeiMQMRDShW/+7G9FLzi3WoKrH7j kncZeOZcGHzryb+o3znbpkFsKyTavpDezb13lvO9yIhl4RUZpyzmR4CuPSbMH2KmpZ eO2mVh9ENh/sMr25U2AjIfcr0wvQ/DkLj6xm6Q0s= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/2] lei: avoid repeatedly recreating anonymous subs Date: Tue, 26 Nov 2024 21:29:23 +0000 Message-ID: <20241126212923.840812-3-e@80x24.org> In-Reply-To: <20241126212923.840812-1-e@80x24.org> References: <20241126212923.840812-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: The SIGTERM handler doesn't change, so we can reuse it across different instances without repeatedly creating a new one since (AFAIK) perl(1) isn't able to deduplicate identical subs. In any case, looping `local $SIG{TERM} = $coderef' reveals a minor speedup compared to the equivalent `local $SIG{TERM} = sub {...}'. --- lib/PublicInbox/LEI.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index fc7d190a..34ef95a1 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -590,6 +590,8 @@ sub note_sigpipe { # triggers sigpipe_handler x_it($self, 13); } +my $term_handler = sub { exit(128 + 15) }; + sub _lei_atfork_child { my ($self, $persist) = @_; # we need to explicitly close things which are on stack @@ -629,7 +631,7 @@ sub _lei_atfork_child { $cb->(@_) unless PublicInbox::Eml::warn_ignore(@_) }; } - $SIG{TERM} = sub { exit(128 + 15) }; + $SIG{TERM} = $term_handler; $current_lei = $persist ? undef : $self; # for SIG{__WARN__} }