From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 2/4] codesearch: deduplicate {ibx_score} name pairs
Date: Mon, 11 Mar 2024 19:40:10 +0000 [thread overview]
Message-ID: <20240311194012.1266143-3-e@80x24.org> (raw)
In-Reply-To: <20240311194012.1266143-1-e@80x24.org>
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 <<EOM;
next prev parent reply other threads:[~2024-03-11 19:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-11 19:40 [PATCH 0/4] memory reductions for WWW + solver Eric Wong
2024-03-11 19:40 ` [PATCH 1/4] www: use a dedicated limiter for blob solver Eric Wong
2024-03-11 19:40 ` Eric Wong [this message]
2024-03-11 19:40 ` [PATCH 3/4] doc: tuning: note reduced fragmentation w/ jemalloc Eric Wong
2024-03-11 19:40 ` [PATCH 4/4] codesearch: deduplicate $git->{nick} field Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240311194012.1266143-3-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).