apr-bugs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 40939] - pool minimal allocation size should be configurable
Date Fri, 10 Nov 2006 00:32:42 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=40939>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=40939





------- Additional Comments From rooneg@electricjellyfish.net  2006-11-09 16:32 -------
(From update of attachment 19107)
Ok, just trying to think some of this through, so bear with me...

>Index: memory/unix/apr_pools.c
>===================================================================
>--- memory/unix/apr_pools.c	(revision 473132)
>+++ memory/unix/apr_pools.c	(working copy)
>@@ -44,7 +44,8 @@
>  * Magic numbers
>  */
> 
>-#define MIN_ALLOC 8192
>+#define MIN_ALLOC  512
>+#define DFL_ALLOC 8192
> #define MAX_INDEX   20

So, first you declare a minimum allocation size and a default allocation
size...

[ ...snip... ]

>+APR_DECLARE(apr_status_t) apr_allocator_create_ex(apr_allocator_t **allocator,
>+                                                  apr_size_t min_size)
>+{
>     apr_allocator_t *new_allocator;
> 
>     *allocator = NULL;
>@@ -94,6 +102,8 @@
>     memset(new_allocator, 0, SIZEOF_ALLOCATOR_T);
>     new_allocator->max_free_index = APR_ALLOCATOR_MAX_FREE_UNLIMITED;
> 
>+    new_allocator->min_size = (min_size >= MIN_ALLOC ? min_size : DFL_ALLOC);
>+

Then here, if the min size passed in is bigger than the MIN_ALLOC you'll use
it, otherwise you fall back to the default alloc size?	So if I pass in 511
bytes you jump right back to 8K?  If anything I'd expect to go up to the
minimum size...

>     *allocator = new_allocator;
> 
>     return APR_SUCCESS;
>@@ -178,8 +188,8 @@
>      * allocate at least a certain size (MIN_ALLOC).
>      */
>     size = APR_ALIGN(size + APR_MEMNODE_T_SIZE, BOUNDARY_SIZE);
>-    if (size < MIN_ALLOC)
>-        size = MIN_ALLOC;
>+    if(size < allocator->min_size)
>+        size = allocator->min_size;

Missing a space before the paren there...

Maybe more importantly though, I wonder how all of this stuff plays with the
logic later on in that function:

    /* Find the index for this node size by
     * dividing its size by the boundary size
     */
    index = (size >> BOUNDARY_INDEX) - 1;

How is that going to work if size is something smaller than 8K?  I haven't
really thought this through, so it's certainly possible that it will work, but
I'd always assumed that the reason we hadn't done this sort of thing before was
that it was more complex than it looked...


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

Mime
View raw message