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 2012/09/21 10:40:53 UTC

svn commit: r1388375 - in /subversion/branches/10Gb/subversion: include/svn_ra_svn.h libsvn_ra_svn/client.c libsvn_ra_svn/editorp.c libsvn_ra_svn/marshal.c libsvn_ra_svn/ra_svn.h svnserve/main.c svnserve/server.h

Author: stefan2
Date: Fri Sep 21 08:40:53 2012
New Revision: 1388375

URL: http://svn.apache.org/viewvc?rev=1388375&view=rev
Log:
On the 10Gb branch: SVN collects data into a buffer before actually
transmitting it.  In most cases it is thus sufficient to check for
incoming abortion requests only once after transmitting data.

This patch introduces yet another svnserve parameter.  When set to 0,
we will always check for abortion requests - even if no data was sent.
Otherwise, the specified amount of data has to be sent between checks.

* subversion/libsvn_ra_svn/ra_svn.h
  (svn_ra_svn_conn_st): add abortion check control state; insert comments

* subversion/include/svn_ra_svn.h
  (svn_ra_svn_create_conn3): add error_check_interval parameter

* subversion/libsvn_ra_svn/marshal.c
  (svn_ra_svn_create_conn3): init additional connection state
  (writebuf_output): update abortion check control state

* subversion/libsvn_ra_svn/editorp.c
  (check_for_error): call check only at certain intervals
  (check_for_error_internal): actual abortion check; handle counters

* subversion/libsvn_ra_svn/client.c
  (handle_child_process_error,
   make_tunnel,
   open_session): update callers

* subversion/svnserve/server.h
  (serve_params_t): extend parameter set

* subversion/svnserve/main.c
  (SVNSERVE_OPT_ERROR_CHECK_INTERVAL): new CL option
  (svnserve__options): define it here
  (main): parse it and pass it on

Modified:
    subversion/branches/10Gb/subversion/include/svn_ra_svn.h
    subversion/branches/10Gb/subversion/libsvn_ra_svn/client.c
    subversion/branches/10Gb/subversion/libsvn_ra_svn/editorp.c
    subversion/branches/10Gb/subversion/libsvn_ra_svn/marshal.c
    subversion/branches/10Gb/subversion/libsvn_ra_svn/ra_svn.h
    subversion/branches/10Gb/subversion/svnserve/main.c
    subversion/branches/10Gb/subversion/svnserve/server.h

Modified: subversion/branches/10Gb/subversion/include/svn_ra_svn.h
URL: http://svn.apache.org/viewvc/subversion/branches/10Gb/subversion/include/svn_ra_svn.h?rev=1388375&r1=1388374&r2=1388375&view=diff
==============================================================================
--- subversion/branches/10Gb/subversion/include/svn_ra_svn.h (original)
+++ subversion/branches/10Gb/subversion/include/svn_ra_svn.h Fri Sep 21 08:40:53 2012
@@ -198,8 +198,15 @@ svn_ra_svn__set_shim_callbacks(svn_ra_sv
  * 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).
+ * @a compression_level specifies the desired network data compression
+ * level (zlib) from 0 (no compression) to 9 (best but slowest).
+ *
+ * To reduce the overhead of checking for cancellation requests from the
+ * data receiver, set @a error_check_interval to some non-zero value.
+ * It defines the number of bytes that must have been sent since the last
+ * check before the next check will be made.
+ *
+ * Allocate the result in @a pool.
  *
  * @since New in 1.9.
  */
@@ -208,10 +215,11 @@ svn_ra_svn_conn_t *svn_ra_svn_create_con
                                            apr_file_t *out_file,
                                            int compression_level,
                                            apr_size_t zero_copy_limit,
+                                           apr_size_t error_check_interval,
                                            apr_pool_t *pool);
 
 /** Similar to svn_ra_svn_create_conn3() but disables the zero copy code
- * path.
+ * path and sets the error checking interval to 0.
  *
  * @since New in 1.7.
  *

Modified: subversion/branches/10Gb/subversion/libsvn_ra_svn/client.c
URL: http://svn.apache.org/viewvc/subversion/branches/10Gb/subversion/libsvn_ra_svn/client.c?rev=1388375&r1=1388374&r2=1388375&view=diff
==============================================================================
--- subversion/branches/10Gb/subversion/libsvn_ra_svn/client.c (original)
+++ subversion/branches/10Gb/subversion/libsvn_ra_svn/client.c Fri Sep 21 08:40:53 2012
@@ -456,7 +456,7 @@ static void handle_child_process_error(a
 
   conn = svn_ra_svn_create_conn3(NULL, in_file, out_file,
                                  SVN_DELTA_COMPRESSION_LEVEL_DEFAULT, 0,
-                                 pool);
+                                 0, pool);
   err = svn_error_wrap_apr(status, _("Error in child process: %s"), desc);
   svn_error_clear(svn_ra_svn_write_cmd_failure(conn, pool, err));
   svn_error_clear(err);
@@ -525,7 +525,7 @@ static svn_error_t *make_tunnel(const ch
   /* Guard against dotfile output to stdout on the server. */
   *conn = svn_ra_svn_create_conn3(NULL, proc->out, proc->in,
                                   SVN_DELTA_COMPRESSION_LEVEL_DEFAULT,
-                                  0, pool);
+                                  0, 0, pool);
   err = svn_ra_svn_skip_leading_garbage(*conn, pool);
   if (err)
     return svn_error_quick_wrap(
@@ -596,7 +596,7 @@ static svn_error_t *open_session(svn_ra_
       SVN_ERR(make_connection(uri->hostname, uri->port, &sock, pool));
       conn = svn_ra_svn_create_conn3(sock, NULL, NULL,
                                      SVN_DELTA_COMPRESSION_LEVEL_DEFAULT,
-                                     0, pool);
+                                     0, 0, pool);
     }
 
   /* Make sure we set conn->session before reading from it,

Modified: subversion/branches/10Gb/subversion/libsvn_ra_svn/editorp.c
URL: http://svn.apache.org/viewvc/subversion/branches/10Gb/subversion/libsvn_ra_svn/editorp.c?rev=1388375&r1=1388374&r2=1388375&view=diff
==============================================================================
--- subversion/branches/10Gb/subversion/libsvn_ra_svn/editorp.c (original)
+++ subversion/branches/10Gb/subversion/libsvn_ra_svn/editorp.c Fri Sep 21 08:40:53 2012
@@ -121,12 +121,22 @@ static ra_svn_baton_t *ra_svn_make_baton
 
 /* Check for an early error status report from the consumer.  If we
  * get one, abort the edit and return the error. */
-static svn_error_t *check_for_error(ra_svn_edit_baton_t *eb, apr_pool_t *pool)
+static svn_error_t *
+check_for_error_internal(ra_svn_edit_baton_t *eb, apr_pool_t *pool)
 {
   SVN_ERR_ASSERT(!eb->got_status);
+
+  /* reset TX counter */
+  eb->conn->written_since_error_check = 0;
+
+  /* if we weren't asked to always check, wait for at least the next TX */
+  eb->conn->may_check_for_error = eb->conn->error_check_interval == 0;
+
+  /* any incoming data? */
   if (svn_ra_svn__input_waiting(eb->conn, pool))
     {
       eb->got_status = TRUE;
+
       SVN_ERR(svn_ra_svn_write_templated_cmd(eb->conn, pool, svn_ra_svn_cmd_abort_edit));
       SVN_ERR(svn_ra_svn_read_cmd_response(eb->conn, pool, ""));
       /* We shouldn't get here if the consumer is doing its job. */
@@ -136,6 +146,14 @@ static svn_error_t *check_for_error(ra_s
   return SVN_NO_ERROR;
 }
 
+static svn_error_t *
+check_for_error(ra_svn_edit_baton_t *eb, apr_pool_t *pool)
+{
+  return eb->conn->may_check_for_error
+    ? check_for_error_internal(eb, pool)
+    : SVN_NO_ERROR;
+}
+
 static svn_error_t *ra_svn_target_rev(void *edit_baton, svn_revnum_t rev,
                                       apr_pool_t *pool)
 {

Modified: subversion/branches/10Gb/subversion/libsvn_ra_svn/marshal.c
URL: http://svn.apache.org/viewvc/subversion/branches/10Gb/subversion/libsvn_ra_svn/marshal.c?rev=1388375&r1=1388374&r2=1388375&view=diff
==============================================================================
--- subversion/branches/10Gb/subversion/libsvn_ra_svn/marshal.c (original)
+++ subversion/branches/10Gb/subversion/libsvn_ra_svn/marshal.c Fri Sep 21 08:40:53 2012
@@ -61,6 +61,7 @@ svn_ra_svn_conn_t *svn_ra_svn_create_con
                                            apr_file_t *out_file,
                                            int compression_level,
                                            apr_size_t zero_copy_limit,
+                                           apr_size_t error_check_interval,
                                            apr_pool_t *pool)
 {
   svn_ra_svn_conn_t *conn = apr_palloc(pool, sizeof(*conn));
@@ -74,6 +75,9 @@ svn_ra_svn_conn_t *svn_ra_svn_create_con
   conn->read_ptr = conn->read_buf;
   conn->read_end = conn->read_buf;
   conn->write_pos = 0;
+  conn->written_since_error_check = 0;
+  conn->error_check_interval = error_check_interval;
+  conn->may_check_for_error = error_check_interval == 0;
   conn->block_handler = NULL;
   conn->block_baton = NULL;
   conn->capabilities = apr_hash_make(pool);
@@ -105,7 +109,7 @@ svn_ra_svn_conn_t *svn_ra_svn_create_con
                                            apr_pool_t *pool)
 {
   return svn_ra_svn_create_conn3(sock, in_file, out_file,
-                                 compression_level, 0, pool);
+                                 compression_level, 0, 0, pool);
 }
 
 /* backward-compatible implementation using the default compression level */
@@ -115,7 +119,7 @@ svn_ra_svn_conn_t *svn_ra_svn_create_con
                                           apr_pool_t *pool)
 {
   return svn_ra_svn_create_conn3(sock, in_file, out_file,
-                                 SVN_DELTA_COMPRESSION_LEVEL_DEFAULT, 0,
+                                 SVN_DELTA_COMPRESSION_LEVEL_DEFAULT, 0, 0,
                                  pool);
 }
 
@@ -242,6 +246,10 @@ static svn_error_t *writebuf_output(svn_
         }
     }
 
+  conn->written_since_error_check += len;
+  conn->may_check_for_error
+    = conn->written_since_error_check >= conn->error_check_interval;
+
   if (subpool)
     svn_pool_destroy(subpool);
   return SVN_NO_ERROR;

Modified: subversion/branches/10Gb/subversion/libsvn_ra_svn/ra_svn.h
URL: http://svn.apache.org/viewvc/subversion/branches/10Gb/subversion/libsvn_ra_svn/ra_svn.h?rev=1388375&r1=1388374&r2=1388375&view=diff
==============================================================================
--- subversion/branches/10Gb/subversion/libsvn_ra_svn/ra_svn.h (original)
+++ subversion/branches/10Gb/subversion/libsvn_ra_svn/ra_svn.h Fri Sep 21 08:40:53 2012
@@ -75,20 +75,39 @@ struct svn_ra_svn_conn_st {
   apr_socket_t *sock;
   svn_boolean_t encrypted;
 #endif
+
+  /* I/O buffers */
   char read_buf[SVN_RA_SVN__READBUF_SIZE];
   char *read_ptr;
   char *read_end;
   char write_buf[SVN_RA_SVN__WRITEBUF_SIZE];
   apr_size_t write_pos;
+
+  /* abortion check control */
+  apr_size_t written_since_error_check;
+  apr_size_t error_check_interval;
+  svn_boolean_t may_check_for_error;
+
+  /* repository info */
   const char *uuid;
   const char *repos_root;
+
+  /* TX block notification target */
   ra_svn_block_handler_t block_handler;
   void *block_baton;
+
+  /* server settings */
   apr_hash_t *capabilities;
   int compression_level;
   apr_size_t zero_copy_limit;
+
+  /* who's on the other side of the connection? */
   char *remote_ip;
+
+  /* EV2 support*/
   svn_delta_shim_callbacks_t *shim_callbacks;
+
+  /* our pool */
   apr_pool_t *pool;
 };
 

Modified: subversion/branches/10Gb/subversion/svnserve/main.c
URL: http://svn.apache.org/viewvc/subversion/branches/10Gb/subversion/svnserve/main.c?rev=1388375&r1=1388374&r2=1388375&view=diff
==============================================================================
--- subversion/branches/10Gb/subversion/svnserve/main.c (original)
+++ subversion/branches/10Gb/subversion/svnserve/main.c Fri Sep 21 08:40:53 2012
@@ -150,6 +150,7 @@ void winservice_notify_stop(void)
 #define SVNSERVE_OPT_CACHE_REVPROPS  267
 #define SVNSERVE_OPT_SINGLE_CONN     268
 #define SVNSERVE_OPT_ZERO_COPY_LIMIT 269
+#define SVNSERVE_OPT_ERROR_CHECK_INTERVAL 270
 
 static const apr_getopt_option_t svnserve__options[] =
   {
@@ -246,6 +247,12 @@ static const apr_getopt_option_t svnserv
         "Default is 0 (optimization disabled).\n"
         "                             "
         "[used for FSFS repositories only]")},
+    {"error-check-interval", SVNSERVE_OPT_ERROR_CHECK_INTERVAL, 1,
+     N_("minimum amount of bytes to send between checks\n"
+        "                             "
+        "for cancellation requests from clients.\n"
+        "                             "
+        "Default is 4096.")},
 #ifdef CONNECTION_HAVE_THREAD_OPTION
     /* ### Making the assumption here that WIN32 never has fork and so
      * ### this option never exists when --service exists. */
@@ -509,6 +516,7 @@ int main(int argc, const char *argv[])
   params.cache_txdeltas = FALSE;
   params.cache_revprops = FALSE;
   params.zero_copy_limit = 0;
+  params.error_check_interval = 4096;
 
   while (1)
     {
@@ -661,6 +669,10 @@ int main(int argc, const char *argv[])
           params.zero_copy_limit = (apr_size_t)apr_strtoi64(arg, NULL, 0);
           break;
 
+        case SVNSERVE_OPT_ERROR_CHECK_INTERVAL:
+          params.error_check_interval = (apr_size_t)apr_strtoi64(arg, NULL, 0);
+          break;
+
 #ifdef WIN32
         case SVNSERVE_OPT_SERVICE:
           if (run_mode != run_mode_service)
@@ -774,6 +786,7 @@ int main(int argc, const char *argv[])
       conn = svn_ra_svn_create_conn3(NULL, in_file, out_file,
                                      params.compression_level,
                                      params.zero_copy_limit,
+                                     params.error_check_interval,
                                      connection_pool);
       svn_error_clear(serve(conn, &params, connection_pool));
       exit(0);
@@ -1008,6 +1021,7 @@ int main(int argc, const char *argv[])
       conn = svn_ra_svn_create_conn3(usock, NULL, NULL,
                                      params.compression_level,
                                      params.zero_copy_limit,
+                                     params.error_check_interval,
                                      connection_pool);
 
       if (run_mode == run_mode_listen_once)

Modified: subversion/branches/10Gb/subversion/svnserve/server.h
URL: http://svn.apache.org/viewvc/subversion/branches/10Gb/subversion/svnserve/server.h?rev=1388375&r1=1388374&r2=1388375&view=diff
==============================================================================
--- subversion/branches/10Gb/subversion/svnserve/server.h (original)
+++ subversion/branches/10Gb/subversion/svnserve/server.h Fri Sep 21 08:40:53 2012
@@ -131,6 +131,10 @@ typedef struct serve_params_t {
   /* Item size up to which we use the zero-copy code path to transmit
      them over the network.  0 disables that code path. */
   apr_size_t zero_copy_limit;
+
+  /* Amount of data to send between checks for cancellation requests
+     coming in from the client. */
+  apr_size_t error_check_interval;
 } serve_params_t;
 
 /* Serve the connection CONN according to the parameters PARAMS. */