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 2015/05/20 10:15:27 UTC
svn commit: r1680481 - /subversion/trunk/subversion/tests/svn_test_fs.c
Author: stefan2
Date: Wed May 20 08:15:26 2015
New Revision: 1680481
URL: http://svn.apache.org/r1680481
Log:
Reduce peak memory consumption during FS-related tests, in particular
during parallel execution.
Nothing major here; just follow the common pool usage patterns. This
also improves the signal-to-noise ratio when using the test suite to
check for pool usage issues in the FS implementations.
* subversion/tests/svn_test_fs.c
(get_dir_entries): Properly name the pool argument and use an ITERPOOL
for iteration and recursion.
(svn_test__validate_tree): Allocate everything from temporary pools as
we don't return anything. Use an ITERPOOL.
(svn_test__txn_script_exec,
svn_test__check_greek_tree,
svn_test__create_greek_tree_at): Use an ITERPOOL for iteration.
Modified:
subversion/trunk/subversion/tests/svn_test_fs.c
Modified: subversion/trunk/subversion/tests/svn_test_fs.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/svn_test_fs.c?rev=1680481&r1=1680480&r2=1680481&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/svn_test_fs.c (original)
+++ subversion/trunk/subversion/tests/svn_test_fs.c Wed May 20 08:15:26 2015
@@ -399,27 +399,30 @@ static svn_error_t *
get_dir_entries(apr_hash_t *tree_entries,
svn_fs_root_t *root,
const char *path,
- apr_pool_t *pool)
+ apr_pool_t *scratch_pool)
{
apr_hash_t *entries;
apr_hash_index_t *hi;
+ apr_pool_t *iterpool = svn_pool_create(scratch_pool);
+ apr_pool_t *result_pool = apr_hash_pool_get(tree_entries);
- SVN_ERR(svn_fs_dir_entries(&entries, root, path, pool));
+ SVN_ERR(svn_fs_dir_entries(&entries, root, path, scratch_pool));
/* Copy this list to the master list with the path prepended to the
names */
- for (hi = apr_hash_first(pool, entries); hi; hi = apr_hash_next(hi))
+ for (hi = apr_hash_first(scratch_pool, entries); hi; hi = apr_hash_next(hi))
{
void *val;
svn_fs_dirent_t *dirent;
const char *full_path;
+ svn_pool_clear(iterpool);
apr_hash_this(hi, NULL, NULL, &val);
dirent = val;
/* Calculate the full path of this entry (by appending the name
to the path thus far) */
- full_path = svn_path_join(path, dirent->name, pool);
+ full_path = svn_path_join(path, dirent->name, result_pool);
/* Now, copy this dirent to the master hash, but this time, use
the full path for the key */
@@ -427,7 +430,7 @@ get_dir_entries(apr_hash_t *tree_entries
/* If this entry is a directory, recurse into the tree. */
if (dirent->kind == svn_node_dir)
- SVN_ERR(get_dir_entries(tree_entries, root, full_path, pool));
+ SVN_ERR(get_dir_entries(tree_entries, root, full_path, iterpool));
}
return SVN_NO_ERROR;
@@ -500,6 +503,7 @@ svn_test__validate_tree(svn_fs_root_t *r
{
apr_hash_t *tree_entries, *expected_entries;
apr_pool_t *subpool = svn_pool_create(pool);
+ apr_pool_t *iterpool = svn_pool_create(pool);
svn_stringbuf_t *extra_entries = NULL;
svn_stringbuf_t *missing_entries = NULL;
svn_stringbuf_t *corrupt_entries = NULL;
@@ -509,6 +513,13 @@ svn_test__validate_tree(svn_fs_root_t *r
/* There should be no entry with this name. */
const char *na_name = "es-vee-en";
+ /* Create our master hash for storing the entries */
+ tree_entries = apr_hash_make(subpool);
+
+ /* Recursively get the whole tree */
+ SVN_ERR(get_dir_entries(tree_entries, root, "", iterpool));
+ svn_pool_clear(iterpool);
+
/* Create a hash for storing our expected entries */
expected_entries = apr_hash_make(subpool);
@@ -517,12 +528,6 @@ svn_test__validate_tree(svn_fs_root_t *r
apr_hash_set(expected_entries, entries[i].path,
APR_HASH_KEY_STRING, &(entries[i]));
- /* Create our master hash for storing the entries */
- tree_entries = apr_hash_make(pool);
-
- /* Begin the recursive directory entry dig */
- SVN_ERR(get_dir_entries(tree_entries, root, "", subpool));
-
/* For each entry in our EXPECTED_ENTRIES hash, try to find that
entry in the TREE_ENTRIES hash given us by the FS. If we find
that object, remove it from the TREE_ENTRIES. If we don't find
@@ -536,6 +541,7 @@ svn_test__validate_tree(svn_fs_root_t *r
void *val;
svn_test__tree_entry_t *entry;
+ svn_pool_clear(iterpool);
apr_hash_this(hi, &key, &keylen, &val);
entry = val;
@@ -546,7 +552,7 @@ svn_test__validate_tree(svn_fs_root_t *r
svn_error_t *err;
if ((err = validate_tree_entry(root, entry->path,
- entry->contents, subpool)))
+ entry->contents, iterpool)))
{
/* If we don't have a corrupt entries string, make one. */
if (! corrupt_entries)
@@ -627,6 +633,7 @@ svn_test__validate_tree(svn_fs_root_t *r
extra_entries ? extra_entries->data : "");
}
+ svn_pool_destroy(iterpool);
svn_pool_destroy(subpool);
return SVN_NO_ERROR;
}
@@ -675,6 +682,7 @@ svn_test__txn_script_exec(svn_fs_root_t
apr_pool_t *pool)
{
int i;
+ apr_pool_t *iterpool = svn_pool_create(pool);
/* Run through the list of edits, making the appropriate edit on
that entry in the TXN_ROOT. */
@@ -685,18 +693,19 @@ svn_test__txn_script_exec(svn_fs_root_t
int cmd = script[i].cmd;
svn_boolean_t is_dir = (param1 == 0);
+ svn_pool_clear(iterpool);
switch (cmd)
{
case 'a':
if (is_dir)
{
- SVN_ERR(svn_fs_make_dir(txn_root, path, pool));
+ SVN_ERR(svn_fs_make_dir(txn_root, path, iterpool));
}
else
{
- SVN_ERR(svn_fs_make_file(txn_root, path, pool));
+ SVN_ERR(svn_fs_make_file(txn_root, path, iterpool));
SVN_ERR(svn_test__set_file_contents(txn_root, path,
- param1, pool));
+ param1, iterpool));
}
break;
@@ -706,21 +715,21 @@ svn_test__txn_script_exec(svn_fs_root_t
svn_fs_root_t *rev_root;
svn_fs_t *fs = svn_fs_root_fs(txn_root);
- SVN_ERR(svn_fs_youngest_rev(&youngest, fs, pool));
- SVN_ERR(svn_fs_revision_root(&rev_root, fs, youngest, pool));
- SVN_ERR(svn_fs_copy(rev_root, path, txn_root, param1, pool));
+ SVN_ERR(svn_fs_youngest_rev(&youngest, fs, iterpool));
+ SVN_ERR(svn_fs_revision_root(&rev_root, fs, youngest, iterpool));
+ SVN_ERR(svn_fs_copy(rev_root, path, txn_root, param1, iterpool));
}
break;
case 'd':
- SVN_ERR(svn_fs_delete(txn_root, path, pool));
+ SVN_ERR(svn_fs_delete(txn_root, path, iterpool));
break;
case 'e':
if (! is_dir)
{
SVN_ERR(svn_test__set_file_contents(txn_root, path,
- param1, pool));
+ param1, iterpool));
}
break;
@@ -729,6 +738,7 @@ svn_test__txn_script_exec(svn_fs_root_t
}
}
+ svn_pool_destroy(iterpool);
return SVN_NO_ERROR;
}
@@ -765,21 +775,26 @@ svn_test__check_greek_tree(svn_fs_root_t
svn_stringbuf_t *rstring;
svn_stringbuf_t *content;
const struct svn_test__tree_entry_t *node;
+ apr_pool_t *iterpool = svn_pool_create(pool);
/* Loop through the list of files, checking for matching content. */
for (node = svn_test__greek_tree_nodes; node->path; node++)
{
if (node->contents)
{
- SVN_ERR(svn_fs_file_contents(&rstream, root, node->path, pool));
- SVN_ERR(svn_test__stream_to_string(&rstring, rstream, pool));
- content = svn_stringbuf_create(node->contents, pool);
+ svn_pool_clear(iterpool);
+
+ SVN_ERR(svn_fs_file_contents(&rstream, root, node->path, iterpool));
+ SVN_ERR(svn_test__stream_to_string(&rstring, rstream, iterpool));
+ content = svn_stringbuf_create(node->contents, iterpool);
if (! svn_stringbuf_compare(rstring, content))
return svn_error_createf(SVN_ERR_FS_GENERAL, NULL,
"data read != data written in file '%s'.",
node->path);
}
}
+
+ svn_pool_destroy(iterpool);
return SVN_NO_ERROR;
}
@@ -789,22 +804,28 @@ svn_test__create_greek_tree_at(svn_fs_ro
apr_pool_t *pool)
{
const struct svn_test__tree_entry_t *node;
+ apr_pool_t *iterpool = svn_pool_create(pool);
for (node = svn_test__greek_tree_nodes; node->path; node++)
{
- const char *path = svn_relpath_join(root_dir, node->path, pool);
+ const char *path;
+ svn_pool_clear(iterpool);
+
+ path = svn_relpath_join(root_dir, node->path, iterpool);
if (node->contents)
{
- SVN_ERR(svn_fs_make_file(txn_root, path, pool));
+ SVN_ERR(svn_fs_make_file(txn_root, path, iterpool));
SVN_ERR(svn_test__set_file_contents(txn_root, path, node->contents,
- pool));
+ iterpool));
}
else
{
- SVN_ERR(svn_fs_make_dir(txn_root, path, pool));
+ SVN_ERR(svn_fs_make_dir(txn_root, path, iterpool));
}
}
+
+ svn_pool_destroy(iterpool);
return SVN_NO_ERROR;
}