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 2010/08/03 13:38:01 UTC
svn commit: r981827 - in /subversion/branches/performance/subversion:
include/svn_ra_svn.h libsvn_ra_svn/editorp.c libsvn_ra_svn/marshal.c
libsvn_ra_svn/ra_svn.h svnserve/main.c svnserve/serve.c svnserve/server.h
Author: stefan2
Date: Tue Aug 3 11:38:01 2010
New Revision: 981827
URL: http://svn.apache.org/viewvc?rev=981827&view=rev
Log:
Make the compression level used over RA_SVN selectable by serve_params_t.
Disable wire compression entirely for level 0, i.e. skip zlib in that case.
Because level 0 is only useful for maximizing throughput in broadband LANs
(>= 1GB/s), we won't advertise the the SVNDIFF1 capability in that case, either.
Thus, clients will send plaintext data as well during commits, etc.
* subversion/svnserve/server.h
(serve_params_t): add compression_level parameter
* subversion/svnserve/serve.c
(file_rev_handler): switch to new diff API; disable compression for level 0
(serve): don't advertise SVN_RA_SVN_CAP_SVNDIFF1 capability if we
want uncompressed communication
* subversion/svnserve/main.c
(main): init new compression level parameter
* subversion/include/svn_ra_svn.h
(svn_ra_svn_create_conn2): declare new API function taking the compression level
as additional parameter
* subversion/libsvn_ra_svn/ra_svn.h
(svn_ra_svn_conn_st): add compression_level parameter
* subversion/libsvn_ra_svn/marshal.c
(svn_ra_svn_create_conn2, svn_ra_svn_compression_level): implement new API function
(svn_ra_svn_create_conn): simply wrap the new API
* subversion/libsvn_ra_svn/editorp.c
(ra_svn_apply_textdelta): switch to new diff API; disable compression for level 0
Modified:
subversion/branches/performance/subversion/include/svn_ra_svn.h
subversion/branches/performance/subversion/libsvn_ra_svn/editorp.c
subversion/branches/performance/subversion/libsvn_ra_svn/marshal.c
subversion/branches/performance/subversion/libsvn_ra_svn/ra_svn.h
subversion/branches/performance/subversion/svnserve/main.c
subversion/branches/performance/subversion/svnserve/serve.c
subversion/branches/performance/subversion/svnserve/server.h
Modified: subversion/branches/performance/subversion/include/svn_ra_svn.h
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/include/svn_ra_svn.h?rev=981827&r1=981826&r2=981827&view=diff
==============================================================================
--- subversion/branches/performance/subversion/include/svn_ra_svn.h (original)
+++ subversion/branches/performance/subversion/include/svn_ra_svn.h Tue Aug 3 11:38:01 2010
@@ -159,6 +159,18 @@ 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).
+ */
+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 for network transmissions.
*/
svn_ra_svn_conn_t *
svn_ra_svn_create_conn(apr_socket_t *sock,
@@ -183,6 +195,10 @@ 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 */
+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/branches/performance/subversion/libsvn_ra_svn/editorp.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/libsvn_ra_svn/editorp.c?rev=981827&r1=981826&r2=981827&view=diff
==============================================================================
--- subversion/branches/performance/subversion/libsvn_ra_svn/editorp.c (original)
+++ subversion/branches/performance/subversion/libsvn_ra_svn/editorp.c Tue Aug 3 11:38:01 2010
@@ -313,10 +313,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/branches/performance/subversion/libsvn_ra_svn/marshal.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/libsvn_ra_svn/marshal.c?rev=981827&r1=981826&r2=981827&view=diff
==============================================================================
--- subversion/branches/performance/subversion/libsvn_ra_svn/marshal.c (original)
+++ subversion/branches/performance/subversion/libsvn_ra_svn/marshal.c Tue Aug 3 11:38:01 2010
@@ -45,10 +45,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));
@@ -64,6 +65,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)
@@ -83,6 +85,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,
+ SVNDIFF1_COMPRESS_LEVEL, pool);
+}
+
svn_error_t *svn_ra_svn_set_capabilities(svn_ra_svn_conn_t *conn,
const apr_array_header_t *list)
{
@@ -109,6 +121,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/branches/performance/subversion/libsvn_ra_svn/ra_svn.h
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/libsvn_ra_svn/ra_svn.h?rev=981827&r1=981826&r2=981827&view=diff
==============================================================================
--- subversion/branches/performance/subversion/libsvn_ra_svn/ra_svn.h (original)
+++ subversion/branches/performance/subversion/libsvn_ra_svn/ra_svn.h Tue Aug 3 11:38:01 2010
@@ -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/branches/performance/subversion/svnserve/main.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/svnserve/main.c?rev=981827&r1=981826&r2=981827&view=diff
==============================================================================
--- subversion/branches/performance/subversion/svnserve/main.c (original)
+++ subversion/branches/performance/subversion/svnserve/main.c Tue Aug 3 11:38:01 2010
@@ -428,6 +428,7 @@ int main(int argc, const char *argv[])
params.cfg = NULL;
params.pwdb = NULL;
params.authzdb = NULL;
+ params.compression_level = SVNDIFF1_COMPRESS_LEVEL;
params.log_file = NULL;
while (1)
@@ -619,7 +620,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, ¶ms, pool));
exit(0);
}
@@ -820,7 +822,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/branches/performance/subversion/svnserve/serve.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/svnserve/serve.c?rev=981827&r1=981826&r2=981827&view=diff
==============================================================================
--- subversion/branches/performance/subversion/svnserve/serve.c (original)
+++ subversion/branches/performance/subversion/svnserve/serve.c Tue Aug 3 11:38:01 2010
@@ -2253,10 +2253,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, ""));
@@ -2978,15 +2983,25 @@ 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. */
- 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_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_PARTIAL_REPLAY));
+ if (params->compression_level > 0)
+ 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_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_PARTIAL_REPLAY));
+ else
+ SVN_ERR(svn_ra_svn_write_cmd_response(conn, pool, "nn()(wwwwww)",
+ (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_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/branches/performance/subversion/svnserve/server.h
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/svnserve/server.h?rev=981827&r1=981826&r2=981827&view=diff
==============================================================================
--- subversion/branches/performance/subversion/svnserve/server.h (original)
+++ subversion/branches/performance/subversion/svnserve/server.h Tue Aug 3 11:38:01 2010
@@ -101,6 +101,12 @@ typedef struct serve_params_t {
/* A filehandle open for writing logs to; possibly NULL. */
apr_file_t *log_file;
+
+ /* Data compression level to reduce for network traffic. If this
+ is 0, no compression should be applied and the protocol may
+ fall back to txdelta "version 0" bypassing zlib entirely.
+ Defaults to SVNDIFF1_COMPRESS_LEVEL. */
+ int compression_level;
} serve_params_t;
/* Serve the connection CONN according to the parameters PARAMS. */