[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] Editor txdelta interface (#510)

From: Chia-liang Kao <clkao_at_clkao.org>
Date: 2003-08-17 11:42:45 CEST

Hi,

As I look at issue 510, I didn't find a consensus made after skimming the
archive. Since the code base has been much larger than the time the issue
was filed, I think an incremental migration for the api change would be
less painful than a change merge at a time. (how many editors and drivers
do we have in the tree now?)

the attached patch makes #913 over local a bit faster,
doing import of the freebsd stable kernel: (90M, ~8000 files)
time svn import -q /usr/src/sys file:///home/clkao/tmp/svnbsd/stable -m import

before the change:
75.770u 17.921s 2:48.54 55.5% 102+11815k 7827+102270io 2pf+0w

after the change:
60.948u 17.304s 2:31.05 51.7% 102+7579k 1+103314io 0pf+0w

But I'd like to know if people think #510 should be fixed as the way
Greg described so I could go on.

log message:

Preliminary changes for issue 510. Provide an inverted callback function
`apply_delta' in addition to editor->apply_textdelta.

* subversion/include/svn_delta.h
  (svn_delta_type): New.
  (svn_delta_editor_t): Add apply_delta callback.

* subversion/libsvn_client/commit.c
  (send_file_contents): If editr->apply_delta is set, use the new interface.

* subversion/libsvn_repos/commit.c
  (apply_delta): New.

* subversion/libsvn_delta/default_editor.c
  (default_editor): assign NULL to apply_delta.

Index: subversion/include/svn_delta.h
===================================================================
--- subversion/include/svn_delta.h (revision 6751)
+++ subversion/include/svn_delta.h (working copy)
@@ -520,6 +520,11 @@
  * have the proper lifetime). In general, it is recommended to simply
  * avoid keeping a parent directory baton in a file baton.
  */
+enum svn_delta_type {
+ svn_delta_fulltext,
+ svn_delta_delta,
+};
+
 typedef struct
 {
   /** Set the target revision for this edit to @a target_revision. This
@@ -655,6 +660,23 @@
                              apr_pool_t *file_pool,
                              void **file_baton);
 
+ /** Apply a text delta or a fulltext.
+ *
+ * @a file_baton indicates the file we're creating or updating, and the
+ * ancestor file on which it is based; it is the baton set by some
+ * prior @c add_file or @c open_file callback.
+ *
+ * @a base_stream might be NULL if @ type is @c svn_delta_fulltext.
+ * @a data_stream is @c svn_txdelta_stream_t if @ type is @c
+ * svn_delta_delta.
+ */
+
+ svn_error_t *(*apply_delta) (void *filebaton,
+ svn_stream_t *base_stream,
+ svn_stream_t *data_stream,
+ enum svn_delta_type type,
+ apr_pool_t *pool);
+
   /** Apply a text delta, yielding the new revision of a file.
    *
    * @a file_baton indicates the file we're creating or updating, and the
Index: subversion/libsvn_client/commit.c
===================================================================
--- subversion/libsvn_client/commit.c (revision 6751)
+++ subversion/libsvn_client/commit.c (working copy)
@@ -67,14 +67,22 @@
   /* Get a readable stream of the file's contents. */
   contents = svn_stream_from_aprfile (f, pool);
 
- /* Get an editor func that wants to consume the delta stream. */
- SVN_ERR (editor->apply_textdelta (file_baton, NULL, pool,
- &handler, &handler_baton));
+ if (editor->apply_delta)
+ {
+ SVN_ERR (editor->apply_delta (file_baton, NULL, contents,
+ svn_delta_fulltext, pool));
+ SVN_ERR (svn_io_file_checksum (digest, path, pool));
+ }
+ else
+ {
+ /* Get an editor func that wants to consume the delta stream. */
+ SVN_ERR (editor->apply_textdelta (file_baton, NULL, pool,
+ &handler, &handler_baton));
 
- /* Send the file's contents to the delta-window handler. */
- SVN_ERR (svn_txdelta_send_stream (contents, handler, handler_baton,
- digest, pool));
-
+ /* Send the file's contents to the delta-window handler. */
+ SVN_ERR (svn_txdelta_send_stream (contents, handler, handler_baton,
+ digest, pool));
+ }
   /* Close the file. */
   apr_err = apr_file_close (f);
   if (apr_err)
Index: subversion/libsvn_repos/commit.c
===================================================================
--- subversion/libsvn_repos/commit.c (revision 6751)
+++ subversion/libsvn_repos/commit.c (working copy)
@@ -312,6 +312,56 @@
 
 
 static svn_error_t *
+apply_delta (void *file_baton,
+ svn_stream_t *base_stream,
+ svn_stream_t *data_stream,
+ enum svn_delta_type type,
+ apr_pool_t *pool)
+{
+ struct file_baton *fb = file_baton;
+
+ if (type == svn_delta_fulltext)
+ {
+ svn_stream_t *file_stream;
+ char buf[SVN_STREAM_CHUNK_SIZE];
+
+ SVN_ERR (svn_fs_apply_text (&file_stream,
+ fb->edit_baton->txn_root,
+ fb->path,
+ NULL,
+ pool));
+
+ while (1)
+ {
+ apr_size_t len = SVN_STREAM_CHUNK_SIZE;
+ SVN_ERR (svn_stream_read (data_stream, buf, &len));
+ if (len <= 0)
+ break;
+
+ SVN_ERR (svn_stream_write (file_stream, buf, &len));
+ }
+ SVN_ERR (svn_stream_close (file_stream));
+ }
+ else if (type == svn_delta_delta)
+ {
+ svn_txdelta_window_handler_t delta_handler;
+ void *delta_handler_baton;
+ SVN_ERR (svn_fs_apply_textdelta (&delta_handler,
+ &delta_handler_baton,
+ fb->edit_baton->txn_root,
+ fb->path,
+ NULL, NULL, pool));
+
+ SVN_ERR (svn_txdelta_send_txstream (data_stream,
+ delta_handler,
+ delta_handler_baton,
+ pool));
+ }
+
+ return SVN_NO_ERROR;
+}
+
+static svn_error_t *
 apply_textdelta (void *file_baton,
                  const char *base_checksum,
                  apr_pool_t *pool,
@@ -613,6 +663,7 @@
   e->add_file = add_file;
   e->open_file = open_file;
   e->close_file = close_file;
+ e->apply_delta = apply_delta;
   e->apply_textdelta = apply_textdelta;
   e->change_file_prop = change_file_prop;
   e->close_edit = close_edit;
Index: subversion/libsvn_delta/default_editor.c
===================================================================
--- subversion/libsvn_delta/default_editor.c (revision 6751)
+++ subversion/libsvn_delta/default_editor.c (working copy)
@@ -135,6 +135,7 @@
   single_baton_func,
   add_item,
   open_item,
+ NULL,
   apply_textdelta,
   change_prop,
   close_file,

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sun Aug 17 11:43:40 2003

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.