Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Simple General-Purpose Dynamic Region Allocator...

53 views
Skip to first unread message

Chris Thomasson

unread,
Apr 21, 2008, 9:54:12 AM4/21/08
to
Here is the VERY crude initial code:

http://pastebin.com/m2dacea67


The allocator overloads the global new/delete operators when
'TEST_USE_REGION_ALLOCATOR' is defined. This makes it easier to fit into the
STL. When I run that program with 'TEST_USE_REGION_ALLOCATOR' defined it
get:

Time: 266 ms


The time I get when its not defined is:

Time: 2495 ms


So, this allocator could "possibly" be a definite improvement over original
new/delete operators. There is one MAJOR problem... It's not thread-safe
as-is. However, I don't think its going to be hard to make it work with
threads. I believe I can do a complete non-blocking version. Anyway, before
I go ahead and do that, I was wondering if anybody can give me some
comments/suggestions? BTW, what times do you all get?


Thanks!


--
Chris M. Thomasson
http://appcore.home.comcast.net

Juha Nieminen

unread,
Apr 21, 2008, 11:29:19 AM4/21/08
to
Chris Thomasson wrote:
> Anyway, before I go ahead and do that, I was wondering if
> anybody can give me some comments/suggestions?

An allocator class which could be given to STL containers (as a
template parameter) would be nice.

> BTW, what times do you all get?

When creating my own allocator: http://warp.povusers.org/FSBAllocator/
I made a somewhat comprehensive sanity check test program, which was
also a speed test at the same time.
Here are timing results in my computer (3.4GHz Pentium4) using
gcc 4.1.2 (compilation options -O3 -march=pentium4 -fomit-frame-pointer
-s -DNDEBUG) using that test program of mine:

Default libc allocator: 9 minutes 35 seconds.
My allocator: 1 minute 2 seconds.
Your allocator: 49 seconds.

Chris Thomasson

unread,
Apr 21, 2008, 3:07:56 PM4/21/08
to
"Juha Nieminen" <nos...@thanks.invalid> wrote in message
news:480cb2cd$0$8161$4f79...@news.tdc.fi...

> Chris Thomasson wrote:
>> Anyway, before I go ahead and do that, I was wondering if
>> anybody can give me some comments/suggestions?
>
> An allocator class which could be given to STL containers (as a
> template parameter) would be nice.

Agreed.


>> BTW, what times do you all get?
>
> When creating my own allocator: http://warp.povusers.org/FSBAllocator/
> I made a somewhat comprehensive sanity check test program, which was
> also a speed test at the same time.
> Here are timing results in my computer (3.4GHz Pentium4) using
> gcc 4.1.2 (compilation options -O3 -march=pentium4 -fomit-frame-pointer
> -s -DNDEBUG) using that test program of mine:
>
> Default libc allocator: 9 minutes 35 seconds.
> My allocator: 1 minute 2 seconds.
> Your allocator: 49 seconds.

Weird. I would have thought that a fixed-block allocator would totally beat
my general-purpose allocator.

Juha Nieminen

unread,
Apr 21, 2008, 3:59:47 PM4/21/08
to
Chris Thomasson wrote:
> Weird. I would have thought that a fixed-block allocator would totally
> beat my general-purpose allocator.

Yeah, I don't know what the bottleneck is. Trying to profile the code
is basically impossible because all the functions are inlined (the
profiler only sees main(), and that's it), so I'm at a loss.

(I don't think disabling optimizations would be a good way to profile
the code to find the bottleneck because turning off optimizations may
well create bottlenecks which are inexistent in the optimized version.)

0 new messages