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, T_SCC_BODY_TEXT_LINE 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 050B61F518 for ; Mon, 11 Mar 2024 19:40:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1710186013; bh=NqQ+b9dzCYvz0HfYElqZHX/WSxbATz9aRlvEnFrg6Ko=; h=From:To:Subject:Date:In-Reply-To:References:From; b=WuEfMK3Ch4GUkoir3aMWIM3zLtbH4zflm17P2ljKq1FP40G7z7Hf32bFt0JQMWmUQ GaBks51MqObQfT/FLU9BW7wWO/LxgCOlRu3mgYkEhbGP3T51tnvCFBpxKpwRxEudlX +yx4p+VLwH7VssZgFjjpOU1D+dUdeARr9Gs9gsfE= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/4] codesearch: deduplicate {ibx_score} name pairs Date: Mon, 11 Mar 2024 19:40:10 +0000 Message-ID: <20240311194012.1266143-3-e@80x24.org> In-Reply-To: <20240311194012.1266143-1-e@80x24.org> References: <20240311194012.1266143-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: With my current mirror of lore + gko, this saves over 300K allocations and brings the allocation count in this area down to under 5K. The reduction in AV refs saves around 45MB RAM according to measurements done live via Devel::Mwrap. --- lib/PublicInbox/CodeSearch.pm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/CodeSearch.pm b/lib/PublicInbox/CodeSearch.pm index 1f95a726..48033bb5 100644 --- a/lib/PublicInbox/CodeSearch.pm +++ b/lib/PublicInbox/CodeSearch.pm @@ -292,6 +292,7 @@ W: cindex.$name.topdir=$self->{topdir} has no usable join data for $cfg_f EOM my ($ekeys, $roots, $ibx2root) = @$jd{qw(ekeys roots ibx2root)}; my $roots2paths = roots2paths($self); + my %dedupe; # 50x alloc reduction w/ lore + gko mirror (Mar 2024) for my $root_offs (@$ibx2root) { my $ekey = shift(@$ekeys) // die 'BUG: {ekeys} empty'; scalar(@$root_offs) or next; @@ -320,9 +321,15 @@ EOM if (my $git = $dir2cr{$_}) { $ibx_p2g{$_} = $git; $ibx2self = 1; - $ibx->{-hide_www} or - push @{$git->{ibx_score}}, + if (!$ibx->{-hide_www}) { + # don't stringify $nr directly + # to avoid long-lived PV + my $k = ($nr + 0)."\0". + ($ibx + 0); + my $s = $dedupe{$k} //= [ $nr, $ibx->{name} ]; + push @{$git->{ibx_score}}, $s; + } push @$gits, $git; } else { warn <