bug-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Proposed branch tag performance patch for feature and stable releases


From: Kelly F. Hickel
Subject: Proposed branch tag performance patch for feature and stable releases
Date: Thu, 4 May 2006 15:10:03 -0500

Here are patches for both cvs 1.11.21 and 1.12.13 releases to greatly
improve performance when doing branch tags on files that have man
branches (800 or more in my case).  Both patches pass the sanity.sh
tests on linux, and have been tested on windows to the extent possible.

 

On a copy of my live repo, this patch taks a branch tag of the full repo
from about 115 minutes down to 8 minutes.

 

There are other improvements possible, but this seemed the least
disruptive to the existing code base, and the safest way to handle it.  

 

Let me know if I need to provide any more information, or do something
else with these patches to get them accepted.....

 

Thanks,

 

 

********** Begin patch for 1.11.21 ************************

--- cvs-1.11.21/src/rcs.c     2005-09-26 09:31:36.000000000 -0500
+++ cvs-1.11.21_patched/src/rcs.c   2006-05-04 11:39:58.000000000 -0500
@@ -133,6 +133,9 @@
 static FILE *rcs_internal_lockfile PROTO ((char *));
 static void rcs_internal_unlockfile PROTO ((FILE *, char *));
 static char *rcs_lockfilename PROTO ((const char *));
+static int findnextmagicrev PROTO ((RCSNode *rcs, char *rev, int
default_rv));
+static int findhighestmagicrev_proc PROTO((Node *p, void *closure));
+
 
 /* The RCS file reading functions are called a lot, and they do some
    string comparisons.  This macro speeds things up a bit by skipping
@@ -2549,8 +2552,13 @@
     xrev = xmalloc (strlen (rev) + 14); /* enough for .0.number */
     check_rev = xrev;
 
+    /* prime the pump by finding the next unused magic rev,
+     * if none are found, it should return 2.
+     */
+    rev_num = findnextmagicrev(rcs, rev, 2);
+    
     /* only look at even numbered branches */
-    for (rev_num = 2; ; rev_num += 2)
+    for (; ; rev_num += 2)
     {
      /* see if the physical branch exists */
      (void) sprintf (xrev, "%s.%d", rev, rev_num);
@@ -8818,3 +8826,64 @@
     }
     return label;
 }
+
+/*
+ * Go through the symbolic tag list, find the next unused magic
+ * branch revision.
+ *
+ * Returns 2 if it can't figure anything out, then the caller
+ * will end up doing a linear search.
+ */
+static int findnextmagicrev_dots;
+static int
+findnextmagicrev(rcs, rev, defaultrv)
+  RCSNode *rcs;
+  char *rev;
+  int defaultrv;
+{
+  int rv = defaultrv;
+
+  /* Tell the walklist proc how many dots we're looking for,
+   * which is the number of dots in the existing rev, plus
+   * 2.  one for RCS_MAGIC_BRANCH and one for the new rev number.
+   */
+  findnextmagicrev_dots = numdots(rev) + 2;
+  
+  /* walk the symbols list to find the highest revision. */
+  (void)walklist (RCS_symbols(rcs), findhighestmagicrev_proc, &rv);
+
+  /* adjust to next even number if we found something */
+  if(rv != defaultrv) {
+    if((rv % 2) != 0)
+      rv++;
+    else
+      rv += 2;
+  }
+
+  return rv;
+}
+
+/*
+ * walklist proc to find the highest magic rev with
+ * the required number of dots.
+ */
+static int
+findhighestmagicrev_proc(p, closure)
+  Node *p;
+  void *closure;
+{
+  int *rev = (int*)closure;
+
+  if(numdots(p->data) == findnextmagicrev_dots) {
+    /* if the last term of the rev is greater than the current max,
update */
+    char *cp;
+    cp = strrchr(p->data, '.');
+    if((cp != 0) && (cp[1] != 0)) {
+      int new_rev = atoi(cp+1);
+      if(new_rev > *rev) {
+        *rev = new_rev;
+      }
+    }
+  }
+  return 1;
+}
 

 

 

 

 

********** Begin patch for 1.12.13 ************************

--- cvs-1.12.13/src/rcs.c     2005-09-28 10:25:59.000000000 -0500
+++ cvs-1.12.13_patched/src/rcs.c   2006-05-04 11:40:21.000000000 -0500
@@ -128,6 +128,8 @@
 static FILE *rcs_internal_lockfile (char *);
 static void rcs_internal_unlockfile (FILE *, char *);
 static char *rcs_lockfilename (const char *);
+static int findnextmagicrev (RCSNode *rcs, char *rev, int default_rv);
+static int findhighestmagicrev_proc (Node *p, void *closure);
 
 /* The RCS file reading functions are called a lot, and they do some
    string comparisons.  This macro speeds things up a bit by skipping
@@ -2481,6 +2483,11 @@
     else
       rev_num = 2;
 
+    /* prime the pump by finding the next unused magic rev,
+     * if none are found, it should return the value we started with.
+     */
+    rev_num = findnextmagicrev(rcs, rev, rev_num);
+
     /* only look at even numbered branches */
     for ( ; ; rev_num += 2)
     {
@@ -8876,3 +8883,64 @@
     }
     return CVSname;
 }
+
+/*
+ * Go through the symbolic tag list, find the next unused magic
+ * branch revision.
+ *
+ * Returns 2 if it can't figure anything out, then the caller
+ * will end up doing a linear search.
+ */
+static int findnextmagicrev_dots;
+static int
+findnextmagicrev(rcs, rev, defaultrv)
+  RCSNode *rcs;
+  char *rev;
+  int defaultrv;
+{
+  int rv = defaultrv;
+
+  /* Tell the walklist proc how many dots we're looking for,
+   * which is the number of dots in the existing rev, plus
+   * 2.  one for RCS_MAGIC_BRANCH and one for the new rev number.
+   */
+  findnextmagicrev_dots = numdots(rev) + 2;
+  
+  /* walk the symbols list to find the highest revision. */
+  (void)walklist (RCS_symbols(rcs), findhighestmagicrev_proc, &rv);
+
+  /* adjust to next even number if we found something */
+  if(rv != defaultrv) {
+    if((rv % 2) != 0)
+      rv++;
+    else
+      rv += 2;
+  }
+
+  return rv;
+}
+
+/*
+ * walklist proc to find the highest magic rev with
+ * the required number of dots.
+ */
+static int
+findhighestmagicrev_proc(p, closure)
+  Node *p;
+  void *closure;
+{
+  int *rev = (int*)closure;
+
+  if(numdots(p->data) == findnextmagicrev_dots) {
+    /* if the last term of the rev is greater than the current max,
update */
+    char *cp;
+    cp = strrchr(p->data, '.');
+    if((cp != 0) && (cp[1] != 0)) {
+      int new_rev = atoi(cp+1);
+      if(new_rev > *rev) {
+        *rev = new_rev;
+      }
+    }
+  }
+  return 1;
+}
 

 

-- 

Kelly F. Hickel
Senior Software Architect
MQSoftware, Inc
952.345.8677
kfh@mqsoftware.com

 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]