You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2013/10/29 17:11:04 UTC

svn commit: r1536786 - /subversion/branches/1.7.x/subversion/libsvn_fs_fs/fs_fs.c

Author: stefan2
Date: Tue Oct 29 16:11:04 2013
New Revision: 1536786

URL: http://svn.apache.org/r1536786
Log:
Backport of the code limiting the time spent walking the node history
when committing a file.

As it turns out, some users make scripted commits that not only create
deep histories for individual files but create many of those files with
the exact same depths of history, i.e. number of changes.

Without this patch, committing the e.g. 65536th change to this set of
files will take hours instead of the usual seconds.  With this patch
we are down to a few minutes.

* subversion/libsvn_fs_fs/fs_fs.c
  (SVN_FS_FS_MAX_DELTIFICATION_WALK): define limit to the effort we spend
                                      on finding a delta base
  (choose_delta_base): don't attempt walks longer than the defined limit

Modified:
    subversion/branches/1.7.x/subversion/libsvn_fs_fs/fs_fs.c

Modified: subversion/branches/1.7.x/subversion/libsvn_fs_fs/fs_fs.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x/subversion/libsvn_fs_fs/fs_fs.c?rev=1536786&r1=1536785&r2=1536786&view=diff
==============================================================================
--- subversion/branches/1.7.x/subversion/libsvn_fs_fs/fs_fs.c (original)
+++ subversion/branches/1.7.x/subversion/libsvn_fs_fs/fs_fs.c Tue Oct 29 16:11:04 2013
@@ -78,6 +78,13 @@
 #define SVN_FS_FS_DEFAULT_MAX_FILES_PER_DIR 1000
 #endif
 
+/* Finding a deltification base takes operations proportional to the
+   number of changes being skipped. To prevent exploding runtime
+   during commits, limit the deltification range to this value.
+   Should be a power of 2 minus one.
+   Values < 1 disable deltification. */
+#define SVN_FS_FS_MAX_DELTIFICATION_WALK 1023
+
 /* Following are defines that specify the textual elements of the
    native filesystem directories and revision files. */
 
@@ -5483,6 +5490,16 @@ choose_delta_base(representation_t **rep
   count = noderev->predecessor_count;
   count = count & (count - 1);
 
+  /* Finding the delta base over a very long distance can become extremely
+     expensive for very deep histories, possibly causing client timeouts etc.
+     OTOH, this is a rare operation and its gains are minimal. Lets simply
+     start deltification anew close every other 1000 changes or so.  */
+  if (noderev->predecessor_count - count > SVN_FS_FS_MAX_DELTIFICATION_WALK)
+    {
+      *rep = NULL;
+      return SVN_NO_ERROR;
+    }
+
   /* Walk back a number of predecessors equal to the difference
      between count and the original predecessor count.  (For example,
      if noderev has ten predecessors and we want the eighth file rev,