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 2011/02/19 10:58:35 UTC

svn commit: r1072288 - in /subversion/trunk: ./ subversion/include/ subversion/libsvn_delta/ subversion/libsvn_ra_neon/ subversion/libsvn_ra_svn/ subversion/mod_dav_svn/ subversion/mod_dav_svn/reports/ subversion/svnserve/ subversion/tests/libsvn_delta/

Author: stefan2
Date: Sat Feb 19 09:58:34 2011
New Revision: 1072288

URL: http://svn.apache.org/viewvc?rev=1072288&view=rev
Log:
Merge all changes (r1068651 - r1072287) from the 
integrate-compression-level branch.

These patches make the compression level used for
network data transfer configurable.

Modified:
    subversion/trunk/   (props changed)
    subversion/trunk/subversion/include/svn_delta.h
    subversion/trunk/subversion/include/svn_ra_svn.h
    subversion/trunk/subversion/libsvn_delta/svndiff.c
    subversion/trunk/subversion/libsvn_ra_neon/commit.c
    subversion/trunk/subversion/libsvn_ra_svn/editorp.c
    subversion/trunk/subversion/libsvn_ra_svn/marshal.c
    subversion/trunk/subversion/libsvn_ra_svn/ra_svn.h
    subversion/trunk/subversion/mod_dav_svn/dav_svn.h
    subversion/trunk/subversion/mod_dav_svn/mod_dav_svn.c
    subversion/trunk/subversion/mod_dav_svn/reports/file-revs.c
    subversion/trunk/subversion/mod_dav_svn/reports/replay.c
    subversion/trunk/subversion/mod_dav_svn/reports/update.c
    subversion/trunk/subversion/mod_dav_svn/repos.c
    subversion/trunk/subversion/svnserve/main.c
    subversion/trunk/subversion/svnserve/serve.c
    subversion/trunk/subversion/svnserve/server.h
    subversion/trunk/subversion/tests/libsvn_delta/random-test.c
    subversion/trunk/subversion/tests/libsvn_delta/svndiff-test.c

Propchange: subversion/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Feb 19 09:58:34 2011
@@ -14,6 +14,7 @@
 /subversion/branches/http-protocol-v2:874395-876041
 /subversion/branches/in-memory-cache:869829-871452
 /subversion/branches/integrate-cache-membuffer:998649-998852
+/subversion/branches/integrate-compression-level:1068651-1072287
 /subversion/branches/issue-2779-dev:965496-984198
 /subversion/branches/issue-2843-dev:871432-874179
 /subversion/branches/issue-3000:871713,871716-871719,871721-871726,871728,871734
@@ -27,7 +28,7 @@
 /subversion/branches/log-g-performance:870941-871032
 /subversion/branches/merge-skips-obstructions:874525-874615
 /subversion/branches/nfc-nfd-aware-client:870276,870376
-/subversion/branches/performance:979193,980118,981087,981684,982043,982355,983764,983766,984927,984973,984984,985014,985037,985046,985472,985477,985482,985500,985606,985669,986453,987888,987893,988319,990541,990568,990572,990600,990759,992899,992911,993127,993141,994956,995478,995507,995603,998858,999098,1001413,1001417,1004291,1022668,1022670,1022676,1022715,1022719,1025660,1025672,1027193,1027203,1027206,1027214,1027227,1028077,1028092,1028094,1028104,1028107,1028111,1028354,1029038,1029042-1029043,1029078,1029080,1029090,1029092-1029093,1029111,1029151,1029158,1029232,1029335,1029340,1029342,1029344,1030763,1030827,1031203,1031235,1032285,1032333,1033040,1033057,1033294,1035869,1039511,1043705,1053735,1056015,1066452,1067683
+/subversion/branches/performance:979193,980118,981087,981287,981684,981827,982043,982355,983764,983766,984927,984973,984984,985014,985037,985046,985472,985477,985482,985500,985606,985669,986453,987888,987893,988319,990541,990568,990572,990600,990759,992899,992911,993127,993141,994956,995478,995507,995603,998858,999098,1001413,1001417,1004291,1022668,1022670,1022676,1022715,1022719,1025660,1025672,1027193,1027203,1027206,1027214,1027227,1028077,1028092,1028094,1028104,1028107,1028111,1028354,1029038,1029042-1029043,1029078,1029080,1029090,1029092-1029093,1029111,1029151,1029158,1029232,1029335,1029339-1029340,1029342,1029344,1030763,1030827,1031203,1031235,1032285,1032333,1033040,1033057,1033294,1035869,1039511,1043705,1053735,1056015,1066452,1067683
 /subversion/branches/py-tests-as-modules:956579-1033052
 /subversion/branches/ra_serf-digest-authn:875693-876404
 /subversion/branches/reintegrate-improvements:873853-874164

Modified: subversion/trunk/subversion/include/svn_delta.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_delta.h?rev=1072288&r1=1072287&r2=1072288&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_delta.h (original)
+++ subversion/trunk/subversion/include/svn_delta.h Sat Feb 19 09:58:34 2011
@@ -49,6 +49,21 @@ extern "C" {
 
 
 
+/** This compression level effectively disables data compression.
+ * However, the data pre-processing costs may still not be zero.
+ */
+#define SVN_NO_COMPRESSION_LEVEL 0
+
+/** This is the maximum compression level we can pass to zlib.
+ */
+#define SVN_BEST_COMPRESSION_LEVEL 9
+
+/** This is the default compression level we pass to zlib.  It
+ * should be between 0 and 9, with higher numbers resulting in
+ * better compression rates but slower operation.
+ */
+#define SVN_DEFAULT_COMPRESSSION_LEVEL 5
+
 /**
  * Get libsvn_delta version information.
  *
@@ -453,7 +468,21 @@ svn_txdelta_apply(svn_stream_t *source,
  * Allocation takes place in a sub-pool of @a pool.  On return, @a *handler
  * is set to a window handler function and @a *handler_baton is set to
  * the value to pass as the @a baton argument to @a *handler. The svndiff
- * version is @a svndiff_version.
+ * version is @a svndiff_version. @a compression_level is the zlib
+ * compression level from 0 (no compression) and 9 (maximum compression).
+ *
+ * @since New in 1.7.
+ */
+void
+svn_txdelta_to_svndiff3(svn_txdelta_window_handler_t *handler,
+                        void **handler_baton,
+                        svn_stream_t *output,
+                        int svndiff_version,
+                        int compression_level,
+                        apr_pool_t *pool);
+
+/** Similar to svn_txdelta_to_svndiff3, but always using the SVN default
+ * compression level (@ref SVN_DEFAULT_COMPRESSSION_LEVEL).
  *
  * @since New in 1.4.
  */

Modified: subversion/trunk/subversion/include/svn_ra_svn.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_ra_svn.h?rev=1072288&r1=1072287&r2=1072288&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_ra_svn.h (original)
+++ subversion/trunk/subversion/include/svn_ra_svn.h Sat Feb 19 09:58:34 2011
@@ -161,7 +161,25 @@ typedef svn_error_t *(*svn_ra_svn_edit_c
  * input/output files.
  *
  * Either @a sock or @a in_file/@a out_file must be set, not both.
+ * Specify the desired network data compression level (zlib) from
+ * 0 (no compression) to 9 (best but slowest).
+ *
+ * @since New in 1.7.
+ */
+svn_ra_svn_conn_t *
+svn_ra_svn_create_conn2(apr_socket_t *sock,
+                        apr_file_t *in_file,
+                        apr_file_t *out_file,
+                        int compression_level,
+                        apr_pool_t *pool);
+
+/** Similar to @ref svn_ra_svn_create_conn2() but uses default
+ * compression level (@ref SVN_DEFAULT_COMPRESSSION_LEVEL) for network
+ * transmissions.
+ * 
+ * @deprecated Provided for backward compatibility with the 1.6 API.
  */
+SVN_DEPRECATED
 svn_ra_svn_conn_t *
 svn_ra_svn_create_conn(apr_socket_t *sock,
                        apr_file_t *in_file,
@@ -185,6 +203,13 @@ svn_boolean_t
 svn_ra_svn_has_capability(svn_ra_svn_conn_t *conn,
                           const char *capability);
 
+/** Return the data compression level to use for network transmissions
+ * 
+ * @since New in 1.7.
+ */
+int
+svn_ra_svn_compression_level(svn_ra_svn_conn_t *conn);
+
 /** Returns the remote address of the connection as a string, if known,
  *  or NULL if inapplicable. */
 const char *

Modified: subversion/trunk/subversion/libsvn_delta/svndiff.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_delta/svndiff.c?rev=1072288&r1=1072287&r2=1072288&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_delta/svndiff.c (original)
+++ subversion/trunk/subversion/libsvn_delta/svndiff.c Sat Feb 19 09:58:34 2011
@@ -42,23 +42,16 @@
    be compressed using zlib as a secondary compressor.  */
 #define MIN_COMPRESS_SIZE 512
 
-/* For svndiff, this is the compression level we pass to zlib.  It
-   should be between 0 and 9, with higher numbers being greater
-   compression.  */
-#define SVNDIFF1_COMPRESS_LEVEL 5
-#define NORMAL_BITS 7
-#define LENGTH_BITS 5
-
-
 /* ----- Text delta to svndiff ----- */
 
 /* We make one of these and get it passed back to us in calls to the
    window handler.  We only use it to record the write function and
-   baton passed to svn_txdelta_to_svndiff2().  */
+   baton passed to svn_txdelta_to_svndiff3().  */
 struct encoder_baton {
   svn_stream_t *output;
   svn_boolean_t header_done;
   int version;
+  int compression_level;
   apr_pool_t *pool;
 };
 
@@ -140,7 +133,10 @@ append_encoded_int(svn_stringbuf_t *head
    version of IN was no smaller than the original IN, OUT will be a copy
    of IN with the size prepended as an integer. */
 static svn_error_t *
-zlib_encode(const char *data, apr_size_t len, svn_stringbuf_t *out)
+zlib_encode(const char *data,
+            apr_size_t len,
+            svn_stringbuf_t *out,
+            int compression_level)
 {
   unsigned long endlen;
   apr_size_t intlen;
@@ -159,7 +155,7 @@ zlib_encode(const char *data, apr_size_t
 
       if (compress2((unsigned char *)out->data + intlen, &endlen,
                     (const unsigned char *)data, len,
-                    SVNDIFF1_COMPRESS_LEVEL) != Z_OK)
+                    compression_level) != Z_OK)
         return svn_error_create(SVN_ERR_SVNDIFF_INVALID_COMPRESSED_DATA,
                                 NULL,
                                 _("Compression of svndiff data failed"));
@@ -245,7 +241,8 @@ window_handler(svn_txdelta_window_t *win
   append_encoded_int(header, window->tview_len);
   if (eb->version == 1)
     {
-      SVN_ERR(zlib_encode(instructions->data, instructions->len, i1));
+      SVN_ERR(zlib_encode(instructions->data, instructions->len,
+                          i1, eb->compression_level));
       instructions = i1;
     }
   append_encoded_int(header, instructions->len);
@@ -254,7 +251,7 @@ window_handler(svn_txdelta_window_t *win
       svn_stringbuf_t *temp = svn_stringbuf_create("", pool);
       svn_string_t *tempstr = svn_string_create("", pool);
       SVN_ERR(zlib_encode(window->new_data->data, window->new_data->len,
-                          temp));
+                          temp, eb->compression_level));
       tempstr->data = temp->data;
       tempstr->len = temp->len;
       newdata = tempstr;
@@ -283,10 +280,11 @@ window_handler(svn_txdelta_window_t *win
 }
 
 void
-svn_txdelta_to_svndiff2(svn_txdelta_window_handler_t *handler,
+svn_txdelta_to_svndiff3(svn_txdelta_window_handler_t *handler,
                         void **handler_baton,
                         svn_stream_t *output,
                         int svndiff_version,
+                        int compression_level,
                         apr_pool_t *pool)
 {
   apr_pool_t *subpool = svn_pool_create(pool);
@@ -297,18 +295,31 @@ svn_txdelta_to_svndiff2(svn_txdelta_wind
   eb->header_done = FALSE;
   eb->pool = subpool;
   eb->version = svndiff_version;
+  eb->compression_level = compression_level;
 
   *handler = window_handler;
   *handler_baton = eb;
 }
 
 void
+svn_txdelta_to_svndiff2(svn_txdelta_window_handler_t *handler,
+                        void **handler_baton,
+                        svn_stream_t *output,
+                        int svndiff_version,
+                        apr_pool_t *pool)
+{
+  svn_txdelta_to_svndiff3(handler, handler_baton, output,
+                          svndiff_version, SVN_DEFAULT_COMPRESSSION_LEVEL, pool);
+}
+
+void
 svn_txdelta_to_svndiff(svn_stream_t *output,
                        apr_pool_t *pool,
                        svn_txdelta_window_handler_t *handler,
                        void **handler_baton)
 {
-  svn_txdelta_to_svndiff2(handler, handler_baton, output, 0, pool);
+  svn_txdelta_to_svndiff3(handler, handler_baton, output,
+                          0, SVN_DEFAULT_COMPRESSSION_LEVEL, pool);
 }
 
 

Modified: subversion/trunk/subversion/libsvn_ra_neon/commit.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_neon/commit.c?rev=1072288&r1=1072287&r2=1072288&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_neon/commit.c (original)
+++ subversion/trunk/subversion/libsvn_ra_neon/commit.c Sat Feb 19 09:58:34 2011
@@ -1215,7 +1215,8 @@ commit_apply_txdelta(void *file_baton,
   stream = svn_stream_create(baton, pool);
   svn_stream_set_write(stream, commit_stream_write);
 
-  svn_txdelta_to_svndiff2(handler, handler_baton, stream, 0, pool);
+  svn_txdelta_to_svndiff3(handler, handler_baton, stream, 0,
+                          dav_svn__get_compression_level(), pool);
 
   /* Add this path to the valid targets hash. */
   add_valid_target(file->cc, file->rsrc->local_path, svn_nonrecursive);

Modified: subversion/trunk/subversion/libsvn_ra_svn/editorp.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_svn/editorp.c?rev=1072288&r1=1072287&r2=1072288&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_svn/editorp.c (original)
+++ subversion/trunk/subversion/libsvn_ra_svn/editorp.c Sat Feb 19 09:58:34 2011
@@ -316,10 +316,16 @@ static svn_error_t *ra_svn_apply_textdel
   diff_stream = svn_stream_create(b, pool);
   svn_stream_set_write(diff_stream, ra_svn_svndiff_handler);
   svn_stream_set_close(diff_stream, ra_svn_svndiff_close_handler);
-  if (svn_ra_svn_has_capability(b->conn, SVN_RA_SVN_CAP_SVNDIFF1))
-    svn_txdelta_to_svndiff2(wh, wh_baton, diff_stream, 1, pool);
+
+  /* If the connection does not support SVNDIFF1 or if we don't want to use
+   * compression, use the non-compressing "version 0" implementation */ 
+  if (   svn_ra_svn_compression_level(b->conn) > 0
+      && svn_ra_svn_has_capability(b->conn, SVN_RA_SVN_CAP_SVNDIFF1)) 
+    svn_txdelta_to_svndiff3(wh, wh_baton, diff_stream, 1,
+                            b->conn->compression_level, pool);
   else
-    svn_txdelta_to_svndiff2(wh, wh_baton, diff_stream, 0, pool);
+    svn_txdelta_to_svndiff3(wh, wh_baton, diff_stream, 0,
+                            b->conn->compression_level, pool);
   return SVN_NO_ERROR;
 }
 

Modified: subversion/trunk/subversion/libsvn_ra_svn/marshal.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_svn/marshal.c?rev=1072288&r1=1072287&r2=1072288&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_svn/marshal.c (original)
+++ subversion/trunk/subversion/libsvn_ra_svn/marshal.c Sat Feb 19 09:58:34 2011
@@ -52,10 +52,11 @@
 
 /* --- CONNECTION INITIALIZATION --- */
 
-svn_ra_svn_conn_t *svn_ra_svn_create_conn(apr_socket_t *sock,
-                                          apr_file_t *in_file,
-                                          apr_file_t *out_file,
-                                          apr_pool_t *pool)
+svn_ra_svn_conn_t *svn_ra_svn_create_conn2(apr_socket_t *sock,
+                                           apr_file_t *in_file,
+                                           apr_file_t *out_file,
+                                           int compression_level,
+                                           apr_pool_t *pool)
 {
   svn_ra_svn_conn_t *conn = apr_palloc(pool, sizeof(*conn));
 
@@ -71,6 +72,7 @@ svn_ra_svn_conn_t *svn_ra_svn_create_con
   conn->block_handler = NULL;
   conn->block_baton = NULL;
   conn->capabilities = apr_hash_make(pool);
+  conn->compression_level = compression_level;
   conn->pool = pool;
 
   if (sock != NULL)
@@ -90,6 +92,16 @@ svn_ra_svn_conn_t *svn_ra_svn_create_con
   return conn;
 }
 
+/* backward-compatible implementation using the default compression level */
+svn_ra_svn_conn_t *svn_ra_svn_create_conn(apr_socket_t *sock,
+                                          apr_file_t *in_file,
+                                          apr_file_t *out_file,
+                                          apr_pool_t *pool)
+{
+  return svn_ra_svn_create_conn2(sock, in_file, out_file, 
+                                 SVN_DEFAULT_COMPRESSSION_LEVEL, pool);
+}
+
 svn_error_t *svn_ra_svn_set_capabilities(svn_ra_svn_conn_t *conn,
                                          const apr_array_header_t *list)
 {
@@ -116,6 +128,12 @@ svn_boolean_t svn_ra_svn_has_capability(
                        APR_HASH_KEY_STRING) != NULL);
 }
 
+int
+svn_ra_svn_compression_level(svn_ra_svn_conn_t *conn)
+{
+  return conn->compression_level;
+}
+
 const char *svn_ra_svn_conn_remote_host(svn_ra_svn_conn_t *conn)
 {
   return conn->remote_ip;

Modified: subversion/trunk/subversion/libsvn_ra_svn/ra_svn.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_svn/ra_svn.h?rev=1072288&r1=1072287&r2=1072288&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_svn/ra_svn.h (original)
+++ subversion/trunk/subversion/libsvn_ra_svn/ra_svn.h Sat Feb 19 09:58:34 2011
@@ -85,6 +85,7 @@ struct svn_ra_svn_conn_st {
   ra_svn_block_handler_t block_handler;
   void *block_baton;
   apr_hash_t *capabilities;
+  int compression_level;
   char *remote_ip;
   apr_pool_t *pool;
 };

Modified: subversion/trunk/subversion/mod_dav_svn/dav_svn.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/mod_dav_svn/dav_svn.h?rev=1072288&r1=1072287&r2=1072288&view=diff
==============================================================================
--- subversion/trunk/subversion/mod_dav_svn/dav_svn.h (original)
+++ subversion/trunk/subversion/mod_dav_svn/dav_svn.h Sat Feb 19 09:58:34 2011
@@ -370,6 +370,8 @@ const char *dav_svn__get_activities_db(r
 /* ### Is this assumed to be URI-encoded? */
 const char *dav_svn__get_root_dir(request_rec *r);
 
+/* Return the data compression level to be used over the wire. */
+int dav_svn__get_compression_level();
 
 /** For HTTP protocol v2, these are the new URIs and URI stubs
     returned to the client in our OPTIONS response.  They all depend

Modified: subversion/trunk/subversion/mod_dav_svn/mod_dav_svn.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/mod_dav_svn/mod_dav_svn.c?rev=1072288&r1=1072287&r2=1072288&view=diff
==============================================================================
--- subversion/trunk/subversion/mod_dav_svn/mod_dav_svn.c (original)
+++ subversion/trunk/subversion/mod_dav_svn/mod_dav_svn.c Sat Feb 19 09:58:34 2011
@@ -101,6 +101,10 @@ extern module AP_MODULE_DECLARE_DATA dav
 /* The authz_svn provider for bypassing path authz. */
 static authz_svn__subreq_bypass_func_t pathauthz_bypass_func = NULL;
 
+/* The compression level we will pass to svn_txdelta_to_svndiff3()
+ * for wire-compression */
+static int svn__compression_level = SVN_DEFAULT_COMPRESSSION_LEVEL;
+
 static int
 init(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
 {
@@ -440,6 +444,32 @@ SVNInMemoryCacheSize_cmd(cmd_parms *cmd,
   return NULL;
 }
 
+static const char *
+SVNCompressionLevel_cmd(cmd_parms *cmd, void *config, const char *arg1)
+{
+  svn_fs_cache_config_t settings = *svn_fs_get_cache_config();
+
+  int value = 0;
+  svn_error_t *err = svn_cstring_atoi(&value, arg1);
+  if (err)
+    {
+      svn_error_clear(err);
+      return "Invalid decimal number for the SVN compression level.";
+    }
+
+  if ((value < SVN_NO_COMPRESSION_LEVEL) || (value > SVN_BEST_COMPRESSION_LEVEL))
+    return apr_psprintf(cmd->pool,
+                        "%d is not a valid compression level. "
+                        "The valid range is %d .. %d.",
+                        value,
+                        (int)SVN_NO_COMPRESSION_LEVEL,
+                        (int)SVN_BEST_COMPRESSION_LEVEL);
+
+  svn__compression_level = value;
+
+  return NULL;
+}
+
 
 /** Accessor functions for the module's configuration state **/
 
@@ -675,6 +705,12 @@ dav_svn__get_activities_db(request_rec *
 }
 
 
+int
+dav_svn__get_compression_level()
+{
+  return svn__compression_level;
+}
+
 static void
 merge_xml_filter_insert(request_rec *r)
 {
@@ -881,9 +917,15 @@ static const command_rec cmds[] =
   /* per server */
   AP_INIT_TAKE1("SVNInMemoryCacheSize", SVNInMemoryCacheSize_cmd, NULL,
                 RSRC_CONF,
-                "specify the maximum size im MB per process of Subversion's "
+                "specifies the maximum size im MB per process of Subversion's "
                 "in-memory object cache (default value is 16; 0 deactivates "
                 "the cache)."),
+  /* per server */
+  AP_INIT_TAKE1("SVNCompressionLevel", SVNCompressionLevel_cmd, NULL,
+                RSRC_CONF,
+                "specifies the ZIP compression level used before sending file "
+                "content over the network (0 for no compression, 9 for best, "
+                "5 is default)."),
 
   { NULL }
 };

Modified: subversion/trunk/subversion/mod_dav_svn/reports/file-revs.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/mod_dav_svn/reports/file-revs.c?rev=1072288&r1=1072287&r2=1072288&view=diff
==============================================================================
--- subversion/trunk/subversion/mod_dav_svn/reports/file-revs.c (original)
+++ subversion/trunk/subversion/mod_dav_svn/reports/file-revs.c Sat Feb 19 09:58:34 2011
@@ -206,8 +206,9 @@ file_rev_handler(void *baton,
 
       base64_stream = dav_svn__make_base64_output_stream(frb->bb, frb->output,
                                                          pool);
-      svn_txdelta_to_svndiff2(&frb->window_handler, &frb->window_baton,
-                              base64_stream, frb->svndiff_version, pool);
+      svn_txdelta_to_svndiff3(&frb->window_handler, &frb->window_baton,
+                              base64_stream, frb->svndiff_version,
+                              dav_svn__get_compression_level(), pool);
       *window_handler = delta_window_handler;
       *window_baton = frb;
       /* Start the txdelta element wich will be terminated by the window

Modified: subversion/trunk/subversion/mod_dav_svn/reports/replay.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/mod_dav_svn/reports/replay.c?rev=1072288&r1=1072287&r2=1072288&view=diff
==============================================================================
--- subversion/trunk/subversion/mod_dav_svn/reports/replay.c (original)
+++ subversion/trunk/subversion/mod_dav_svn/reports/replay.c Sat Feb 19 09:58:34 2011
@@ -320,12 +320,13 @@ apply_textdelta(void *file_baton,
   else
     SVN_ERR(dav_svn__brigade_puts(eb->bb, eb->output, ">"));
 
-  svn_txdelta_to_svndiff2(handler,
+  svn_txdelta_to_svndiff3(handler,
                           handler_baton,
                           dav_svn__make_base64_output_stream(eb->bb,
                                                              eb->output,
                                                              pool),
                           0,
+                          dav_svn__get_compression_level(),
                           pool);
 
   eb->sending_textdelta = TRUE;

Modified: subversion/trunk/subversion/mod_dav_svn/reports/update.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/mod_dav_svn/reports/update.c?rev=1072288&r1=1072287&r2=1072288&view=diff
==============================================================================
--- subversion/trunk/subversion/mod_dav_svn/reports/update.c (original)
+++ subversion/trunk/subversion/mod_dav_svn/reports/update.c Sat Feb 19 09:58:34 2011
@@ -779,9 +779,9 @@ upd_apply_textdelta(void *file_baton,
                                                      wb->uc->output,
                                                      file->pool);
 
-  svn_txdelta_to_svndiff2(&(wb->handler), &(wb->handler_baton),
+  svn_txdelta_to_svndiff3(&(wb->handler), &(wb->handler_baton),
                           base64_stream, file->uc->svndiff_version,
-                          file->pool);
+                          dav_svn__get_compression_level(), file->pool);
 
   *handler = window_handler;
   *handler_baton = wb;

Modified: subversion/trunk/subversion/mod_dav_svn/repos.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/mod_dav_svn/repos.c?rev=1072288&r1=1072287&r2=1072288&view=diff
==============================================================================
--- subversion/trunk/subversion/mod_dav_svn/repos.c (original)
+++ subversion/trunk/subversion/mod_dav_svn/repos.c Sat Feb 19 09:58:34 2011
@@ -3509,8 +3509,9 @@ deliver(const dav_resource *resource, ap
           svn_stream_set_close(o_stream, close_filter);
 
           /* get a handler/baton for writing into the output stream */
-          svn_txdelta_to_svndiff2(&handler, &h_baton,
+          svn_txdelta_to_svndiff3(&handler, &h_baton,
                                   o_stream, resource->info->svndiff_version,
+                                  dav_svn__get_compression_level(),
                                   resource->pool);
 
           /* got everything set up. read in delta windows and shove them into

Modified: subversion/trunk/subversion/svnserve/main.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnserve/main.c?rev=1072288&r1=1072287&r2=1072288&view=diff
==============================================================================
--- subversion/trunk/subversion/svnserve/main.c (original)
+++ subversion/trunk/subversion/svnserve/main.c Sat Feb 19 09:58:34 2011
@@ -189,6 +189,12 @@ static const apr_getopt_option_t svnserv
         "at the same time is not supported in daemon mode.\n"
         "                             "
         "Use inetd mode or tunnel mode if you need this.]")},
+    {"compression",      'c', 1,
+     N_("compression level to use for network transmissions\n"
+        "                             "
+        "[0 .. no compression, 5 .. default, \n"
+        "                             "
+        " 9 .. maximum compresssion]")},
     {"memory-cache-size", 'M', 1, 
      N_("size of the extra in-memory cache in MB used to\n"
         "                             "
@@ -445,6 +451,7 @@ int main(int argc, const char *argv[])
   params.cfg = NULL;
   params.pwdb = NULL;
   params.authzdb = NULL;
+  params.compression_level = SVN_DEFAULT_COMPRESSSION_LEVEL;
   params.log_file = NULL;
   params.username_case = CASE_ASIS;
   params.memory_cache_size = (apr_uint64_t)-1;
@@ -560,6 +567,14 @@ int main(int argc, const char *argv[])
           handling_mode = connection_mode_thread;
           break;
 
+        case 'c':
+          params.compression_level = atoi(arg);
+          if (params.compression_level < SVN_NO_COMPRESSION_LEVEL)
+            params.compression_level = SVN_NO_COMPRESSION_LEVEL;
+          if (params.compression_level > SVN_BEST_COMPRESSION_LEVEL)
+            params.compression_level = SVN_BEST_COMPRESSION_LEVEL;
+          break;
+
         case 'M':
           params.memory_cache_size = 0x100000 * apr_strtoi64(arg, NULL, 0);
           break;
@@ -662,7 +677,8 @@ int main(int argc, const char *argv[])
           return svn_cmdline_handle_exit_error(err, pool, "svnserve: ");
         }
 
-      conn = svn_ra_svn_create_conn(NULL, in_file, out_file, pool);
+      conn = svn_ra_svn_create_conn2(NULL, in_file, out_file, 
+                                     params.compression_level, pool);
       svn_error_clear(serve(conn, &params, pool));
       exit(0);
     }
@@ -908,7 +924,9 @@ int main(int argc, const char *argv[])
           /* It's not a fatal error if we cannot enable keep-alives. */
         }
 
-      conn = svn_ra_svn_create_conn(usock, NULL, NULL, connection_pool);
+      conn = svn_ra_svn_create_conn2(usock, NULL, NULL,
+                                     params.compression_level,
+                                     connection_pool);
 
       if (run_mode == run_mode_listen_once)
         {

Modified: subversion/trunk/subversion/svnserve/serve.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnserve/serve.c?rev=1072288&r1=1072287&r2=1072288&view=diff
==============================================================================
--- subversion/trunk/subversion/svnserve/serve.c (original)
+++ subversion/trunk/subversion/svnserve/serve.c Sat Feb 19 09:58:34 2011
@@ -2366,10 +2366,15 @@ static svn_error_t *file_rev_handler(voi
       svn_stream_set_write(stream, svndiff_handler);
       svn_stream_set_close(stream, svndiff_close_handler);
 
-      if (svn_ra_svn_has_capability(frb->conn, SVN_RA_SVN_CAP_SVNDIFF1))
-        svn_txdelta_to_svndiff2(d_handler, d_baton, stream, 1, pool);
+      /* If the connection does not support SVNDIFF1 or if we don't want to use
+       * compression, use the non-compressing "version 0" implementation */ 
+      if (   svn_ra_svn_compression_level(frb->conn) > 0
+          && svn_ra_svn_has_capability(frb->conn, SVN_RA_SVN_CAP_SVNDIFF1))
+        svn_txdelta_to_svndiff3(d_handler, d_baton, stream, 1,
+                                svn_ra_svn_compression_level(frb->conn), pool);
       else
-        svn_txdelta_to_svndiff2(d_handler, d_baton, stream, 0, pool);
+        svn_txdelta_to_svndiff3(d_handler, d_baton, stream, 0,
+                                svn_ra_svn_compression_level(frb->conn), pool);
     }
   else
     SVN_ERR(svn_ra_svn_write_cstring(frb->conn, pool, ""));
@@ -3091,17 +3096,27 @@ svn_error_t *serve(svn_ra_svn_conn_t *co
 
   /* Send greeting.  We don't support version 1 any more, so we can
    * send an empty mechlist. */
-  /* Server-side capabilities list: */
-  SVN_ERR(svn_ra_svn_write_cmd_response(conn, pool, "nn()(wwwwwwww)",
-                                        (apr_uint64_t) 2, (apr_uint64_t) 2,
-                                        SVN_RA_SVN_CAP_EDIT_PIPELINE,
-                                        SVN_RA_SVN_CAP_SVNDIFF1,
-                                        SVN_RA_SVN_CAP_ABSENT_ENTRIES,
-                                        SVN_RA_SVN_CAP_COMMIT_REVPROPS,
-                                        SVN_RA_SVN_CAP_DEPTH,
-                                        SVN_RA_SVN_CAP_LOG_REVPROPS,
-                                        SVN_RA_SVN_CAP_ATOMIC_REVPROPS,
-                                        SVN_RA_SVN_CAP_PARTIAL_REPLAY));
+  if (params->compression_level > 0)
+    SVN_ERR(svn_ra_svn_write_cmd_response(conn, pool, "nn()(wwwwwwww)",
+                                          (apr_uint64_t) 2, (apr_uint64_t) 2,
+                                          SVN_RA_SVN_CAP_EDIT_PIPELINE,
+                                          SVN_RA_SVN_CAP_SVNDIFF1,
+                                          SVN_RA_SVN_CAP_ABSENT_ENTRIES,
+                                          SVN_RA_SVN_CAP_COMMIT_REVPROPS,
+                                          SVN_RA_SVN_CAP_DEPTH,
+                                          SVN_RA_SVN_CAP_LOG_REVPROPS,
+                                          SVN_RA_SVN_CAP_ATOMIC_REVPROPS,
+                                          SVN_RA_SVN_CAP_PARTIAL_REPLAY));
+  else
+    SVN_ERR(svn_ra_svn_write_cmd_response(conn, pool, "nn()(wwwwwww)",
+                                          (apr_uint64_t) 2, (apr_uint64_t) 2,
+                                          SVN_RA_SVN_CAP_EDIT_PIPELINE,
+                                          SVN_RA_SVN_CAP_ABSENT_ENTRIES,
+                                          SVN_RA_SVN_CAP_COMMIT_REVPROPS,
+                                          SVN_RA_SVN_CAP_DEPTH,
+                                          SVN_RA_SVN_CAP_LOG_REVPROPS,
+                                          SVN_RA_SVN_CAP_ATOMIC_REVPROPS,
+                                          SVN_RA_SVN_CAP_PARTIAL_REPLAY));
 
   /* Read client response, which we assume to be in version 2 format:
    * version, capability list, and client URL; then we do an auth

Modified: subversion/trunk/subversion/svnserve/server.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnserve/server.h?rev=1072288&r1=1072287&r2=1072288&view=diff
==============================================================================
--- subversion/trunk/subversion/svnserve/server.h (original)
+++ subversion/trunk/subversion/svnserve/server.h Sat Feb 19 09:58:34 2011
@@ -112,6 +112,12 @@ typedef struct serve_params_t {
   /* Size of the in-memory cache (used by FSFS only). */
   apr_uint64_t memory_cache_size;
 
+  /* Data compression level to reduce for network traffic. If this
+     is 0, no compression should be applied and the protocol may
+     fall back to svndiff "version 0" bypassing zlib entirely.
+     Defaults to SVN_DEFAULT_COMPRESSSION_LEVEL. */
+  int compression_level;
+
 } serve_params_t;
 
 /* Serve the connection CONN according to the parameters PARAMS. */

Modified: subversion/trunk/subversion/tests/libsvn_delta/random-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_delta/random-test.c?rev=1072288&r1=1072287&r2=1072288&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_delta/random-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_delta/random-test.c Sat Feb 19 09:58:34 2011
@@ -330,8 +330,9 @@ random_test(apr_pool_t *pool)
       stream = svn_txdelta_parse_svndiff(handler, handler_baton, TRUE,
                                          delta_pool);
 
-      /* Make stage 2: encode the text delta in svndiff format.  */
-      svn_txdelta_to_svndiff2(&handler, &handler_baton, stream, 1,
+      /* Make stage 2: encode the text delta in svndiff format using
+                       varying compression levels. */
+      svn_txdelta_to_svndiff3(&handler, &handler_baton, stream, 1, i % 10,
                               delta_pool);
 
       /* Make stage 1: create the text delta.  */
@@ -412,8 +413,9 @@ do_random_combine_test(apr_pool_t *pool,
       stream = svn_txdelta_parse_svndiff(handler, handler_baton, TRUE,
                                          delta_pool);
 
-      /* Make stage 2: encode the text delta in svndiff format.  */
-      svn_txdelta_to_svndiff2(&handler, &handler_baton, stream, 1,
+      /* Make stage 2: encode the text delta in svndiff format using
+                       varying compression levels. */
+      svn_txdelta_to_svndiff3(&handler, &handler_baton, stream, 1, i % 10,
                               delta_pool);
 
       /* Make stage 1: create the text deltas.  */

Modified: subversion/trunk/subversion/tests/libsvn_delta/svndiff-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_delta/svndiff-test.c?rev=1072288&r1=1072287&r2=1072288&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_delta/svndiff-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_delta/svndiff-test.c Sat Feb 19 09:58:34 2011
@@ -89,8 +89,9 @@ main(int argc, char **argv)
 #else
   encoder = svn_base64_encode(stdout_stream, pool);
 #endif
-  svn_txdelta_to_svndiff2(&svndiff_handler, &svndiff_baton,
-                          encoder, version, pool);
+  /* use maximum compression level */
+  svn_txdelta_to_svndiff3(&svndiff_handler, &svndiff_baton,
+                          encoder, version, 9, pool);
   err = svn_txdelta_send_txstream(txdelta_stream,
                                   svndiff_handler,
                                   svndiff_baton,