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 2014/01/04 00:40:10 UTC
svn commit: r1555284 - in /subversion/trunk/subversion:
include/private/svn_delta_private.h libsvn_delta/svndiff.c
libsvn_fs_fs/cached_data.c
Author: stefan2
Date: Fri Jan 3 23:40:10 2014
New Revision: 1555284
URL: http://svn.apache.org/r1555284
Log:
Running unzip is relatively expensive. Therefore skip the decoding
of txdelta windows in block_read() if we already have them in cache.
* subversion/include/private/svn_delta_private.h
(svn_txdelta__read_svndiff_window_sizes): Declare new utility API
that evaluates just enough information to let us skip the window.
* subversion/libsvn_delta/svndiff.c
(svn_txdelta__read_svndiff_window_sizes): Implement.
* subversion/libsvn_fs_fs/cached_data.c
(cache_windows): Don't decode windows that we already have in cache.
Modified:
subversion/trunk/subversion/include/private/svn_delta_private.h
subversion/trunk/subversion/libsvn_delta/svndiff.c
subversion/trunk/subversion/libsvn_fs_fs/cached_data.c
Modified: subversion/trunk/subversion/include/private/svn_delta_private.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_delta_private.h?rev=1555284&r1=1555283&r2=1555284&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_delta_private.h (original)
+++ subversion/trunk/subversion/include/private/svn_delta_private.h Fri Jan 3 23:40:10 2014
@@ -101,6 +101,17 @@ svn_delta__delta_from_editor(const svn_d
struct svn_delta__extra_baton *exb,
apr_pool_t *pool);
+/**
+ * Similar to #svn_txdelta_read_svndiff_window but only returns the window
+ * header information, i.e. does not decode the window contents.
+ */
+svn_error_t *
+svn_txdelta__read_svndiff_window_sizes(svn_txdelta_window_t **window,
+ svn_stream_t *stream,
+ int svndiff_version,
+ apr_pool_t *pool);
+
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
Modified: subversion/trunk/subversion/libsvn_delta/svndiff.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_delta/svndiff.c?rev=1555284&r1=1555283&r2=1555284&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_delta/svndiff.c (original)
+++ subversion/trunk/subversion/libsvn_delta/svndiff.c Fri Jan 3 23:40:10 2014
@@ -872,6 +872,23 @@ svn_txdelta_read_svndiff_window(svn_txde
svn_error_t *
+svn_txdelta__read_svndiff_window_sizes(svn_txdelta_window_t **window,
+ svn_stream_t *stream,
+ int svndiff_version,
+ apr_pool_t *pool)
+{
+ apr_size_t inslen, newlen;
+
+ *window = apr_pcalloc(pool, sizeof(**window));
+ SVN_ERR(read_window_header(stream, &(*window)->sview_offset,
+ &(*window)->sview_len, &(*window)->tview_len,
+ &inslen, &newlen));
+
+ return svn_error_trace(svn_stream_skip(stream, inslen + newlen));
+}
+
+
+svn_error_t *
svn_txdelta_skip_svndiff_window(apr_file_t *file,
int svndiff_version,
apr_pool_t *pool)
Modified: subversion/trunk/subversion/libsvn_fs_fs/cached_data.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/cached_data.c?rev=1555284&r1=1555283&r2=1555284&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/cached_data.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/cached_data.c Fri Jan 3 23:40:10 2014
@@ -27,6 +27,7 @@
#include "svn_hash.h"
#include "svn_ctype.h"
#include "svn_sorts.h"
+#include "private/svn_delta_private.h"
#include "private/svn_io_private.h"
#include "private/svn_sorts_private.h"
#include "private/svn_subr_private.h"
@@ -2402,12 +2403,29 @@ cache_windows(svn_filesize_t *fulltext_l
svn_txdelta_window_t *window;
apr_off_t start_offset = rs->start + rs->current;
apr_off_t end_offset;
+ svn_boolean_t found = FALSE;
- /* navigate to & read the current window */
+ /* We don't need to read the data again, if it is already in cache.
+ */
+ if (rs->window_cache)
+ {
+ window_cache_key_t key = {0};
+ SVN_ERR(svn_cache__has_key(&found, rs->window_cache,
+ get_window_key(&key, rs), pool));
+ }
+
+ /* navigate to the current window */
SVN_ERR(rs_aligned_seek(rs, NULL, start_offset, pool));
- SVN_ERR(svn_txdelta_read_svndiff_window(&window,
- rs->sfile->rfile->stream,
- rs->ver, pool));
+
+ /* Skip or actually read the window - depending on cache status. */
+ if (found)
+ SVN_ERR(svn_txdelta__read_svndiff_window_sizes(&window,
+ rs->sfile->rfile->stream,
+ rs->ver, pool));
+ else
+ SVN_ERR(svn_txdelta_read_svndiff_window(&window,
+ rs->sfile->rfile->stream,
+ rs->ver, pool));
/* aggregate expanded window size */
*fulltext_len += window->tview_len;
@@ -2421,7 +2439,8 @@ cache_windows(svn_filesize_t *fulltext_l
"the end of the representation"));
/* cache the window now */
- SVN_ERR(set_cached_window(window, rs, pool));
+ if (!found)
+ SVN_ERR(set_cached_window(window, rs, pool));
rs->chunk_index++;
}