Author: stefan2
Date: Wed Aug  4 18:43:29 2010
New Revision: 982355

URL: http://svn.apache.org/viewvc?rev=982355&view=rev
Log:
Fix an issue with fulltext caching already present in production SVN:
APR pools often won't reuse memory fragments if they are larger
than 80kB. Using string buffers while reconstructing fulltexts does 
exactly The Bad Thing: request large buffers of various sizes that
APR pools will often not reuse due to their differing and often just
a tad bit too small size.

Use an allocator to limit the amount of unused memory fragments
held by the root pools.

* subversion/svnserve/main.c
  (main): limit the idle memory allocated per request root pool to 4 MB.

Modified:
    subversion/branches/performance/subversion/svnserve/main.c

Modified: subversion/branches/performance/subversion/svnserve/main.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/performance/subversion/svnserve/main.c?rev=982355&r1=982354&r2=982355&view=diff
==============================================================================
--- subversion/branches/performance/subversion/svnserve/main.c (original)
+++ subversion/branches/performance/subversion/svnserve/main.c Wed Aug  4 
18:43:29 2010
@@ -402,6 +402,7 @@ int main(int argc, const char *argv[])
   apr_sockaddr_t *sa;
   apr_pool_t *pool;
   apr_pool_t *connection_pool;
+  apr_allocator_t *allocator;
   svn_error_t *err;
   apr_getopt_t *os;
   int opt;
@@ -859,10 +860,22 @@ int main(int argc, const char *argv[])
         return ERROR_SUCCESS;
 #endif
 
+      /* If we are using fulltext caches etc., we will allocate many large
+         chunks of memory of various sizes outside the cachde for those
+         fulltexts. Make sure, we use the memory wisely: use an allocator
+         that causes memory fragments to be given back to the OS early. */
+
+      if (apr_allocator_create(&allocator))
+        return EXIT_FAILURE;
+
+      apr_allocator_max_free_set(allocator, 
SVN_ALLOCATOR_RECOMMENDED_MAX_FREE);
+
       /* Non-standard pool handling.  The main thread never blocks to join
          the connection threads so it cannot clean up after each one.  So
          separate pools, that can be cleared at thread exit, are used */
-      connection_pool = svn_pool_create(NULL);
+
+      connection_pool = svn_pool_create_ex(NULL, allocator);
+      apr_allocator_owner_set(allocator, connection_pool);
 
       status = apr_socket_accept(&usock, sock, connection_pool);
       if (handling_mode == connection_mode_fork)


Reply via email to