Skip to main content
GameDev.net gamedev.net
🔒 Locked

How important are custom allocaters actually?

Started by 3DModelerMan May 19, 2013 at 3:14 PM 4 replies 1.9k views
Original Post
3DModelerMan
3DModelerMan

I have a custom allocation scheme in my engine because I want my game to run fast and efficiently on mobile phones and consoles like OUYA. I wrote a custom STL allocater and so far every library I use hooks into my allocation system. However there are some libraries that don't support hooking custom allocaters into that I would like to use. So my question is basically this: should I take the extra effort to make sure that STL integrates perfectly with my allocaters and use as few external libs that can't hook into them as possible? Or should custom allocaters just be used for the game engine itself?

markr
markr

I think you should ask yourself:

* Which game(s) have performance problems? On which devices?

* What do the profiling data tell you about the location of the problem(s)? Hopefully you can get a native profiler on all your target devices.

* What is the best way of fixing the specific problems?

If the answer to all of those points to a STL custom allocator being the BEST way of fixing the problem, then do it. Otherwise don't.

Hodgman
Hodgman
What does your custom one do differently from the default one?
Krohm
Krohm

Some time ago I had a performance problem on my lowest-end supported devices (atom, FYI). I identified allocation as a problem. I rewrote the systems involved so I cut allocation count to 1/30.

I keep hearing about those custom allocators, but I wonder if all this people is really trying to minimize allocations in the first place, because this is what everyone should do first. Avoiding work. Not doing useless work faster.

Now, I'm not claiming people to be doing the wrong thing up start, it's just a question I have. Before trying to alloc faster, have you tried alloc'ing less frequently?

edit: typo.

Previously "Krohm"
ApochPiQ
ApochPiQ

The more allocation scenarios you use a custom allocator for, the closer it will degrade to general-purpose.

Profile first and foremost.

Allocate as little as possible.

For the remainder, decide on a specialized allocation strategy as much as possible. Does your event system really need a free-store style allocator, or can you get away with something like a stack allocator or a freelist/pool or some other mechanism?

Worst case, rearchitect your code to eliminate allocation overhead (while taking care not to introduce other forms of algorithmic overhead in the process).

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.