Live data from Hacker News

5 Coding Hacks to Reduce GC Overhead

takipiblog.com

21–25 of 25 posts

Re: 5 Coding Hacks to Reduce GC Overhead

#21

This article is way inaccurate. It recommends approaches that were maybe important in 1997. It also breaks the "profile before optimising" rule. Currently the Java GC works splendidly with lots of short-lived, small immutable classes. Using this approach can be far better for performance than worrying about telling the ArrayList constructor how many elements the list will probably have.

Absolutely. Step 0 of this article should have been "profile your GC and establish that it is a problem."

Re: 5 Coding Hacks to Reduce GC Overhead

#23

This article is way inaccurate. It recommends approaches that were maybe important in 1997. It also breaks the "profile before optimising" rule. Currently the Java GC works splendidly with lots of short-lived, small immutable classes. Using this approach can be far better for performance than worrying about telling the ArrayList constructor how many elements the list will probably have.

While VMs like Sun's may be using techniques like escape analysis, I seriously doubt that Dalvik does (it seems like dx might, but that's going to be of limited value at compile time, and it isn't clear how it uses the information): a lot of people these days coding in Java are doing so for Android, where the garbage collector is a serious problem, sufficiently so that all garbage collections are logged to the system log (so as a developer you don't even need to go to much work to profile it as an issue: you just see the pain in your console and then likely seem out this article).

Re: 5 Coding Hacks to Reduce GC Overhead

#25
post #7
post #5

Articles like this make me believe that Java should have just gone with a model designed around fibers that each fiber gets a fiber-local heap and objects that survive the death of the heap or are accessed in a multi-fiber way are moved to a global heap. It would solve the problem with "stop the world" GC dynamics and increase concurrent collecting performance while also adding native fibers to the JVM (and thus make…

The DLG collector as used by Caml Light does what you describe. Updating an object in the global heap to point to a thread-local heap can cause unbounded work to be done before that update as the entire pointed-to structure has to be copied into the global heap first. GC designers really hate write barriers (sections of code that are performed before a pointer is updated) that perform unbounded work.

[deleted]
Post reply on HN