Linked by Thom Holwerda on Thu 6th Sep 2012 21:32 UTC, submitted by MOS6510
Benchmarks "During the 4th Semester of my studies I wrote a small 3d spaceship deathmatch shooter with the D-Programming language. It was created within 3 Months time and allows multiple players to play deathmatch over local area network. All of the code was written with a garbage collector in mind and made wide usage of the D standard library phobos. After the project was finished I noticed how much time is spend every frame for garbage collection, so I decided to create a version of the game which does not use a GC, to improve performance."
Permalink for comment 534397
To read all comments associated with this story, please click here.
RE[6]: GC is for scripting
by sakeniwefu on Sun 9th Sep 2012 02:56 UTC in reply to "RE[5]: GC is for scripting"
Member since:

"If you have a GC, you do not worry too much about short-lived objects, but worry a great deal about medium-lived objects. If you do not have a GC, then you do not worry too much about medium-lived objects, but must take care to avoid excessive overhead from constructing and destructing short-lived objects."

I still don't think it's safe to assume these generalisations are accurate without benchmarking them in an application.

Benchmark, benchmark, and when you've established that there isn't any possible bottleneck other than memory allocation, then it still isn't the memory allocation system.

Some time ago, I designed and implemented an abstraction layer for an embedded OS and when the app it was serving was reported as being too slow by the customers my system allocator wrapper was singled out as the problem by the "profiler".

This was in a world of custom prematurely optimized everything. So my decision to keep it simple was met with little sympathy.

So, I rewrote it with a custom memory management algorithm to the point allocation and release were barely slower on average than a void (library) function call.

Guess what? It still was the bottleneck.

Some good old printf profiling revealed that the OOP client application was hitting it like crazy.

Classic allocation, Reference Counting, Garbage Collection, it wouldn't have made a difference.

The problem I see in all of GC, RAII(for system memory) or ARC is that they encourage the everything is an object mentality. And that mentality generally turns into programs that hit the allocator way too much.

Reply Parent Score: 2