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/10/24 16:24:01 UTC

svn commit: r1710344 - in /subversion/trunk/subversion/tests: libsvn_fs/fs-test.c svn_test_fs.c

Author: stefan2
Date: Sat Oct 24 14:24:01 2015
New Revision: 1710344

URL: http://svn.apache.org/viewvc?rev=1710344&view=rev
Log:
Tighten the memory pool usage in our FS tests.

This is not so much about absolute memory usage etc. but about a better
signal-noise-ratio when profiling for pool usage issues in the FS backend.
Also, cleaning up pools early and reusing them may uncover object lifetime
issues that "normal" API users might encounter.

* subversion/tests/libsvn_fs/fs-test.c
  (txn_names_are_not_reused_helper1): We created many transaction objects.
                                      Clean them up as soon as possible.
  (check_entry): Directories may be large-ish. Make sure that multiple calls
                 to this simple predicate function do not build up a large
                 pool. 
  (closest_copy_test): Clear the SPOOL immediately after each transaction.
  (test_delta_file_stream): Use a SUBPOOL and clear it after each delta
                            application because txdelta is a complex op.

* subversion/tests/svn_test_fs.c
  (svn_test__set_file_contents): TxDelta windows can be 100k, therefore
                                 release them asap.
  (svn_test__create_blame_repository): Use a SUBPOOL for the txns and clear
                                       it immediately after each one.

Modified:
    subversion/trunk/subversion/tests/libsvn_fs/fs-test.c
    subversion/trunk/subversion/tests/svn_test_fs.c

Modified: subversion/trunk/subversion/tests/libsvn_fs/fs-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_fs/fs-test.c?rev=1710344&r1=1710343&r2=1710344&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_fs/fs-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_fs/fs-test.c Sat Oct 24 14:24:01 2015
@@ -334,6 +334,7 @@ txn_names_are_not_reused_helper1(apr_has
   apr_hash_index_t *hi;
   const int N = 10;
   int i;
+  apr_pool_t *subpool = svn_pool_create(pool);
 
   *txn_names = apr_hash_make(pool);
 
@@ -343,7 +344,8 @@ txn_names_are_not_reused_helper1(apr_has
     {
       svn_fs_txn_t *txn;
       const char *name;
-      SVN_ERR(svn_fs_begin_txn(&txn, fs, 0, pool));
+
+      SVN_ERR(svn_fs_begin_txn(&txn, fs, 0, subpool));
       SVN_ERR(svn_fs_txn_name(&name, txn, pool));
       if (apr_hash_get(*txn_names, name, APR_HASH_KEY_STRING) != NULL)
         return svn_error_createf(SVN_ERR_FS_GENERAL, NULL,
@@ -367,6 +369,7 @@ txn_names_are_not_reused_helper1(apr_has
                              "created %d transactions, but only aborted %d",
                              N, i);
 
+  svn_pool_destroy(subpool);
   return SVN_NO_ERROR;
 }
 
@@ -1018,8 +1021,9 @@ check_entry(svn_fs_root_t *root,
 {
   apr_hash_t *entries;
   svn_fs_dirent_t *ent;
+  apr_pool_t *subpool = svn_pool_create(pool);
 
-  SVN_ERR(svn_fs_dir_entries(&entries, root, path, pool));
+  SVN_ERR(svn_fs_dir_entries(&entries, root, path, subpool));
   ent = apr_hash_get(entries, name, APR_HASH_KEY_STRING);
 
   if (ent)
@@ -1027,6 +1031,7 @@ check_entry(svn_fs_root_t *root,
   else
     *present = FALSE;
 
+  svn_pool_destroy(subpool);
   return SVN_NO_ERROR;
 }
 
@@ -4761,6 +4766,7 @@ closest_copy_test(const svn_test_opts_t
   SVN_ERR(svn_fs_txn_root(&txn_root, txn, spool));
   SVN_ERR(svn_test__create_greek_tree(txn_root, spool));
   SVN_ERR(test_commit_txn(&after_rev, txn, NULL, spool));
+  svn_pool_clear(spool);
   SVN_ERR(svn_fs_revision_root(&rev_root, fs, after_rev, spool));
 
   /* Copy A to Z, and commit. */
@@ -4768,6 +4774,7 @@ closest_copy_test(const svn_test_opts_t
   SVN_ERR(svn_fs_txn_root(&txn_root, txn, spool));
   SVN_ERR(svn_fs_copy(rev_root, "A", txn_root, "Z", spool));
   SVN_ERR(test_commit_txn(&after_rev, txn, NULL, spool));
+  svn_pool_clear(spool);
   SVN_ERR(svn_fs_revision_root(&rev_root, fs, after_rev, spool));
 
   /* Anything under Z should have a closest copy pair of ("/Z", 2), so
@@ -4804,6 +4811,7 @@ closest_copy_test(const svn_test_opts_t
   SVN_ERR(svn_fs_make_file(txn_root, "Z/t", pool));
   SVN_ERR(svn_fs_make_file(txn_root, "Z2/D/H2/t", pool));
   SVN_ERR(test_commit_txn(&after_rev, txn, NULL, spool));
+  svn_pool_clear(spool);
   SVN_ERR(svn_fs_revision_root(&rev_root, fs, after_rev, spool));
 
   /* Okay, just for kicks, let's modify Z2/D/H2/t.  Shouldn't affect
@@ -4813,6 +4821,7 @@ closest_copy_test(const svn_test_opts_t
   SVN_ERR(svn_test__set_file_contents(txn_root, "Z2/D/H2/t",
                                       "Edited text.", spool));
   SVN_ERR(test_commit_txn(&after_rev, txn, NULL, spool));
+  svn_pool_clear(spool);
   SVN_ERR(svn_fs_revision_root(&rev_root, fs, after_rev, spool));
 
   /* Now, we expect Z2/D/H2 to have a closest copy of ("/Z2/D/H2", 3)
@@ -6496,6 +6505,7 @@ test_delta_file_stream(const svn_test_op
   svn_fs_txn_t *txn;
   svn_fs_root_t *txn_root, *root1, *root2;
   svn_revnum_t rev;
+  apr_pool_t *subpool = svn_pool_create(pool);
 
   const char *old_content = "some content";
   const char *new_content = "some more content";
@@ -6527,52 +6537,56 @@ test_delta_file_stream(const svn_test_op
 
   /* Test 1: Get delta against empty target. */
   SVN_ERR(svn_fs_get_file_delta_stream(&delta_stream,
-                                       NULL, NULL, root1, "foo", pool));
+                                       NULL, NULL, root1, "foo", subpool));
 
   svn_stringbuf_setempty(source);
   svn_stringbuf_setempty(dest);
 
-  svn_txdelta_apply(svn_stream_from_stringbuf(source, pool),
-                    svn_stream_from_stringbuf(dest, pool),
-                    NULL, NULL, pool, &delta_handler, &delta_baton);
+  svn_txdelta_apply(svn_stream_from_stringbuf(source, subpool),
+                    svn_stream_from_stringbuf(dest, subpool),
+                    NULL, NULL, subpool, &delta_handler, &delta_baton);
   SVN_ERR(svn_txdelta_send_txstream(delta_stream,
                                     delta_handler,
                                     delta_baton,
-                                    pool));
+                                    subpool));
   SVN_TEST_STRING_ASSERT(old_content, dest->data);
+  svn_pool_clear(subpool);
 
   /* Test 2: Get delta against previous version. */
   SVN_ERR(svn_fs_get_file_delta_stream(&delta_stream,
-                                       root1, "foo", root2, "foo", pool));
+                                       root1, "foo", root2, "foo", subpool));
 
   svn_stringbuf_set(source, old_content);
   svn_stringbuf_setempty(dest);
 
-  svn_txdelta_apply(svn_stream_from_stringbuf(source, pool),
-                    svn_stream_from_stringbuf(dest, pool),
-                    NULL, NULL, pool, &delta_handler, &delta_baton);
+  svn_txdelta_apply(svn_stream_from_stringbuf(source, subpool),
+                    svn_stream_from_stringbuf(dest, subpool),
+                    NULL, NULL, subpool, &delta_handler, &delta_baton);
   SVN_ERR(svn_txdelta_send_txstream(delta_stream,
                                     delta_handler,
                                     delta_baton,
-                                    pool));
+                                    subpool));
   SVN_TEST_STRING_ASSERT(new_content, dest->data);
+  svn_pool_clear(subpool);
 
   /* Test 3: Get reverse delta. */
   SVN_ERR(svn_fs_get_file_delta_stream(&delta_stream,
-                                       root2, "foo", root1, "foo", pool));
+                                       root2, "foo", root1, "foo", subpool));
 
   svn_stringbuf_set(source, new_content);
   svn_stringbuf_setempty(dest);
 
-  svn_txdelta_apply(svn_stream_from_stringbuf(source, pool),
-                    svn_stream_from_stringbuf(dest, pool),
-                    NULL, NULL, pool, &delta_handler, &delta_baton);
+  svn_txdelta_apply(svn_stream_from_stringbuf(source, subpool),
+                    svn_stream_from_stringbuf(dest, subpool),
+                    NULL, NULL, subpool, &delta_handler, &delta_baton);
   SVN_ERR(svn_txdelta_send_txstream(delta_stream,
                                     delta_handler,
                                     delta_baton,
-                                    pool));
+                                    subpool));
   SVN_TEST_STRING_ASSERT(old_content, dest->data);
 
+  svn_pool_destroy(subpool);
+
   return SVN_NO_ERROR;
 }
 

Modified: subversion/trunk/subversion/tests/svn_test_fs.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/svn_test_fs.c?rev=1710344&r1=1710343&r2=1710344&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/svn_test_fs.c (original)
+++ subversion/trunk/subversion/tests/svn_test_fs.c Sat Oct 24 14:24:01 2015
@@ -364,15 +364,17 @@ svn_test__set_file_contents(svn_fs_root_
   svn_txdelta_window_handler_t consumer_func;
   void *consumer_baton;
   svn_string_t string;
+  apr_pool_t *subpool = svn_pool_create(pool);
 
   SVN_ERR(svn_fs_apply_textdelta(&consumer_func, &consumer_baton,
-                                 root, path, NULL, NULL, pool));
+                                 root, path, NULL, NULL, subpool));
 
   string.data = contents;
   string.len = strlen(contents);
   SVN_ERR(svn_txdelta_send_string(&string, consumer_func,
-                                  consumer_baton, pool));
+                                  consumer_baton, subpool));
 
+  svn_pool_destroy(subpool);
   return SVN_NO_ERROR;
 }
 
@@ -847,6 +849,7 @@ svn_test__create_blame_repository(svn_re
   svn_fs_txn_t *txn;
   svn_fs_root_t *txn_root, *revision_root;
   svn_revnum_t youngest_rev = 0;
+  apr_pool_t *subpool = svn_pool_create(pool);
 
   /* Create a filesystem and repository. */
   SVN_ERR(svn_test__create_repos(&repos, test_name,
@@ -857,87 +860,96 @@ svn_test__create_blame_repository(svn_re
 
   /* Revision 1:  Add trunk, tags, branches. */
   SVN_ERR(svn_repos_fs_begin_txn_for_commit(&txn, repos, youngest_rev,
-                                            "initial", "log msg", pool));
-  SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool));
-  SVN_ERR(svn_fs_make_dir(txn_root, "trunk", pool));
-  SVN_ERR(svn_fs_make_dir(txn_root, "tags", pool));
-  SVN_ERR(svn_fs_make_dir(txn_root, "branches", pool));
-  SVN_ERR(svn_repos_fs_commit_txn(NULL, repos, &youngest_rev, txn, pool));
+                                            "initial", "log msg", subpool));
+  SVN_ERR(svn_fs_txn_root(&txn_root, txn, subpool));
+  SVN_ERR(svn_fs_make_dir(txn_root, "trunk", subpool));
+  SVN_ERR(svn_fs_make_dir(txn_root, "tags", subpool));
+  SVN_ERR(svn_fs_make_dir(txn_root, "branches", subpool));
+  SVN_ERR(svn_repos_fs_commit_txn(NULL, repos, &youngest_rev, txn, subpool));
   SVN_TEST_ASSERT(SVN_IS_VALID_REVNUM(youngest_rev));
+  svn_pool_clear(subpool);
 
   /* Revision 2:  Add the Greek tree on the trunk. */
   SVN_ERR(svn_repos_fs_begin_txn_for_commit(&txn, repos, youngest_rev,
-                                            "initial", "log msg", pool));
-  SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool));
-  SVN_ERR(svn_test__create_greek_tree_at(txn_root, "trunk", pool));
-  SVN_ERR(svn_repos_fs_commit_txn(NULL, repos, &youngest_rev, txn, pool));
+                                            "initial", "log msg", subpool));
+  SVN_ERR(svn_fs_txn_root(&txn_root, txn, subpool));
+  SVN_ERR(svn_test__create_greek_tree_at(txn_root, "trunk", subpool));
+  SVN_ERR(svn_repos_fs_commit_txn(NULL, repos, &youngest_rev, txn, subpool));
   SVN_TEST_ASSERT(SVN_IS_VALID_REVNUM(youngest_rev));
+  svn_pool_clear(subpool);
 
   /* Revision 3:  Tweak trunk/A/mu. */
   SVN_ERR(svn_repos_fs_begin_txn_for_commit(&txn, repos, youngest_rev,
-                                            "user-trunk", "log msg", pool));
-  SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool));
+                                            "user-trunk", "log msg", subpool));
+  SVN_ERR(svn_fs_txn_root(&txn_root, txn, subpool));
   SVN_ERR(svn_test__set_file_contents(txn_root, "trunk/A/mu",
-                                      "A\nB\nC\nD\nE\nF\nG\nH\nI", pool));
-  SVN_ERR(svn_repos_fs_commit_txn(NULL, repos, &youngest_rev, txn, pool));
+                                      "A\nB\nC\nD\nE\nF\nG\nH\nI", subpool));
+  SVN_ERR(svn_repos_fs_commit_txn(NULL, repos, &youngest_rev, txn, subpool));
   SVN_TEST_ASSERT(SVN_IS_VALID_REVNUM(youngest_rev));
+  svn_pool_clear(subpool);
 
   /* Revision 4:  Copy trunk to branches/1.0.x. */
   SVN_ERR(svn_repos_fs_begin_txn_for_commit(&txn, repos, youngest_rev,
-                                            "copy", "log msg", pool));
-  SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool));
-  SVN_ERR(svn_fs_revision_root(&revision_root, fs, youngest_rev, pool));
+                                            "copy", "log msg", subpool));
+  SVN_ERR(svn_fs_txn_root(&txn_root, txn, subpool));
+  SVN_ERR(svn_fs_revision_root(&revision_root, fs, youngest_rev, subpool));
   SVN_ERR(svn_fs_copy(revision_root, "trunk",
                       txn_root, "branches/1.0.x",
-                      pool));
-  SVN_ERR(svn_repos_fs_commit_txn(NULL, repos, &youngest_rev, txn, pool));
+                      subpool));
+  SVN_ERR(svn_repos_fs_commit_txn(NULL, repos, &youngest_rev, txn, subpool));
   SVN_TEST_ASSERT(SVN_IS_VALID_REVNUM(youngest_rev));
+  svn_pool_clear(subpool);
 
   /* Revision 5:  Tweak trunk/A/mu. */
   SVN_ERR(svn_repos_fs_begin_txn_for_commit(&txn, repos, youngest_rev,
-                                            "user-trunk", "log msg", pool));
-  SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool));
+                                            "user-trunk", "log msg", subpool));
+  SVN_ERR(svn_fs_txn_root(&txn_root, txn, subpool));
   SVN_ERR(svn_test__set_file_contents(txn_root, "trunk/A/mu",
                                       "A\nB\nC -- trunk edit\nD\nE\nF\nG\nH\nI",
-                                      pool));
-  SVN_ERR(svn_repos_fs_commit_txn(NULL, repos, &youngest_rev, txn, pool));
+                                      subpool));
+  SVN_ERR(svn_repos_fs_commit_txn(NULL, repos, &youngest_rev, txn, subpool));
   SVN_TEST_ASSERT(SVN_IS_VALID_REVNUM(youngest_rev));
+  svn_pool_clear(subpool);
 
   /* Revision 6:  Tweak branches/1.0.x/A/mu. */
   SVN_ERR(svn_repos_fs_begin_txn_for_commit(&txn, repos, youngest_rev,
-                                            "user-branch", "log msg", pool));
-  SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool));
+                                            "user-branch", "log msg", subpool));
+  SVN_ERR(svn_fs_txn_root(&txn_root, txn, subpool));
   SVN_ERR(svn_test__set_file_contents(txn_root, "branches/1.0.x/A/mu",
                                       "A\nB\nC\nD -- branch edit\nE\nF\nG\nH\nI",
-                                      pool));
-  SVN_ERR(svn_repos_fs_commit_txn(NULL, repos, &youngest_rev, txn, pool));
+                                      subpool));
+  SVN_ERR(svn_repos_fs_commit_txn(NULL, repos, &youngest_rev, txn, subpool));
   SVN_TEST_ASSERT(SVN_IS_VALID_REVNUM(youngest_rev));
+  svn_pool_clear(subpool);
 
   /* Revision 7:  Merge trunk to branch. */
   SVN_ERR(svn_repos_fs_begin_txn_for_commit(&txn, repos, youngest_rev,
-                                            "user-merge1", "log msg", pool));
-  SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool));
+                                            "user-merge1", "log msg", subpool));
+  SVN_ERR(svn_fs_txn_root(&txn_root, txn, subpool));
   SVN_ERR(svn_test__set_file_contents(txn_root, "branches/1.0.x/A/mu",
                                       "A\nB\nC -- trunk edit\nD -- branch edit"
-                                      "\nE\nF\nG\nH\nI", pool));
+                                      "\nE\nF\nG\nH\nI", subpool));
   SVN_ERR(svn_fs_change_node_prop(txn_root, "/branches/1.0.x", "svn:mergeinfo",
-                                  svn_string_create("/trunk:4-6", pool),
-                                  pool));
-  SVN_ERR(svn_repos_fs_commit_txn(NULL, repos, &youngest_rev, txn, pool));
+                                  svn_string_create("/trunk:4-6", subpool),
+                                  subpool));
+  SVN_ERR(svn_repos_fs_commit_txn(NULL, repos, &youngest_rev, txn, subpool));
   SVN_TEST_ASSERT(SVN_IS_VALID_REVNUM(youngest_rev));
+  svn_pool_clear(subpool);
 
   /* Revision 8:  Merge branch to trunk. */
   SVN_ERR(svn_repos_fs_begin_txn_for_commit(&txn, repos, youngest_rev,
-                                            "user-merge2", "log msg", pool));
-  SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool));
+                                            "user-merge2", "log msg", subpool));
+  SVN_ERR(svn_fs_txn_root(&txn_root, txn, subpool));
   SVN_ERR(svn_test__set_file_contents(txn_root, "trunk/A/mu",
                                       "A\nB\nC -- trunk edit\nD -- branch edit\n"
-                                      "E\nF\nG\nH\nI", pool));
+                                      "E\nF\nG\nH\nI", subpool));
   SVN_ERR(svn_fs_change_node_prop(txn_root, "/trunk", "svn:mergeinfo",
-                                  svn_string_create("/branches/1.0.x:4-7", pool),
-                                  pool));
-  SVN_ERR(svn_repos_fs_commit_txn(NULL, repos, &youngest_rev, txn, pool));
+                                  svn_string_create("/branches/1.0.x:4-7", subpool),
+                                  subpool));
+  SVN_ERR(svn_repos_fs_commit_txn(NULL, repos, &youngest_rev, txn, subpool));
   SVN_TEST_ASSERT(SVN_IS_VALID_REVNUM(youngest_rev));
 
+  svn_pool_destroy(subpool);
+
   return SVN_NO_ERROR;
 }