You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@apr.apache.org by bu...@apache.org on 2006/11/10 00:30:51 UTC
DO NOT REPLY [Bug 40939] New: - pool minimal allocation size should be configurable
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
Summary: pool minimal allocation size should be configurable
Product: APR
Version: HEAD
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P3
Component: APR
AssignedTo: bugs@apr.apache.org
ReportedBy: mlindner@google.com
Pools currently allocate memory in 8K chunks; the size is a hardcoded constant.
This is not ideal when using APR from C++ code; it's preferable not to pass
pools around between classes as it breaks encapsulation. Therefore those C++
objects that make APR calls should have their own dedicated pools. 8K in many
cases is wasteful; it would be appropriate to use memory in smaller increments.
The attached patch adds a new function apr_allocator_create_ex() that accepts a
min_size parameter, which gets stored in the apr_allocator_t structure and
replaces the hardcoded MIN_SIZE value.
--
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.
DO NOT REPLY [Bug 40939] - pool minimal allocation size should be configurable
Posted by bu...@apache.org.
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 mlindner@google.com 2006-11-09 15:32 -------
Created an attachment (id=19107)
--> (http://issues.apache.org/bugzilla/attachment.cgi?id=19107&action=view)
apr allocator patch
file 2 of 2
--
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.
DO NOT REPLY [Bug 40939] - pool minimal allocation size should be configurable
Posted by bu...@apache.org.
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
mlindner@google.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #19106|apr allocator patch |apr_allocator.h.diff
description| |
--
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.
DO NOT REPLY [Bug 40939] - pool minimal allocation size should be configurable
Posted by bu...@apache.org.
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 davi@haxent.com.br 2007-05-12 11:11 -------
Are you going to pursue this further?
--
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.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org
DO NOT REPLY [Bug 40939] - pool minimal allocation size should be configurable
Posted by bu...@apache.org.
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 mlindner@google.com 2006-11-09 15:31 -------
Created an attachment (id=19106)
--> (http://issues.apache.org/bugzilla/attachment.cgi?id=19106&action=view)
apr allocator patch
file 1 of 2
--
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.
DO NOT REPLY [Bug 40939] - pool minimal allocation size should be configurable
Posted by bu...@apache.org.
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
mlindner@google.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #19107|apr allocator patch |apr_pools.c.diff
description| |
--
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.
DO NOT REPLY [Bug 40939] - pool minimal allocation size should be configurable
Posted by bu...@apache.org.
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 mlindner@google.com 2006-11-09 17:34 -------
Ok, so we'll need to make sure the supplied size is a power of 2...
if ((min_size & 1) || (min_size < MIN_ALLOC))
new_allocator->min_size = MIN_ALLOC;
else
new_allocator->min_size = min_size;
...and instead of using hardcoded BOUNDARY_INDEX and BOUNDARY_SIZE we add them
as fields in apr_allocator_t, calculated as:
new_allocator->boundary_size = new_allocator->min_size / 2;
new_allocator->boundary_index = 0;
int x = new_allocator->boundary_size;
while ((x >>= 1))
(new_allocator->boundary_index)++;
MAX_INDEX would probably have to be supplied by caller instead of being a fixed
value as it determines the number of buckets (and thus size of largest bucket).
I think that should work...I'll flesh out the patch when I have time...
--
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.
DO NOT REPLY [Bug 40939] - pool minimal allocation size should be configurable
Posted by bu...@apache.org.
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
davi@haxent.com.br changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |PatchAvailable
--
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.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org
DO NOT REPLY [Bug 40939] - pool minimal allocation size should be configurable
Posted by bu...@apache.org.
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 18:37 -------
When you rework the patch, please be sure to add some comments explaining how
the various values relate to each other... It's kind of opaque now. Obviously
this isn't a problem with your patch, but if we're already diving into the guts
of this stuff we might as well make it easier to understand for the next guy.
--
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.
DO NOT REPLY [Bug 40939] - pool minimal allocation size should be configurable
Posted by bu...@apache.org.
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.