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 2015/09/16 16:04:55 UTC

svn commit: r1703412 - /subversion/branches/ra_serf-stream-commit/subversion/libsvn_client/import.c

Author: kotkov
Date: Wed Sep 16 14:04:55 2015
New Revision: 1703412

URL: http://svn.apache.org/r1703412
Log:
On the ra_serf-stream-commit branch: Begin switching one of our delta editor
drives, svn_client_import5(), to using the apply_textdelta_stream() callback.

This avoids creating temporary files with svndiff during 'svn import' over
http:// and https:// protocols.  Creating these temporary files has a certain
overhead (time to write them and consuming disk space), but, what's probably
more important, creating them between the actual PUT requests can interfere
with TCP auto-tuning techniques that rely on the data being sent steadily.

A couple of my preliminary tests show difference of up to three times — i.e.,
importing 10 files, with a total size of ~50 MiB over http:// to a remote
server, took 53s with the temporary files and around 18s without them.

* subversion/libsvn_client/import.c
  (open_txdelta_baton_t): New baton.
  (send_file_contents): Move the core logic of this function, i.e., preparing
   the delta stream into ...
  (open_txdelta): ...this new function, and pass the necessary arguments via
   the callback.
  (import_file): Use apply_textdelta_stream() when driving the editor, and
   pass open_txdelta() to open the appropriate svn_txdelta_stream_t.  Drop
   the support for result checksums for now, and leave a corresponding TODO
   comment.

Modified:
    subversion/branches/ra_serf-stream-commit/subversion/libsvn_client/import.c

Modified: subversion/branches/ra_serf-stream-commit/subversion/libsvn_client/import.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra_serf-stream-commit/subversion/libsvn_client/import.c?rev=1703412&r1=1703411&r2=1703412&view=diff
==============================================================================
--- subversion/branches/ra_serf-stream-commit/subversion/libsvn_client/import.c (original)
+++ subversion/branches/ra_serf-stream-commit/subversion/libsvn_client/import.c Wed Sep 16 14:04:55 2015
@@ -73,27 +73,26 @@ typedef struct import_ctx_t
   apr_hash_t *autoprops;
 } import_ctx_t;
 
-
-/* Apply LOCAL_ABSPATH's contents (as a delta against the empty string) to
-   FILE_BATON in EDITOR.  Use POOL for any temporary allocation.
-   PROPERTIES is the set of node properties set on this file.
-
-   Fill DIGEST with the md5 checksum of the sent file; DIGEST must be
-   at least APR_MD5_DIGESTSIZE bytes long. */
+typedef struct open_txdelta_baton_t
+{
+  const char *local_abspath;
+  apr_hash_t *properties;
+} open_txdelta_baton_t;
+
+/* Open delta stream *TXDELTA_STREAM_P for the BATON->local_abspath
+   file contents (as a delta against the empty string).  Use POOL for
+   all allocations.  BATON->properties is the set of node properties
+   set on this file. */
 
 /* ### how does this compare against svn_wc_transmit_text_deltas2() ??? */
 
 static svn_error_t *
-send_file_contents(const char *local_abspath,
-                   void *file_baton,
-                   const svn_delta_editor_t *editor,
-                   apr_hash_t *properties,
-                   unsigned char *digest,
-                   apr_pool_t *pool)
+open_txdelta(svn_txdelta_stream_t **txdelta_stream_p,
+             void *baton,
+             apr_pool_t *pool)
 {
+  open_txdelta_baton_t *b = baton;
   svn_stream_t *contents;
-  svn_txdelta_window_handler_t handler;
-  void *handler_baton;
   const svn_string_t *eol_style_val = NULL, *keywords_val = NULL;
   svn_boolean_t special = FALSE;
   svn_subst_eol_style_t eol_style;
@@ -101,20 +100,16 @@ send_file_contents(const char *local_abs
   apr_hash_t *keywords;
 
   /* If there are properties, look for EOL-style and keywords ones. */
-  if (properties)
+  if (b->properties)
     {
-      eol_style_val = apr_hash_get(properties, SVN_PROP_EOL_STYLE,
+      eol_style_val = apr_hash_get(b->properties, SVN_PROP_EOL_STYLE,
                                    sizeof(SVN_PROP_EOL_STYLE) - 1);
-      keywords_val = apr_hash_get(properties, SVN_PROP_KEYWORDS,
+      keywords_val = apr_hash_get(b->properties, SVN_PROP_KEYWORDS,
                                   sizeof(SVN_PROP_KEYWORDS) - 1);
-      if (svn_hash_gets(properties, SVN_PROP_SPECIAL))
+      if (svn_hash_gets(b->properties, SVN_PROP_SPECIAL))
         special = TRUE;
     }
 
-  /* Get an editor func that wants to consume the delta stream. */
-  SVN_ERR(editor->apply_textdelta(file_baton, NULL, pool,
-                                  &handler, &handler_baton));
-
   if (eol_style_val)
     svn_subst_eol_style_from_value(&eol_style, &eol, eol_style_val->data);
   else
@@ -132,13 +127,14 @@ send_file_contents(const char *local_abs
 
   if (special)
     {
-      SVN_ERR(svn_subst_read_specialfile(&contents, local_abspath,
+      SVN_ERR(svn_subst_read_specialfile(&contents, b->local_abspath,
                                          pool, pool));
     }
   else
     {
       /* Open the working copy file. */
-      SVN_ERR(svn_stream_open_readonly(&contents, local_abspath, pool, pool));
+      SVN_ERR(svn_stream_open_readonly(&contents, b->local_abspath,
+                                       pool, pool));
 
       /* If we have EOL styles or keywords, then detranslate the file. */
       if (svn_subst_translation_required(eol_style, eol, keywords,
@@ -149,7 +145,7 @@ send_file_contents(const char *local_abs
                                     _("%s property on '%s' contains "
                                       "unrecognized EOL-style '%s'"),
                                     SVN_PROP_EOL_STYLE,
-                                    svn_dirent_local_style(local_abspath,
+                                    svn_dirent_local_style(b->local_abspath,
                                                            pool),
                                     eol_style_val->data);
 
@@ -168,10 +164,11 @@ send_file_contents(const char *local_abs
         }
     }
 
-  /* Send the file's contents to the delta-window handler. */
-  return svn_error_trace(svn_txdelta_send_stream(contents, handler,
-                                                 handler_baton, digest,
-                                                 pool));
+  /* Get the delta stream (delta against the empty string). */
+  svn_txdelta2(txdelta_stream_p, svn_stream_empty(pool),
+               contents, FALSE, pool);
+
+  return SVN_NO_ERROR;
 }
 
 
@@ -198,10 +195,9 @@ import_file(const svn_delta_editor_t *ed
 {
   void *file_baton;
   const char *mimetype = NULL;
-  unsigned char digest[APR_MD5_DIGESTSIZE];
-  const char *text_checksum;
   apr_hash_t* properties;
   apr_hash_index_t *hi;
+  open_txdelta_baton_t open_txdelta_baton;
 
   SVN_ERR(svn_path_check_valid(local_abspath, pool));
 
@@ -262,14 +258,15 @@ import_file(const svn_delta_editor_t *ed
     }
 
   /* Now, transmit the file contents. */
-  SVN_ERR(send_file_contents(local_abspath, file_baton, editor,
-                             properties, digest, pool));
+  open_txdelta_baton.local_abspath = local_abspath;
+  open_txdelta_baton.properties = properties;
+  /* ### TODO: Pass the result checksum. */
+  SVN_ERR(editor->apply_textdelta_stream(editor, file_baton, NULL, NULL,
+                                         open_txdelta, &open_txdelta_baton,
+                                         pool));
 
   /* Finally, close the file. */
-  text_checksum =
-    svn_checksum_to_cstring(svn_checksum__from_digest_md5(digest, pool), pool);
-
-  return svn_error_trace(editor->close_file(file_baton, text_checksum, pool));
+  return svn_error_trace(editor->close_file(file_baton, NULL, pool));
 }