From: Andrew Myrick <amyrick@apple.com>
To: git@vger.kernel.org
Cc: normalperson@yhbt.net, sam@vilain.net, Andrew Myrick <amyrick@apple.com>
Subject: [PATCH] git-svn: persistent memoization
Date: Sat, 30 Jan 2010 03:14:22 +0000 [thread overview]
Message-ID: <1264821262-28322-1-git-send-email-amyrick@apple.com> (raw)
Make memoization of the svn:mergeinfo processing functions persistent with
Memoize::Storable so that the memoization tables don't need to be regenerated
every time the user runs git-svn fetch.
The Memoize::Storable hashes are stored in ENV{GIT_DIR}/svn/caches.
Signed-off-by: Andrew Myrick <amyrick@apple.com>
---
git-svn.perl | 42 +++++++++++++++++++++++++++++++++++++-----
1 files changed, 37 insertions(+), 5 deletions(-)
diff --git a/git-svn.perl b/git-svn.perl
index 1f201e4..f7a9410 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -1632,10 +1632,11 @@ use vars qw/$default_repo_id $default_ref_id $_no_metadata $_follow_parent
$_use_svnsync_props $no_reuse_existing $_minimize_url
$_use_log_author $_add_author_from $_localtime/;
use Carp qw/croak/;
-use File::Path qw/mkpath/;
+use File::Path qw/mkpath make_path/;
use File::Copy qw/copy/;
use IPC::Open3;
use Memoize; # core since 5.8.0, Jul 2002
+use Memoize::Storable;
my ($_gc_nr, $_gc_period);
@@ -3078,10 +3079,39 @@ sub has_no_changes {
command_oneline("rev-parse", "$commit~1^{tree}"));
}
-BEGIN {
- memoize 'lookup_svn_merge';
- memoize 'check_cherry_pick';
- memoize 'has_no_changes';
+# The GIT_DIR environment variable is not always set until after the command
+# line arguments are processed, so we can't memoize in a BEGIN block.
+{
+ my $memoized = 0;
+
+ sub memoize_svn_mergeinfo_functions {
+ return if $memoized;
+ $memoized = 1;
+
+ my $cache_path = "$ENV{GIT_DIR}/svn/caches/";
+ make_path($cache_path) unless -d $cache_path;
+
+ tie my %lookup_svn_merge_cache =>
+ 'Memoize::Storable',"$cache_path/lookup_svn_merge.db", 'nstore';
+ memoize 'lookup_svn_merge',
+ SCALAR_CACHE => 'FAULT',
+ LIST_CACHE => ['HASH' => \%lookup_svn_merge_cache],
+ ;
+
+ tie my %check_cherry_pick_cache =>
+ 'Memoize::Storable',"$cache_path/check_cherry_pick.db", 'nstore';
+ memoize 'check_cherry_pick',
+ SCALAR_CACHE => 'FAULT',
+ LIST_CACHE => ['HASH' => \%check_cherry_pick_cache],
+ ;
+
+ tie my %has_no_changes_cache =>
+ 'Memoize::Storable',"$cache_path/has_no_changes.db", 'nstore';
+ memoize 'has_no_changes',
+ SCALAR_CACHE => ['HASH' => \%has_no_changes_cache],
+ LIST_CACHE => 'FAULT',
+ ;
+ }
}
sub parents_exclude {
@@ -3125,6 +3155,8 @@ sub find_extra_svn_parents {
my ($self, $ed, $mergeinfo, $parents) = @_;
# aha! svk:merge property changed...
+ memoize_svn_mergeinfo_functions();
+
# We first search for merged tips which are not in our
# history. Then, we figure out which git revisions are in
# that tip, but not this revision. If all of those revisions
--
1.6.6.1.4.g3df0a5.dirty
next reply other threads:[~2010-01-30 3:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-30 3:14 Andrew Myrick [this message]
2010-02-01 4:03 ` [PATCH] git-svn: persistent memoization Eric Wong
2010-02-01 16:44 ` Andrew Myrick
2010-02-05 10:02 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1264821262-28322-1-git-send-email-amyrick@apple.com \
--to=amyrick@apple.com \
--cc=git@vger.kernel.org \
--cc=normalperson@yhbt.net \
--cc=sam@vilain.net \
/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 NNTP newsgroup(s).