RFC: Hint parameter for allocators.
Dhruv Matani
dhruvbird@gmx.net
Fri Jan 23 08:47:00 GMT 2004
On Fri, 2004-01-23 at 08:49, Loren James Rittle wrote:
> Dhruv Matani writes:
> > I'd like to discuss the specific use of the hint parameter of a standard
> > allocator when used to specify the region of memory the allocator should
> > prefer when choosing it for the current request.
> [...]
>
> This is an interesting line of ideas. I do wonder if the dynamic
> complexity outweighs memory layout advantage.
That's the main question. I guess only studying a real application would
provide the answer.
> In a static system
> build, where precompute time is a one-time cost, this can be a big win.
I did not get you here. What precompute time are you talking about?
> > 4. Does anyone know of an allocator that makes use of the hint parameter
> > for locality preservation?
>
> Not in the context of a general allocator for use with STL. How are
> you passing a hint in your current effort (code example, etc)?
First, we need to modify the list's base class so that get node accepts
hints. Then, modify the create_node function to accept hints. Then, in
the insert (iterator pos, const_reference Data) function, we change the
line that calls create_node (Data) to
create_node (Data, pos._M_node->_M_prev);
pos._M_node->_M_prev is the last valid node in case of a non-empty list.
Then there's no need to change any driver program. Just re-compile any
existing test program that uses list and check the timings. I did that,
and did not notice any significant changes, so I suppose that:
1. It does not matter that much or:
2. In real application that runs for longer times, that would probably
make a difference?
Of course, you need to use an allocator that can make sense of the hint
parameter.
For the file attached, the controlling #define is USE_HINT_PARAMETER.
You can turn it on/off by simply commenting it away.
--
-Dhruv Matani.
http://www.geocities.com/dhruvbird/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: balloc.hpp
Type: text/x-c-header
Size: 20708 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20040123/53123a25/attachment.bin>
More information about the Libstdc++
mailing list