* [PATCH] lei_mirror: use fetch.hideRefs to speed up connectivity check
@ 2023-02-15 22:20 Eric Wong
2023-03-23 8:33 ` Eric Wong
0 siblings, 1 reply; 2+ messages in thread
From: Eric Wong @ 2023-02-15 22:20 UTC (permalink / raw)
To: meta
`git fetch' runs an expensive connectivity check against all
refs, which is unnecessarily expensive for incremental fetches
on RAM-constrained systems.
This depends on the proposal to support `fetch.hideRefs' for `git fetch':
https://public-inbox.org/git/20230212090426.M558990@dcvr/
---
I'll commit this if it lands in git.git
lib/PublicInbox/LeiMirror.pm | 32 +++++++++++++++++++++-----------
1 file changed, 21 insertions(+), 11 deletions(-)
diff --git a/lib/PublicInbox/LeiMirror.pm b/lib/PublicInbox/LeiMirror.pm
index 4dedac9b..95486f37 100644
--- a/lib/PublicInbox/LeiMirror.pm
+++ b/lib/PublicInbox/LeiMirror.pm
@@ -407,13 +407,13 @@ sub fgrp_fetch_all {
while (my ($osdir, $fgrp_old_new) = each %$todo) {
my $f = "$osdir/config";
return if !keep_going($self);
- my ($fgrpv, $new) = @$fgrp_old_new;
- @$fgrpv = sort { $b->{-sort} <=> $a->{-sort} } @$fgrpv;
- push @$fgrpv, @$new; # $new is ordered by references
-
+ my ($old, $new) = @$fgrp_old_new;
+ @$old = sort { $b->{-sort} <=> $a->{-sort} } @$old;
+ # $new is ordered by {references}
my $cmd = ['git', "--git-dir=$osdir", qw(config -f), $f ];
- # clobber group from previous run atomically
- for ("remotes.$grp") { # TODO: hideRefs
+
+ # clobber settings from previous run atomically
+ for ("remotes.$grp", 'fetch.hideRefs') {
my $c = [ @$cmd, '--unset-all', $_ ];
$self->{lei}->qerr("# @$c");
next if $self->{dry_run};
@@ -424,7 +424,7 @@ sub fgrp_fetch_all {
# permanent configs:
my $cfg = PublicInbox::Config->git_config_dump($f);
- for my $fgrp (@$fgrpv) {
+ for my $fgrp (@$old, @$new) {
my $u = $fgrp->{-uri} // die 'BUG: no {-uri}';
my $rn = $fgrp->{-remote} // die 'BUG: no {-remote}';
for ("url=$u", "fetch=+refs/*:refs/remotes/$rn/*",
@@ -446,14 +446,24 @@ sub fgrp_fetch_all {
or die "open($f.lock): $!";
open my $fh, '>>', $f or die "open(>>$f): $!";
$fh->autoflush(1);
- my $buf = join('', "[remotes]\n",
- map { "\t$grp = $_->{-remote}\n" } @$fgrpv);
+ my $buf = '';
+ if (@$old) {
+ $buf = "[fetch]\n\thideRefs = refs\n";
+ $buf .= join('', map {
+ "\thideRefs = !refs/remotes/" .
+ "$_->{-remote}/\n";
+ } @$old);
+ }
+ $buf .= join('', "[remotes]\n",
+ (map { "\t$grp = $_->{-remote}\n" } @$old),
+ (map { "\t$grp = $_->{-remote}\n" } @$new));
print $fh $buf or die "print($f): $!";
close $fh or die "close($f): $!";
unlink("$f.lock") or die "unlink($f.lock): $!";
}
- $cmd = [ @git, "--git-dir=$osdir", @fetch, $grp ];
- my $end = PublicInbox::OnDestroy->new($$, \&fgrpv_done, $fgrpv);
+ $cmd = [ @git, "--git-dir=$osdir", @fetch, $grp ];
+ push @$old, @$new;
+ my $end = PublicInbox::OnDestroy->new($$, \&fgrpv_done, $old);
start_cmd($self, $cmd, $opt, $end);
}
}
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] lei_mirror: use fetch.hideRefs to speed up connectivity check
2023-02-15 22:20 [PATCH] lei_mirror: use fetch.hideRefs to speed up connectivity check Eric Wong
@ 2023-03-23 8:33 ` Eric Wong
0 siblings, 0 replies; 2+ messages in thread
From: Eric Wong @ 2023-03-23 8:33 UTC (permalink / raw)
To: meta
Eric Wong <e@80x24.org> wrote:
> `git fetch' runs an expensive connectivity check against all
> refs, which is unnecessarily expensive for incremental fetches
> on RAM-constrained systems.
>
> This depends on the proposal to support `fetch.hideRefs' for `git fetch':
> https://public-inbox.org/git/20230212090426.M558990@dcvr/
> ---
> I'll commit this if it lands in git.git
It's in git.git master:
https://80x24.org/lore/pub/scm/git/git.git/4d87411ffe2432efa8800b9e9d889241dd0f1f07/s/
So merged as commit e28c01f038ddafa1f78c1ba47b5593fe353b5978 in
public-inbox.git
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-03-23 8:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-15 22:20 [PATCH] lei_mirror: use fetch.hideRefs to speed up connectivity check Eric Wong
2023-03-23 8:33 ` Eric Wong
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).