diff options
author | Eric Wong <e@80x24.org> | 2020-09-19 09:37:13 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2020-09-19 21:39:46 +0000 |
commit | 881a5493a8c970c10c051cc55d10d2968e71e691 (patch) | |
tree | 2ad0e7a2658ae855b4c1a5bae663633dfca01098 /script/public-inbox-gcf2 | |
parent | 3750b2e2952e55fe4a04c73fc78f25c5e07d0525 (diff) | |
download | public-inbox-881a5493a8c970c10c051cc55d10d2968e71e691.tar.gz |
This amortizes the cost of recreating PublicInbox::Gcf2 objects when alternates change in v2 all.git.
Diffstat (limited to 'script/public-inbox-gcf2')
-rwxr-xr-x | script/public-inbox-gcf2 | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/script/public-inbox-gcf2 b/script/public-inbox-gcf2 index d2d2ac8b..4a44b654 100755 --- a/script/public-inbox-gcf2 +++ b/script/public-inbox-gcf2 @@ -3,7 +3,6 @@ # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt> eval { require PublicInbox::Gcf2 }; die "libgit2 development package or Inline::C missing for $0: $@\n" if $@; -my @dirs; # may get big (30K-100K) my $gcf2 = PublicInbox::Gcf2::new(); use IO::Handle; # autoflush STDERR->autoflush(1); @@ -11,19 +10,16 @@ STDOUT->autoflush(1); while (<STDIN>) { chomp; - if (m!\A/!) { # +/path/to/git-dir - push @dirs, $_; - $gcf2->add_alternate("$_/objects"); - } elsif (!$gcf2->cat_oid(1, $_)) { + my ($oid, $git_dir) = split(/ /, $_, 2); + $gcf2->add_alternate("$git_dir/objects"); + if (!$gcf2->cat_oid(1, $oid)) { # retry once if missing. We only get unabbreviated OIDs # from SQLite or Xapian DBs, here, so malicious clients # can't trigger excessive retries: - my $oid = $_; - warn "I: $$ $oid missing, retrying...\n"; + warn "I: $$ $oid missing, retrying in $git_dir...\n"; - # clients may need to wait a bit for this: $gcf2 = PublicInbox::Gcf2::new(); - $gcf2->add_alternate("$_/objects") for @dirs; + $gcf2->add_alternate("$git_dir/objects"); if ($gcf2->cat_oid(1, $oid)) { warn "I: $$ $oid found after retry\n"; |