2,573 reputation
21529
bio website
location
age
visits member for 3 years, 11 months
seen 22 hours ago

Jul
4
comment Demonstration of garbage collection being faster than manual memory management
Oops sorry my bad. @btilly should read my comment then.
Jul
4
comment Demonstration of garbage collection being faster than manual memory management
@GuySirton: Then again, they don't even seem to be benchmarking GCs in the first place -- they seem to just be comparing C++ to Java, with preallocated storage...
Jul
4
comment Demonstration of garbage collection being faster than manual memory management
@GuySirton: I can't reproduce the keithlea.com/javabench results. I just tried out the heapsort implementation, and even when comparing the output of my old C++ compiler (Visual C++ 13.10.4035) with the one from JRE 7, C++ beats Java quite noticeably. If you can reproduce any of them let me know which one and I'll try that one.
Jul
4
comment Demonstration of garbage collection being faster than manual memory management
@delnan: Oh, I see what you mean now, that's a great point, thanks for bringing it up!
Jul
4
comment Demonstration of garbage collection being faster than manual memory management
@ddyer: Hmm, what exactly is so difficult to compare here? For example, let's say you're doing some computation (e.g. an FFT) on a lot of data (say, 100 million data points). A very easy and objective way to compare them would be to compare the number of data points processed per second, over the entire life of the program, and show that a GC is faster (or slower). That's a 100% objective and hard measure of performance, and the fact that there was a lot of data shows you're not measuring artifacts over small datasets. How is that hand-wavy? It seems perfectly comparable to me.
Jul
4
comment Demonstration of garbage collection being faster than manual memory management
+1 for citing an actual example with code :) although proper use of C++ constructs (such as swap) isn't that hard, and would probably get you there quite easily performance-wise...
Jul
4
comment Demonstration of garbage collection being faster than manual memory management
@ddyer: So when people say (for example) "garbage collection is often faster than manual memory management", they're thinking of extreme examples like that? I find it hard to believe these statements (which are all over the web) require such extreme and difficult-to-demonstrate examples to be actually true...
Jul
4
comment Demonstration of garbage collection being faster than manual memory management
@btilly: How is that any different from calling abort() in the corresponding location in the C++ code?
Jul
4
comment Demonstration of garbage collection being faster than manual memory management
@btilly: "Write a program where the GC version fails to do a garbage run before exiting."... failing to do garbage collection in the first place is a memory leak due to the lack of a functioning GC, not a performance improvement due to the presence of a GC! That's like calling abort() in C++ before the program exits. It's a meaningless comparison; you're not even garbage-collecting, you're just letting memory leak. You can't say garbage collection is faster (or slower) if you're not garbage-collecting to begin with...
Jul
4
comment Demonstration of garbage collection being faster than manual memory management
@delnan: I don't see how you can have a "copy what the GC does" is possible though. A GC looks through the stack, static data segments, etc. in known locations to find references to the object graph's roots, but that's impossible in a native language C++ because there's no way to discover references like that, unless you make your own compiler (but then your code is restricted to that compiler).
Jul
4
comment Demonstration of garbage collection being faster than manual memory management
If it's easy to construct an artificial example, would you mind showing a simple one?
Jul
4
comment Demonstration of garbage collection being faster than manual memory management
@DanPichelman: Machine performance. Examples of the claims I've seen are here.
Jul
4
comment Demonstration of garbage collection being faster than manual memory management
@ratchetfreak: If you know of any examples that are only faster (say) 70% of the time, that's fine with me too. There must be some way to compare the two, in terms of throughput at least (latency probably wouldn't work).
Jul
4
answered Is fewer lines of code always better?
Jul
4
asked Demonstration of garbage collection being faster than manual memory management
May
29
awarded  Nice Question
Mar
28
awarded  Necromancer
Feb
24
awarded  Necromancer
Feb
18
awarded  Caucus
Feb
16
awarded  Popular Question