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/01 21:36:08 UTC
svn commit: r981287 - in /subversion/branches/performance/subversion:
include/svn_delta.h libsvn_delta/svndiff.c tests/libsvn_delta/random-test.c
tests/libsvn_delta/svndiff-test.c
Author: stefan2
Date: Sun Aug 1 19:36:07 2010
New Revision: 981287
URL: http://svn.apache.org/viewvc?rev=981287&view=rev
Log:
Add compression_level argument to svn_txdelta_to_svndiff.
* subversion/include/svn_delta.h
(SVNDIFF1_COMPRESS_LEVEL): make define public; moved from svndiff.c to here
(svn_txdelta_to_svndiff3): new API function; adds compression_level parameter
* subversion/libsvn_delta/svndiff.c
(SVNDIFF1_COMPRESS_LEVEL): drop; moved to header
(NORMAL_BITS, LENGTH_BITS): drop unused defines
(encoder_baton): add compression_level member
(zlib_encode): add compression_level parameter and pass it to zlib
(window_handler): pass compression level from encoder baton to zlib_encode
(svn_txdelta_to_svndiff3): implement
(svn_txdelta_to_svndiff2): implement as wrapper around svn_txdelta_to_svndiff3
(svn_txdelta_to_svndiff): call svn_txdelta_to_svndiff3
* subversion/tests/libsvn_delta/random-test.c
(random_test, do_random_combine_test): use newest API variant with
different compression levels
* subversion/tests/libsvn_delta/svndiff-test.c
(main): use newest API variant
Modified:
subversion/branches/performance/subversion/include/svn_delta.h
subversion/branches/performance/subversion/libsvn_delta/svndiff.c
subversion/branches/performance/subversion/tests/libsvn_delta/random-test.c
subversion/branches/performance/subversion/tests/libsvn_delta/svndiff-test.c
Modified: subversion/branches/performance/subversion/include/svn_delta.h
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/include/svn_delta.h?rev=981287&r1=981286&r2=981287&view=diff
==============================================================================
--- subversion/branches/performance/subversion/include/svn_delta.h (original)
+++ subversion/branches/performance/subversion/include/svn_delta.h Sun Aug 1 19:36:07 2010
@@ -49,6 +49,12 @@ extern "C" {
+/** This is the default compression level we pass to zlib. It
+ * should be between 0 and 9, with higher numbers being greater
+ * compression.
+ */
+#define SVNDIFF1_COMPRESS_LEVEL 5
+
/**
* Get libsvn_delta version information.
*
@@ -453,11 +459,25 @@ svn_txdelta_apply(svn_stream_t *source,
* Allocation takes place in a sub-pool of @a pool. On return, @a *handler
* is set to a window handler function and @a *handler_baton is set to
* the value to pass as the @a baton argument to @a *handler. The svndiff
- * version is @a svndiff_version.
+ * version is @a svndiff_version. @a compression_level is the zlib
+ * compression level from 0 (no compression) and 9 (maximum compression).
*
- * @since New in 1.4.
+ * @since New in 1.7.
*/
void
+svn_txdelta_to_svndiff3(svn_txdelta_window_handler_t *handler,
+ void **handler_baton,
+ svn_stream_t *output,
+ int svndiff_version,
+ int compression_level,
+ apr_pool_t *pool);
+
+ /** Similar to svn_txdelta_to_svndiff3, but always using the SVN default
+ * compression level (@ref SVNDIFF1_COMPRESS_LEVEL).
+ *
+ * @since New in 1.4.
+ */
+void
svn_txdelta_to_svndiff2(svn_txdelta_window_handler_t *handler,
void **handler_baton,
svn_stream_t *output,
Modified: subversion/branches/performance/subversion/libsvn_delta/svndiff.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/libsvn_delta/svndiff.c?rev=981287&r1=981286&r2=981287&view=diff
==============================================================================
--- subversion/branches/performance/subversion/libsvn_delta/svndiff.c (original)
+++ subversion/branches/performance/subversion/libsvn_delta/svndiff.c Sun Aug 1 19:36:07 2010
@@ -40,23 +40,16 @@
be compressed using zlib as a secondary compressor. */
#define MIN_COMPRESS_SIZE 512
-/* For svndiff, this is the compression level we pass to zlib. It
- should be between 0 and 9, with higher numbers being greater
- compression. */
-#define SVNDIFF1_COMPRESS_LEVEL 5
-#define NORMAL_BITS 7
-#define LENGTH_BITS 5
-
-
/* ----- Text delta to svndiff ----- */
/* We make one of these and get it passed back to us in calls to the
window handler. We only use it to record the write function and
- baton passed to svn_txdelta_to_svndiff2(). */
+ baton passed to svn_txdelta_to_svndiff3(). */
struct encoder_baton {
svn_stream_t *output;
svn_boolean_t header_done;
int version;
+ int compression_level;
apr_pool_t *pool;
};
@@ -138,7 +131,10 @@ append_encoded_int(svn_stringbuf_t *head
version of IN was no smaller than the original IN, OUT will be a copy
of IN with the size prepended as an integer. */
static svn_error_t *
-zlib_encode(const char *data, apr_size_t len, svn_stringbuf_t *out)
+zlib_encode(const char *data,
+ apr_size_t len,
+ svn_stringbuf_t *out,
+ int compression_level)
{
unsigned long endlen;
apr_size_t intlen;
@@ -157,7 +153,7 @@ zlib_encode(const char *data, apr_size_t
if (compress2((unsigned char *)out->data + intlen, &endlen,
(const unsigned char *)data, len,
- SVNDIFF1_COMPRESS_LEVEL) != Z_OK)
+ compression_level) != Z_OK)
return svn_error_create(SVN_ERR_SVNDIFF_INVALID_COMPRESSED_DATA,
NULL,
_("Compression of svndiff data failed"));
@@ -243,7 +239,8 @@ window_handler(svn_txdelta_window_t *win
append_encoded_int(header, window->tview_len);
if (eb->version == 1)
{
- SVN_ERR(zlib_encode(instructions->data, instructions->len, i1));
+ SVN_ERR(zlib_encode(instructions->data, instructions->len,
+ i1, eb->compression_level));
instructions = i1;
}
append_encoded_int(header, instructions->len);
@@ -252,7 +249,7 @@ window_handler(svn_txdelta_window_t *win
svn_stringbuf_t *temp = svn_stringbuf_create("", pool);
svn_string_t *tempstr = svn_string_create("", pool);
SVN_ERR(zlib_encode(window->new_data->data, window->new_data->len,
- temp));
+ temp, eb->compression_level));
tempstr->data = temp->data;
tempstr->len = temp->len;
newdata = tempstr;
@@ -281,10 +278,11 @@ window_handler(svn_txdelta_window_t *win
}
void
-svn_txdelta_to_svndiff2(svn_txdelta_window_handler_t *handler,
+svn_txdelta_to_svndiff3(svn_txdelta_window_handler_t *handler,
void **handler_baton,
svn_stream_t *output,
int svndiff_version,
+ int compression_level,
apr_pool_t *pool)
{
apr_pool_t *subpool = svn_pool_create(pool);
@@ -295,18 +293,31 @@ svn_txdelta_to_svndiff2(svn_txdelta_wind
eb->header_done = FALSE;
eb->pool = subpool;
eb->version = svndiff_version;
+ eb->compression_level = compression_level;
*handler = window_handler;
*handler_baton = eb;
}
void
+svn_txdelta_to_svndiff2(svn_txdelta_window_handler_t *handler,
+ void **handler_baton,
+ svn_stream_t *output,
+ int svndiff_version,
+ apr_pool_t *pool)
+{
+ svn_txdelta_to_svndiff3(handler, handler_baton, output,
+ svndiff_version, SVNDIFF1_COMPRESS_LEVEL, pool);
+}
+
+void
svn_txdelta_to_svndiff(svn_stream_t *output,
apr_pool_t *pool,
svn_txdelta_window_handler_t *handler,
void **handler_baton)
{
- svn_txdelta_to_svndiff2(handler, handler_baton, output, 0, pool);
+ svn_txdelta_to_svndiff3(handler, handler_baton, output,
+ 0, SVNDIFF1_COMPRESS_LEVEL, pool);
}
Modified: subversion/branches/performance/subversion/tests/libsvn_delta/random-test.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/tests/libsvn_delta/random-test.c?rev=981287&r1=981286&r2=981287&view=diff
==============================================================================
--- subversion/branches/performance/subversion/tests/libsvn_delta/random-test.c (original)
+++ subversion/branches/performance/subversion/tests/libsvn_delta/random-test.c Sun Aug 1 19:36:07 2010
@@ -330,8 +330,9 @@ random_test(apr_pool_t *pool)
stream = svn_txdelta_parse_svndiff(handler, handler_baton, TRUE,
delta_pool);
- /* Make stage 2: encode the text delta in svndiff format. */
- svn_txdelta_to_svndiff2(&handler, &handler_baton, stream, 1,
+ /* Make stage 2: encode the text delta in svndiff format using
+ varying compression levels. */
+ svn_txdelta_to_svndiff3(&handler, &handler_baton, stream, 1, i % 10,
delta_pool);
/* Make stage 1: create the text delta. */
@@ -412,8 +413,9 @@ do_random_combine_test(apr_pool_t *pool,
stream = svn_txdelta_parse_svndiff(handler, handler_baton, TRUE,
delta_pool);
- /* Make stage 2: encode the text delta in svndiff format. */
- svn_txdelta_to_svndiff2(&handler, &handler_baton, stream, 1,
+ /* Make stage 2: encode the text delta in svndiff format using
+ varying compression levels. */
+ svn_txdelta_to_svndiff3(&handler, &handler_baton, stream, 1, i % 10,
delta_pool);
/* Make stage 1: create the text deltas. */
Modified: subversion/branches/performance/subversion/tests/libsvn_delta/svndiff-test.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/tests/libsvn_delta/svndiff-test.c?rev=981287&r1=981286&r2=981287&view=diff
==============================================================================
--- subversion/branches/performance/subversion/tests/libsvn_delta/svndiff-test.c (original)
+++ subversion/branches/performance/subversion/tests/libsvn_delta/svndiff-test.c Sun Aug 1 19:36:07 2010
@@ -89,8 +89,9 @@ main(int argc, char **argv)
#else
encoder = svn_base64_encode(stdout_stream, pool);
#endif
- svn_txdelta_to_svndiff2(&svndiff_handler, &svndiff_baton,
- encoder, version, pool);
+ /* use maximum compression level */
+ svn_txdelta_to_svndiff3(&svndiff_handler, &svndiff_baton,
+ encoder, version, 9, pool);
err = svn_txdelta_send_txstream(txdelta_stream,
svndiff_handler,
svndiff_baton,