To view parent comment, click here.
To read all comments associated with this story, please click here.
sakeniwefu,
"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."
Well, GCC's allocator is not very good especially on SMP systems where it can be a bottleneck. So it might make sense to tinker with new allocators but I wouldn't want to imply that allocation is typically a bottleneck in most applications.
"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."
I'm curious about the implementation, I've written my own too where objects were pooled in thread local storage and therefore incurred no overhead on SMP until the global allocator was hit to replenish the pools.
"Guess what? It still was the bottleneck. Some good old printf profiling revealed that the OOP client application was hitting it like crazy."
This should have been uncovered much earlier. Didn't the profiler give function counts?
"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."
Absolutely, one of the easiest ways to improve low level performance is by reducing the number of objects we need to accomplish our tasks. If a process always allocates A+B+C, then those could be combined into one monolith object instead, reducing object overhead by a factor of 3 for both GC or non-GC languages. However many people are going to be on edge about where to draw the line between OOP purity and overhead. Even though ideally one might want to manipulate pixels as objects, the OOP paradigm just breaks down due to the inefficiency of having so many numerous objects. Some day we could have a language with virtual objects which don't exist in memory, but allow us to manipulate the pixels as if they were real objects.




Member since:
2008-02-26
"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.