Skip to content

Commit d0b34f2

Browse files
author
Eric Wong
committed
git-svn: reduce check_cherry_pick cache overhead
We do not need to store entire lists of commits, only the number of incomplete and the first commit for reference. This reduces the amount of data we need to store in memory and on disk stores. Signed-off-by: Eric Wong <[email protected]>
1 parent 9ee13a9 commit d0b34f2

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

perl/Git/SVN.pm

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,7 +1537,7 @@ sub _rev_list {
15371537
@rv;
15381538
}
15391539

1540-
sub check_cherry_pick {
1540+
sub check_cherry_pick2 {
15411541
my $base = shift;
15421542
my $tip = shift;
15431543
my $parents = shift;
@@ -1552,7 +1552,8 @@ sub check_cherry_pick {
15521552
delete $commits{$commit};
15531553
}
15541554
}
1555-
return (keys %commits);
1555+
my @k = (keys %commits);
1556+
return (scalar @k, $k[0]);
15561557
}
15571558

15581559
sub has_no_changes {
@@ -1597,7 +1598,7 @@ sub tie_for_persistent_memoization {
15971598
mkpath([$cache_path]) unless -d $cache_path;
15981599

15991600
my %lookup_svn_merge_cache;
1600-
my %check_cherry_pick_cache;
1601+
my %check_cherry_pick2_cache;
16011602
my %has_no_changes_cache;
16021603
my %_rev_list_cache;
16031604

@@ -1608,11 +1609,11 @@ sub tie_for_persistent_memoization {
16081609
LIST_CACHE => ['HASH' => \%lookup_svn_merge_cache],
16091610
;
16101611

1611-
tie_for_persistent_memoization(\%check_cherry_pick_cache,
1612-
"$cache_path/check_cherry_pick");
1613-
memoize 'check_cherry_pick',
1612+
tie_for_persistent_memoization(\%check_cherry_pick2_cache,
1613+
"$cache_path/check_cherry_pick2");
1614+
memoize 'check_cherry_pick2',
16141615
SCALAR_CACHE => 'FAULT',
1615-
LIST_CACHE => ['HASH' => \%check_cherry_pick_cache],
1616+
LIST_CACHE => ['HASH' => \%check_cherry_pick2_cache],
16161617
;
16171618

16181619
tie_for_persistent_memoization(\%has_no_changes_cache,
@@ -1636,7 +1637,7 @@ sub tie_for_persistent_memoization {
16361637
$memoized = 0;
16371638

16381639
Memoize::unmemoize 'lookup_svn_merge';
1639-
Memoize::unmemoize 'check_cherry_pick';
1640+
Memoize::unmemoize 'check_cherry_pick2';
16401641
Memoize::unmemoize 'has_no_changes';
16411642
Memoize::unmemoize '_rev_list';
16421643
}
@@ -1648,7 +1649,8 @@ sub tie_for_persistent_memoization {
16481649
return unless -d $cache_path;
16491650

16501651
for my $cache_file (("$cache_path/lookup_svn_merge",
1651-
"$cache_path/check_cherry_pick",
1652+
"$cache_path/check_cherry_pick", # old
1653+
"$cache_path/check_cherry_pick2",
16521654
"$cache_path/has_no_changes")) {
16531655
for my $suffix (qw(yaml db)) {
16541656
my $file = "$cache_file.$suffix";
@@ -1817,15 +1819,15 @@ sub find_extra_svn_parents {
18171819
}
18181820

18191821
# double check that there are no missing non-merge commits
1820-
my (@incomplete) = check_cherry_pick(
1822+
my ($ninc, $ifirst) = check_cherry_pick2(
18211823
$merge_base, $merge_tip,
18221824
$parents,
18231825
@all_ranges,
18241826
);
18251827

1826-
if ( @incomplete ) {
1827-
warn "W:svn cherry-pick ignored ($spec) - missing "
1828-
.@incomplete." commit(s) (eg $incomplete[0])\n";
1828+
if ($ninc) {
1829+
warn "W:svn cherry-pick ignored ($spec) - missing " .
1830+
"$ninc commit(s) (eg $ifirst)\n";
18291831
} else {
18301832
warn
18311833
"Found merge parent ($spec): ",

0 commit comments

Comments
 (0)