git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[StGIT PATCH 1/4] Speed up the discovery of uninteresting commits

From
Karl Hasselström <kha@treskal.com>
Date
Aug 13, 2007, 21:01 UTC
Message-ID
<20070813210125.25929.80371.stgit@yoghurt>
In-Reply-To
<20070813205801.25929.34925.stgit@yoghurt>

The operation of discovering uninteresting commits (that is, all the commits that immediately precede a patch but don't have any patch among their ancestors) is expensive. Make it less so, by using the fact that we're done as soon as we've seen all patch commits.

This is probably less of a win than might be naively expected, since we give the --topo-order flag to git-rev-list, which causes it to have to read the full DAG to even start producing the output; but at least we skip quite a bit of looping and set manipulation in Python, which ought to be worth _something_.

Signed-off-by: Karl Hasselström <kha@treskal.com>
---
 stgit/stack.py |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/stgit/stack.py b/stgit/stack.py
index 1b6808e..d3756d0 100644
--- a/stgit/stack.py
+++ b/stgit/stack.py
@@ -472,11 +472,17 @@ class UninterestingCache:
                 for p in parents:
                     if not p in interesting:
                         uninteresting.add(p)
-                continue
+
+                # If this is the last patch commit, there is no way we
+                # can encounter any more uninteresting commits.
+                patches.remove(commit)
+                if not patches:
+                    break
 
             # Commits with interesting parents are interesting.
-            if interesting.intersection(parents):
+            elif interesting.intersection(parents):
                 interesting.add(commit)
+
         self.__uninteresting = uninteresting
         out.done()
     def create_patch(self, name, top, bottom):
Previous: Karl HasselströmNext: Karl Hasselström
Message 2 of 5 in “Optimizations for the DAG appliedness stuff”
  1. 0/4 Optimizations for the DAG appliedness stuffKarl Hasselström, Aug 13, 2007
  2. 1/4 Speed up the discovery of uninteresting commitsKarl Hasselström, Aug 13, 2007
  3. 2/4 Speed up appliedness check during patch creationKarl Hasselström, Aug 13, 2007
  4. 3/4 Don't traverse the whole DAG when looking for uninteresting commitsKarl Hasselström, Aug 13, 2007
  5. 4/4 Find uninteresting commits faster for special casesKarl Hasselström, Aug 13, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.