incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject git commit: [#4691] Fixed issue with tree walking when calculating LCDs
Date Tue, 11 Dec 2012 00:42:36 GMT
Updated Branches:
  refs/heads/cj/4691 5702abc9d -> 4ea4e88c9


[#4691] Fixed issue with tree walking when calculating LCDs

Signed-off-by: Cory Johns <johnsca@geek.net>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/4ea4e88c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/4ea4e88c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/4ea4e88c

Branch: refs/heads/cj/4691
Commit: 4ea4e88c97dbffb38ffd0ddf63834c7667642531
Parents: 5702abc
Author: Cory Johns <johnsca@geek.net>
Authored: Tue Dec 11 00:42:20 2012 +0000
Committer: Cory Johns <johnsca@geek.net>
Committed: Tue Dec 11 00:42:20 2012 +0000

----------------------------------------------------------------------
 Allura/allura/model/repo.py         |    6 +++---
 Allura/allura/model/repo_refresh.py |   20 ++++++++++++++++++--
 scripts/refresh-last-commits.py     |   15 +++++++++------
 3 files changed, 30 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4ea4e88c/Allura/allura/model/repo.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repo.py b/Allura/allura/model/repo.py
index a589531..b58e16d 100644
--- a/Allura/allura/model/repo.py
+++ b/Allura/allura/model/repo.py
@@ -744,10 +744,10 @@ class LastCommit(RepoObject):
             if path in commit.changed_paths:
                 cache._get_misses += 1
                 # tree was changed but no LCD found; have to build
-                tree = commit.tree
+                changed_tree = commit.tree
                 if path != '':
-                    tree = tree.get_obj_by_path(path)
-                return cls.build(tree, commit_ids)
+                    changed_tree = changed_tree.get_obj_by_path(path)
+                return cls.build(changed_tree, commit_ids)
             cache._get_walks += 1
             gw += 1
             cache._get_walks_max = max(cache._get_walks_max, gw)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4ea4e88c/Allura/allura/model/repo_refresh.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repo_refresh.py b/Allura/allura/model/repo_refresh.py
index 36ca927..34e55cb 100644
--- a/Allura/allura/model/repo_refresh.py
+++ b/Allura/allura/model/repo_refresh.py
@@ -503,14 +503,30 @@ def compute_lcds(commit, cache):
         lcd = LastCommit.get(tree)  # auto-vivify LCD
 
 def _walk_commit_tree(commit, cache):
+    def _clone_tree(tree):
+        '''
+        Since the Tree instances stick around in our cache,
+        subsequent calls to set_context are overwriting our
+        in-use copies and confusing the walk.  So, make an
+        memory-only copy for our use.
+        '''
+        new_tree = Tree(
+                _id=tree._id,
+                tree_ids=tree.tree_ids,
+                blob_ids=tree.blob_ids,
+                other_ids=tree.other_ids,
+            )
+        session(new_tree).expunge(new_tree)
+        return new_tree
+
     def _walk_tree(tree):
         yield tree
         for x in tree.tree_ids:
-            sub_tree = cache.get(Tree, dict(_id=x.id))
+            sub_tree = _clone_tree(cache.get(Tree, dict(_id=x.id)))
             sub_tree.set_context(tree, x.name)
             for xx in _walk_tree(sub_tree):
                 yield xx
-    top_tree = cache.get(Tree, dict(_id=commit.tree_id))
+    top_tree = _clone_tree(cache.get(Tree, dict(_id=commit.tree_id)))
     top_tree.set_context(commit)
     return _walk_tree(top_tree)
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4ea4e88c/scripts/refresh-last-commits.py
----------------------------------------------------------------------
diff --git a/scripts/refresh-last-commits.py b/scripts/refresh-last-commits.py
index e45bb49..e027d7c 100644
--- a/scripts/refresh-last-commits.py
+++ b/scripts/refresh-last-commits.py
@@ -98,7 +98,7 @@ def refresh_repo_lcds(commit_ids, options):
                 at = tt / len(timings)
                 print '  Processed %d commits (max: %f, avg: %f, tot: %f, cl: %d)' % (
                         len(timings), mt, at, tt, len(tree_cache))
-    lcd_cache = M.repo.ModelCache(20000)
+    lcd_cache = M.repo.ModelCache(6000)
     timings = []
     print 'Processing last commits'
     debug_step = int(pow(10, max(0, int(log10(len(commit_ids)) - log10(options.step) - 1))))
@@ -118,11 +118,14 @@ def refresh_repo_lcds(commit_ids, options):
             tt = sum(timings)
             at = tt / len(timings)
             mat = sum(timings[-debug_step:]) / debug_step
-            hits = sum(lcd_cache._hits.values())
-            accs = sum(lcd_cache._accesses.values())
-            print '  Processed %d commits (max: %f, avg: %f, mavg: %f, tot: %f, lc: %d, lcl:
%d, hits: %d, agw: %d, mgw: %d, gh: %d, abw: %d, mbw: %d, ts: %d)' % (
-                    len(timings), mt, at, mat, tt, lcd_cache.size(), len(lcd_cache._cache[M.repo.LastCommit]),
-                    hits * 100 / accs,
+            lhits = lcd_cache._hits[M.repo.LastCommit]
+            laccs = lcd_cache._accesses[M.repo.LastCommit]
+            ohits = sum([v for k,v in lcd_cache._hits.items() if k != M.repo.LastCommit])
+            oaccs = sum([v for k,v in lcd_cache._accesses.items() if k != M.repo.LastCommit])
+            print '  Processed %d commits (max: %f, avg: %f, mavg: %f, tot: %f, lc: %d/%d,
hit: %d/%d, agw: %d, mgw: %d, gh: %d, abw: %d, mbw: %d, ts: %d)' % (
+                    len(timings), mt, at, mat, tt,
+                    lcd_cache.size(), len(lcd_cache._cache[M.repo.LastCommit]),
+                    ohits * 100 / oaccs, lhits * 100 / laccs,
                     lcd_cache._get_walks / lcd_cache._get_calls, lcd_cache._get_walks_max,
lcd_cache._get_hits * 100 / lcd_cache._get_calls,
                     lcd_cache._build_walks / lcd_cache._build_calls, lcd_cache._build_walks_max,
                     len(lcd_cache.get(M.repo.TreesDoc, dict(_id=commit._id)).tree_ids))


Mime
View raw message