You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ko...@apache.org on 2017/07/14 15:50:03 UTC
svn commit: r1801974 - in /subversion/trunk/subversion: include/svn_dav.h
libsvn_ra_serf/commit.c libsvn_ra_serf/options.c libsvn_ra_serf/ra_serf.h
libsvn_ra_serf/util.c mod_dav_svn/repos.c mod_dav_svn/version.c
Author: kotkov
Date: Fri Jul 14 15:50:03 2017
New Revision: 1801974
URL: http://svn.apache.org/viewvc?rev=1801974&view=rev
Log:
Negotiate the use of the svndiff2 format over http://.
On the server-side, start sending svndiff2 deltas to clients that can read
them, but only when SVNCompressionLevel is set to 1. On the client-side,
keep sending svndiff1. Currently we use svndiff1 with default compression
ratio (5), and svndiff2 is not a substitute for it, as that would result
in worse compression.
* subversion/include/svn_dav.h
(SVN_DAV_NS_DAV_SVN_SVNDIFF2): New.
* subversion/libsvn_ra_serf/ra_serf.h
(svn_ra_serf__session_t): Add 'supports_svndiff2' field.
* subversion/libsvn_ra_serf/options.c
(capabilities_headers_iterator_callback): Remember if the server supports
svndiff2.
* subversion/libsvn_ra_serf/commit.c
(apply_textdelta): Add the fallback code for a theoretically possible
situation where the server has advertised _only_ svndiff2 support.
Note why we still use svndiff1 when client-side http compression is
enabled. Adjust a couple of comments.
* subversion/libsvn_ra_serf/util.c
(svn_ra_serf__setup_svndiff_accept_encoding): Advertise support for both
svndiff2 and svndiff1 with identical (q=) values. We'll let the server
decide between svndiff2 and svndiff1.
* subversion/mod_dav_svn/repos.c
(negotiate_encoding_prefs): Select the svndiff2 format if the client
supports it and if the server's SVNCompressionLevel is set to 1.
* subversion/mod_dav_svn/version.c
(get_vsn_options): Advertise svndiff2 support.
Modified:
subversion/trunk/subversion/include/svn_dav.h
subversion/trunk/subversion/libsvn_ra_serf/commit.c
subversion/trunk/subversion/libsvn_ra_serf/options.c
subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h
subversion/trunk/subversion/libsvn_ra_serf/util.c
subversion/trunk/subversion/mod_dav_svn/repos.c
subversion/trunk/subversion/mod_dav_svn/version.c
Modified: subversion/trunk/subversion/include/svn_dav.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_dav.h?rev=1801974&r1=1801973&r2=1801974&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_dav.h (original)
+++ subversion/trunk/subversion/include/svn_dav.h Fri Jul 14 15:50:03 2017
@@ -395,6 +395,14 @@ extern "C" {
#define SVN_DAV_NS_DAV_SVN_SVNDIFF1\
SVN_DAV_PROP_NS_DAV "svn/svndiff1"
+/** Presence of this in a DAV header in an OPTIONS response indicates
+ * that the transmitter (in this case, the server) knows how to handle
+ * svndiff2 format encoding.
+ *
+ * @since New in 1.10.
+ */
+#define SVN_DAV_NS_DAV_SVN_SVNDIFF2\
+ SVN_DAV_PROP_NS_DAV "svn/svndiff2"
/** @} */
Modified: subversion/trunk/subversion/libsvn_ra_serf/commit.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/commit.c?rev=1801974&r1=1801973&r2=1801974&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/commit.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/commit.c Fri Jul 14 15:50:03 2017
@@ -1896,17 +1896,32 @@ apply_textdelta(void *file_baton,
if (ctx->commit_ctx->session->supports_svndiff1 &&
ctx->commit_ctx->session->using_compression)
{
- /* Use compressed svndiff1 format, if possible. */
+ /* Prefer svndiff1 when using http compression, as svndiff2 is not a
+ * substitute for svndiff1 with default compression level. (It gives
+ * better speed and compression ratio comparable to svndiff1 with
+ * compression level 1, but not 5).
+ *
+ * It might make sense to tweak the current format negotiation scheme
+ * so that the server would say which versions of svndiff it accepts,
+ * _including_ the preferred order. This would allow us to dynamically
+ * pick svndiff2 if that's what the server thinks is appropriate.
+ */
svndiff_version = 1;
compression_level = SVN_DELTA_COMPRESSION_LEVEL_DEFAULT;
}
+ else if (ctx->commit_ctx->session->supports_svndiff2 &&
+ ctx->commit_ctx->session->using_compression)
+ {
+ svndiff_version = 2;
+ compression_level = SVN_DELTA_COMPRESSION_LEVEL_NONE;
+ }
else
{
- /* Difference between svndiff formats 0 and 1 that format 1 allows
+ /* Difference between svndiff formats 0 and 1/2 that format 1/2 allows
* compression. Uncompressed svndiff0 should also be slightly more
* effective if the compression is not required at all.
*
- * If the server cannot handle svndiff1, or compression is disabled
+ * If the server cannot handle svndiff1/2, or compression is disabled
* with the 'http-compression = no' client configuration option, fall
* back to uncompressed svndiff0 format. As a bonus, users can force
* the usage of the uncompressed format by setting the corresponding
Modified: subversion/trunk/subversion/libsvn_ra_serf/options.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/options.c?rev=1801974&r1=1801973&r2=1801974&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/options.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/options.c Fri Jul 14 15:50:03 2017
@@ -232,6 +232,11 @@ capabilities_headers_iterator_callback(v
advertise this capability (Subversion 1.10 and greater). */
session->supports_svndiff1 = TRUE;
}
+ if (svn_cstring_match_list(SVN_DAV_NS_DAV_SVN_SVNDIFF2, vals))
+ {
+ /* Same for svndiff2. */
+ session->supports_svndiff2 = TRUE;
+ }
}
/* SVN-specific headers -- if present, server supports HTTP protocol v2 */
Modified: subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h?rev=1801974&r1=1801973&r2=1801974&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h Fri Jul 14 15:50:03 2017
@@ -261,6 +261,9 @@ struct svn_ra_serf__session_t {
/* Indicates whether the server can understand svndiff version 1. */
svn_boolean_t supports_svndiff1;
+
+ /* Indicates whether the server can understand svndiff version 2. */
+ svn_boolean_t supports_svndiff2;
};
#define SVN_RA_SERF__HAVE_HTTPV2_SUPPORT(sess) ((sess)->me_resource != NULL)
Modified: subversion/trunk/subversion/libsvn_ra_serf/util.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/util.c?rev=1801974&r1=1801973&r2=1801974&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/util.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/util.c Fri Jul 14 15:50:03 2017
@@ -2030,8 +2030,11 @@ svn_ra_serf__setup_svndiff_accept_encodi
{
if (using_compression)
{
- serf_bucket_headers_setn(headers, "Accept-Encoding",
- "gzip,svndiff1;q=0.9,svndiff;q=0.8");
+ /* We are equally interested in svndiff2 and svndiff1, let the
+ server choose the wire format. */
+ serf_bucket_headers_setn(
+ headers, "Accept-Encoding",
+ "gzip,svndiff2;q=0.9,svndiff1;q=0.9,svndiff;q=0.8");
}
else
{
Modified: subversion/trunk/subversion/mod_dav_svn/repos.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/mod_dav_svn/repos.c?rev=1801974&r1=1801973&r2=1801974&view=diff
==============================================================================
--- subversion/trunk/subversion/mod_dav_svn/repos.c (original)
+++ subversion/trunk/subversion/mod_dav_svn/repos.c Fri Jul 14 15:50:03 2017
@@ -1752,6 +1752,9 @@ negotiate_encoding_prefs(request_rec *r,
necessary ones in this file. */
int i;
apr_array_header_t *encoding_prefs;
+ svn_boolean_t accepts_svndiff1 = FALSE;
+ svn_boolean_t accepts_svndiff2 = FALSE;
+
encoding_prefs = do_header_line(r->pool,
apr_table_get(r->headers_in,
"Accept-Encoding"));
@@ -1762,23 +1765,38 @@ negotiate_encoding_prefs(request_rec *r,
return;
}
- *svndiff_version = 0;
svn_sort__array(encoding_prefs, sort_encoding_pref);
for (i = 0; i < encoding_prefs->nelts; i++)
{
struct accept_rec rec = APR_ARRAY_IDX(encoding_prefs, i,
struct accept_rec);
- if (strcmp(rec.name, "svndiff1") == 0)
+ if (strcmp(rec.name, "svndiff2") == 0)
{
- *svndiff_version = 1;
- break;
+ accepts_svndiff2 = TRUE;
}
- else if (strcmp(rec.name, "svndiff") == 0)
+ else if (strcmp(rec.name, "svndiff1") == 0)
{
- *svndiff_version = 0;
- break;
+ accepts_svndiff1 = TRUE;
}
}
+
+ /* Enable svndiff2 if the client can read it, and if the server-side
+ * compression level is set to 1. Svndiff2 offers better speed and
+ * compression ratio comparable to svndiff1 with compression level 1,
+ * but with for other compression levels.
+ */
+ if (accepts_svndiff2 && dav_svn__get_compression_level(r) == 1)
+ {
+ *svndiff_version = 2;
+ }
+ else if (accepts_svndiff1)
+ {
+ *svndiff_version = 1;
+ }
+ else
+ {
+ *svndiff_version = 0;
+ }
}
Modified: subversion/trunk/subversion/mod_dav_svn/version.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/mod_dav_svn/version.c?rev=1801974&r1=1801973&r2=1801974&view=diff
==============================================================================
--- subversion/trunk/subversion/mod_dav_svn/version.c (original)
+++ subversion/trunk/subversion/mod_dav_svn/version.c Fri Jul 14 15:50:03 2017
@@ -153,6 +153,7 @@ get_vsn_options(apr_pool_t *p, apr_text_
apr_text_append(p, phdr, SVN_DAV_NS_DAV_SVN_INLINE_PROPS);
apr_text_append(p, phdr, SVN_DAV_NS_DAV_SVN_REVERSE_FILE_REVS);
apr_text_append(p, phdr, SVN_DAV_NS_DAV_SVN_SVNDIFF1);
+ apr_text_append(p, phdr, SVN_DAV_NS_DAV_SVN_SVNDIFF2);
/* Mergeinfo is a special case: here we merely say that the server
* knows how to handle mergeinfo -- whether the repository does too
* is a separate matter.