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/06/23 15:48:35 UTC
svn commit: r1604802 - in /subversion/trunk: subversion/libsvn_fs_fs/
tools/server-side/
Author: stsp
Date: Mon Jun 23 13:48:35 2014
New Revision: 1604802
URL: http://svn.apache.org/r1604802
Log:
Switch svn_fs_fs__get_node_revision() to dual-pool paradigm.
Make some callers pass a scratch pool to reduce memory overhead.
* subversion/libsvn_fs_fs/cached_data.c
(get_node_revision_body, svn_fs_fs__get_node_revision): Switch to dual-pool.
Use scratch pool for any data that isn't returned to the caller,
in particular the call to svn_cache__set().
* subversion/libsvn_fs_fs/cached_data.h
(svn_fs_fs__get_node_revision): Update declaration.
* subversion/libsvn_fs_fs/dag.c
(get_node_revision): Use a temporary scratch pool for
svn_fs_fs__get_node_revision().
* subversion/libsvn_fs_fs/transaction.c
(create_new_txn_noderev_from_rev, svn_fs_fs__get_txn, validate_root_noderev,
svn_fs_fs__delete_node_revision): Pass two pools.
(shards_spanned, choose_delta_base): Introduce an iterpool in loops around
svn_fs_fs__get_node_revision and pass it as scratch pool.
(write_final_rev): Extend scope of an existing subpool and pass it as
scratch pool to svn_fs_fs__get_node_revision().
* subversion/libsvn_fs_fs/tree.c
(merge): Create a scratch pool for svn_fs_fs__get_node_revision() calls
grouped in an unrolled-loop fashion.
(verify_node): Pass existing iterpool as scratch pool.
* tools/server-side/svn-rep-sharing-stats.c
(process_one_revision): Pass existing scratch pool.
Modified:
subversion/trunk/subversion/libsvn_fs_fs/cached_data.c
subversion/trunk/subversion/libsvn_fs_fs/cached_data.h
subversion/trunk/subversion/libsvn_fs_fs/dag.c
subversion/trunk/subversion/libsvn_fs_fs/transaction.c
subversion/trunk/subversion/libsvn_fs_fs/tree.c
subversion/trunk/tools/server-side/svn-rep-sharing-stats.c
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=1604802&r1=1604801&r2=1604802&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/cached_data.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/cached_data.c Mon Jun 23 13:48:35 2014
@@ -285,7 +285,8 @@ static svn_error_t *
get_node_revision_body(node_revision_t **noderev_p,
svn_fs_t *fs,
const svn_fs_id_t *id,
- apr_pool_t *pool)
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
{
svn_error_t *err;
svn_boolean_t is_cached = FALSE;
@@ -298,8 +299,10 @@ get_node_revision_body(node_revision_t *
/* This is a transaction node-rev. Its storage logic is very
different from that of rev / pack files. */
err = svn_io_file_open(&file,
- svn_fs_fs__path_txn_node_rev(fs, id, pool),
- APR_READ | APR_BUFFERED, APR_OS_DEFAULT, pool);
+ svn_fs_fs__path_txn_node_rev(fs, id,
+ scratch_pool),
+ APR_READ | APR_BUFFERED, APR_OS_DEFAULT,
+ scratch_pool);
if (err)
{
if (APR_STATUS_IS_ENOENT(err->apr_err))
@@ -314,8 +317,8 @@ get_node_revision_body(node_revision_t *
SVN_ERR(svn_fs_fs__read_noderev(noderev_p,
svn_stream_from_aprfile2(file,
FALSE,
- pool),
- pool));
+ scratch_pool),
+ result_pool));
}
else
{
@@ -335,7 +338,7 @@ get_node_revision_body(node_revision_t *
&is_cached,
ffd->node_revision_cache,
&key,
- pool));
+ result_pool));
if (is_cached)
return SVN_NO_ERROR;
}
@@ -344,7 +347,7 @@ get_node_revision_body(node_revision_t *
SVN_ERR(open_and_seek_revision(&revision_file, fs,
rev_item->revision,
rev_item->number,
- pool));
+ scratch_pool));
if (svn_fs_fs__use_log_addressing(fs, rev_item->revision))
{
@@ -354,15 +357,15 @@ get_node_revision_body(node_revision_t *
rev_item->revision,
rev_item->number,
revision_file,
- pool,
- pool));
+ result_pool,
+ scratch_pool));
}
else
{
/* physical addressing mode reading, parsing and caching */
SVN_ERR(svn_fs_fs__read_noderev(noderev_p,
revision_file->stream,
- pool));
+ result_pool));
/* Workaround issue #4031: is-fresh-txn-root in revision files. */
(*noderev_p)->is_fresh_txn_root = FALSE;
@@ -372,7 +375,7 @@ get_node_revision_body(node_revision_t *
SVN_ERR(svn_cache__set(ffd->node_revision_cache,
&key,
*noderev_p,
- pool));
+ scratch_pool));
}
SVN_ERR(svn_fs_fs__close_revision_file(revision_file));
@@ -385,14 +388,16 @@ svn_error_t *
svn_fs_fs__get_node_revision(node_revision_t **noderev_p,
svn_fs_t *fs,
const svn_fs_id_t *id,
- apr_pool_t *pool)
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
{
const svn_fs_fs__id_part_t *rev_item = svn_fs_fs__id_rev_item(id);
- svn_error_t *err = get_node_revision_body(noderev_p, fs, id, pool);
+ svn_error_t *err = get_node_revision_body(noderev_p, fs, id,
+ result_pool, scratch_pool);
if (err && err->apr_err == SVN_ERR_FS_CORRUPT)
{
- svn_string_t *id_string = svn_fs_fs__id_unparse(id, pool);
+ svn_string_t *id_string = svn_fs_fs__id_unparse(id, scratch_pool);
return svn_error_createf(SVN_ERR_FS_CORRUPT, err,
"Corrupt node-revision '%s'",
id_string->data);
@@ -403,7 +408,7 @@ svn_fs_fs__get_node_revision(node_revisi
rev_item->number,
*noderev_p,
SVN_FS_FS__ITEM_TYPE_NODEREV,
- pool));
+ scratch_pool));
return svn_error_trace(err);
}
Modified: subversion/trunk/subversion/libsvn_fs_fs/cached_data.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/cached_data.h?rev=1604802&r1=1604801&r2=1604802&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/cached_data.h (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/cached_data.h Mon Jun 23 13:48:35 2014
@@ -36,7 +36,8 @@ svn_error_t *
svn_fs_fs__get_node_revision(node_revision_t **noderev_p,
svn_fs_t *fs,
const svn_fs_id_t *id,
- apr_pool_t *pool);
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool);
/* Set *ROOT_ID to the node-id for the root of revision REV in
filesystem FS. Do any allocations in POOL. */
Modified: subversion/trunk/subversion/libsvn_fs_fs/dag.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/dag.c?rev=1604802&r1=1604801&r2=1604802&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/dag.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/dag.c Mon Jun 23 13:48:35 2014
@@ -160,10 +160,13 @@ get_node_revision(node_revision_t **node
if (! node->node_revision)
{
node_revision_t *noderev;
+ apr_pool_t *scratch_pool = svn_pool_create(node->node_pool);
SVN_ERR(svn_fs_fs__get_node_revision(&noderev, node->fs,
- node->id, node->node_pool));
+ node->id, node->node_pool,
+ scratch_pool));
node->node_revision = noderev;
+ svn_pool_destroy(scratch_pool);
}
/* Now NODE->node_revision is set. */
Modified: subversion/trunk/subversion/libsvn_fs_fs/transaction.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/transaction.c?rev=1604802&r1=1604801&r2=1604802&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/transaction.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/transaction.c Mon Jun 23 13:48:35 2014
@@ -912,7 +912,7 @@ create_new_txn_noderev_from_rev(svn_fs_t
node_revision_t *noderev;
const svn_fs_fs__id_part_t *node_id, *copy_id;
- SVN_ERR(svn_fs_fs__get_node_revision(&noderev, fs, src, pool));
+ SVN_ERR(svn_fs_fs__get_node_revision(&noderev, fs, src, pool, pool));
if (svn_fs_fs__id_is_txn(noderev->id))
return svn_error_create(SVN_ERR_FS_CORRUPT, NULL,
@@ -1236,7 +1236,7 @@ svn_fs_fs__get_txn(transaction_t **txn_p
SVN_ERR(get_txn_proplist(txn->proplist, fs, txn_id, pool));
root_id = svn_fs_fs__id_txn_create_root(txn_id, pool);
- SVN_ERR(svn_fs_fs__get_node_revision(&noderev, fs, root_id, pool));
+ SVN_ERR(svn_fs_fs__get_node_revision(&noderev, fs, root_id, pool, pool));
txn->root_id = svn_fs_fs__id_copy(noderev->id, pool);
txn->base_id = svn_fs_fs__id_copy(noderev->predecessor_id, pool);
@@ -1854,13 +1854,17 @@ shards_spanned(int *spanned,
{
fs_fs_data_t *ffd = fs->fsap_data;
int shard_size = ffd->max_files_per_dir ? ffd->max_files_per_dir : 1;
+ apr_pool_t *iterpool;
int count = walk ? 1 : 0; /* The start of a walk already touches a shard. */
svn_revnum_t shard, last_shard = ffd->youngest_rev_cache / shard_size;
+ iterpool = svn_pool_create(pool);
while (walk-- && noderev->predecessor_count)
{
+ svn_pool_clear(iterpool);
SVN_ERR(svn_fs_fs__get_node_revision(&noderev, fs,
- noderev->predecessor_id, pool));
+ noderev->predecessor_id, pool,
+ iterpool));
shard = svn_fs_fs__id_rev(noderev->id) / shard_size;
if (shard != last_shard)
{
@@ -1868,6 +1872,7 @@ shards_spanned(int *spanned,
last_shard = shard;
}
}
+ svn_pool_destroy(iterpool);
*spanned = count;
return SVN_NO_ERROR;
@@ -1894,6 +1899,7 @@ choose_delta_base(representation_t **rep
int walk;
node_revision_t *base;
fs_fs_data_t *ffd = fs->fsap_data;
+ apr_pool_t *iterpool;
/* If we have no predecessors, or that one is empty, then use the empty
* stream as a base. */
@@ -1940,9 +1946,15 @@ choose_delta_base(representation_t **rep
if noderev has ten predecessors and we want the eighth file rev,
walk back two predecessors.) */
base = noderev;
+ iterpool = svn_pool_create(pool);
while ((count++) < noderev->predecessor_count)
- SVN_ERR(svn_fs_fs__get_node_revision(&base, fs,
- base->predecessor_id, pool));
+ {
+ svn_pool_clear(iterpool);
+ SVN_ERR(svn_fs_fs__get_node_revision(&base, fs,
+ base->predecessor_id, pool,
+ iterpool));
+ }
+ svn_pool_destroy(iterpool);
/* return a suitable base representation */
*rep = props ? base->prop_rep : base->data_rep;
@@ -2736,8 +2748,7 @@ validate_root_noderev(svn_fs_t *fs,
SVN_ERR(svn_fs_fs__revision_root(&head_revision, fs, head_revnum, pool));
SVN_ERR(svn_fs_fs__node_id(&head_root_id, head_revision, "/", pool));
SVN_ERR(svn_fs_fs__get_node_revision(&head_root_noderev, fs, head_root_id,
- pool));
-
+ pool, pool));
head_predecessor_count = head_root_noderev->predecessor_count;
}
@@ -2843,6 +2854,7 @@ write_final_rev(const svn_fs_id_t **new_
const svn_fs_fs__id_part_t *txn_id = svn_fs_fs__id_txn_id(id);
svn_stream_t *file_stream;
svn_checksum_ctx_t *fnv1a_checksum_ctx;
+ apr_pool_t *subpool;
*new_id_p = NULL;
@@ -2850,16 +2862,15 @@ write_final_rev(const svn_fs_id_t **new_
if (! svn_fs_fs__id_is_txn(id))
return SVN_NO_ERROR;
- SVN_ERR(svn_fs_fs__get_node_revision(&noderev, fs, id, pool));
+ subpool = svn_pool_create(pool);
+ SVN_ERR(svn_fs_fs__get_node_revision(&noderev, fs, id, pool, subpool));
if (noderev->kind == svn_node_dir)
{
- apr_pool_t *subpool;
apr_array_header_t *entries;
int i;
/* This is a directory. Write out all the children first. */
- subpool = svn_pool_create(pool);
SVN_ERR(svn_fs_fs__rep_contents_dir(&entries, fs, noderev, pool,
subpool));
@@ -2876,7 +2887,6 @@ write_final_rev(const svn_fs_id_t **new_
if (new_id && (svn_fs_fs__id_rev(new_id) == rev))
dirent->id = svn_fs_fs__id_copy(new_id, pool);
}
- svn_pool_destroy(subpool);
if (noderev->data_rep && is_txn_rep(noderev->data_rep))
{
@@ -2922,6 +2932,8 @@ write_final_rev(const svn_fs_id_t **new_
}
}
+ svn_pool_destroy(subpool);
+
/* Fix up the property reps. */
if (noderev->prop_rep && is_txn_rep(noderev->prop_rep))
{
@@ -3950,7 +3962,7 @@ svn_fs_fs__delete_node_revision(svn_fs_t
{
node_revision_t *noderev;
- SVN_ERR(svn_fs_fs__get_node_revision(&noderev, fs, id, pool));
+ SVN_ERR(svn_fs_fs__get_node_revision(&noderev, fs, id, pool, pool));
/* Delete any mutable property representation. */
if (noderev->prop_rep && is_txn_rep(noderev->prop_rep))
Modified: subversion/trunk/subversion/libsvn_fs_fs/tree.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/tree.c?rev=1604802&r1=1604801&r2=1604802&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/tree.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/tree.c Mon Jun 23 13:48:35 2014
@@ -1863,11 +1863,19 @@ merge(svn_stringbuf_t *conflict_p,
{
node_revision_t *tgt_nr, *anc_nr, *src_nr;
svn_boolean_t same;
+ apr_pool_t *scratch_pool;
/* Get node revisions for our id's. */
- SVN_ERR(svn_fs_fs__get_node_revision(&tgt_nr, fs, target_id, pool));
- SVN_ERR(svn_fs_fs__get_node_revision(&anc_nr, fs, ancestor_id, pool));
- SVN_ERR(svn_fs_fs__get_node_revision(&src_nr, fs, source_id, pool));
+ scratch_pool = svn_pool_create(pool);
+ SVN_ERR(svn_fs_fs__get_node_revision(&tgt_nr, fs, target_id, pool,
+ scratch_pool));
+ svn_pool_clear(scratch_pool);
+ SVN_ERR(svn_fs_fs__get_node_revision(&anc_nr, fs, ancestor_id, pool,
+ scratch_pool));
+ svn_pool_clear(scratch_pool);
+ SVN_ERR(svn_fs_fs__get_node_revision(&src_nr, fs, source_id, pool,
+ scratch_pool));
+ svn_pool_destroy(scratch_pool);
/* Now compare the prop-keys of the skels. Note that just because
the keys are different -doesn't- mean the proplists have
@@ -4423,7 +4431,7 @@ verify_node(dag_node_t *node,
/* access mergeinfo counter with minimal overhead */
node_revision_t *noderev;
SVN_ERR(svn_fs_fs__get_node_revision(&noderev, fs, dirent->id,
- iterpool));
+ iterpool, iterpool));
child_mergeinfo = noderev->mergeinfo_count;
}
Modified: subversion/trunk/tools/server-side/svn-rep-sharing-stats.c
URL: http://svn.apache.org/viewvc/subversion/trunk/tools/server-side/svn-rep-sharing-stats.c?rev=1604802&r1=1604801&r2=1604802&view=diff
==============================================================================
--- subversion/trunk/tools/server-side/svn-rep-sharing-stats.c (original)
+++ subversion/trunk/tools/server-side/svn-rep-sharing-stats.c Mon Jun 23 13:48:35 2014
@@ -304,7 +304,8 @@ process_one_revision(svn_fs_t *fs,
the_id = node_rev_id2;
/* Get the node_rev using the chosen node_rev_id. */
- SVN_ERR(svn_fs_fs__get_node_revision(&node_rev, fs, the_id, scratch_pool));
+ SVN_ERR(svn_fs_fs__get_node_revision(&node_rev, fs, the_id,
+ scratch_pool, scratch_pool));
/* Maybe record the sha1's. */
SVN_ERR(record(prop_reps, node_rev->prop_rep, result_pool));