The Artima Developer Community
Sponsored Link

Artima Developer Spotlight Forum
Eric Bruno on the G1 Garbage Collector in JDK 6

19 replies on 2 pages. Most recent reply: Sep 2, 2009 12:34 PM by Nemanja Trifunovic

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 19 replies on 2 pages [ « | 1 2 ]
Achilleas Margaritis

Posts: 674
Nickname: achilleas
Registered: Feb, 2005

Re: Eric Bruno on the G1 Garbage Collector in JDK 6 Posted: Aug 31, 2009 3:30 AM
Reply to this message Reply
Advertisement
> > 'Regulars' on comp.lang.c are eager to teach you
> > that C has no 'heap'. C++ has a 'free store' but no
> heap,
> > either.
>
> Of course the C _language_ has no heap. At any rate, a
> heap is simply a data structure that's efficient for
> managing information about memory blocks. I'm personally
> unaware of C runtime library implementations that manage
> memory and that _don't_ use a heap for alloc(); while it's
> not as fun as practicing pedanticism, perhaps the regulars
> on comp.lang.c could find one?
>
> > > In Java, "new" could come from a heap, or from the
> > > stack, or from ...
>
> > Same in C and C++.
>
> No, not the same in C and C++. Once compiling and linking
> are done in C/C++, the allocation will always use the same
> method. It's not a runtime decision. In a language such as
> Java, "new" (alloc) is not a method, nor is it bound to a
> class or runtime library. The JVM can cause the same "new"
> call in the code to allocate in a stack-based manner,
> using a slab allocator, or using a heap, (or in any other
> manner for that matter), and it can make that decision as
> early or as late as it chooses to.
>
> Peace,
>
> Cameron Purdy | Oracle Coherence
> http://coherence.oracle.com

Do you have any idea of how efficient escape analysis can be on Java? does it equal hand-coded value types in C++?

James Watson

Posts: 2024
Nickname: watson
Registered: Sep, 2005

Re: Eric Bruno on the G1 Garbage Collector in JDK 6 Posted: Aug 31, 2009 6:09 AM
Reply to this message Reply
> Do you have any idea of how efficient escape analysis can
> be on Java? does it equal hand-coded value types in C++?

There has to be some overhead associated with the analysis itself. The question is how significant that overhead is.

http://www.cag.lcs.mit.edu/~rinard/paper/oopsla99.ps

Re: my previous comment - Escape analysis is available in 1.6.1_14 of the JRE.

http://blog.uncommons.org/2009/05/31/escape-analysis-in-java-6-update-14-some-informal-benchmarks/

Cameron Purdy

Posts: 186
Nickname: cpurdy
Registered: Dec, 2004

Re: Eric Bruno on the G1 Garbage Collector in JDK 6 Posted: Aug 31, 2009 4:25 PM
Reply to this message Reply
Achilleas -

> Do you have any idea of how efficient escape analysis can
> be on Java? does it equal hand-coded value types in C++?

I do not believe that Java (and any similar runtimes) can ever match C/C++ code for speed *if* the C/C++ code is well implemented, and the design/coding is based on a realistic runtime profile. In other words, if you can build a C/C++ system as if it had been iteratively designed / implemented / profiled (repeat ad nauseum) until it couldn't be any faster, then that's likely to be unbeatable by any language runtime machine (e.g. JVM).

For relatively small projects, with engineering teams made up of skilled coders with sufficient domain knowledge, this is quite do-able (because the profile can be intelligently postulated up front).

For larger projects, and/or teams without intricate coding skills, I think it's unsafe (code-wise), risky (project-wise) and expensive (resource-wise) to attempt this.

Advances such as runtime profiling (e.g. Hotspot) combined with automatic GC and escape analysis allow a language runtime machine to make this trade-off at runtime, i.e. to burn CPU cycles and memory to do this analysis and work as the application executes, instead of at development time.

For the simplest systems, such as those that run for a short duration, the start-up costs (CPU and memory) and the deferred returns from profile-based optimizations make it clear that this approach is hugely inefficient. (You can clearly see this in language performance comparisons that include JVM start-up time as part of the measurement for programs that run for a fraction of a second.)

For larger systems, and for systems that run for long periods of time, the start-up costs are amortized to near-zero, and the returns from profile-based optimizations are near-impossible to replicate by hand coding.

What we lack today is a language / language runtime machine that combines the two. Java has a number of design flaws (and even more implementation flaws) that cumulatively saddle it with start-up processing costs -- and a significant minimum footprint in terms of memory -- that eliminate it from a large class of applications. I don't personally believe that C/C++ are remotely usable for modern application development (an opinion that is obviously not universally shared ;-).

A language / language runtime _similar_ to Java (etc.) could address most of the issues, but it would have to be _designed_ to solve them.

Peace,

Cameron Purdy | Oracle Coherence
http://coherence.oracle.com/

Achilleas Margaritis

Posts: 674
Nickname: achilleas
Registered: Feb, 2005

Re: Eric Bruno on the G1 Garbage Collector in JDK 6 Posted: Sep 1, 2009 4:54 AM
Reply to this message Reply
> Achilleas -
>
> > Do you have any idea of how efficient escape analysis
> can
> > be on Java? does it equal hand-coded value types in
> C++?
>
> I do not believe that Java (and any similar runtimes) can
> ever match C/C++ code for speed *if* the C/C++ code is
> well implemented, and the design/coding is based on a
> realistic runtime profile. In other words, if you can
> build a C/C++ system as if it had been iteratively
> designed / implemented / profiled (repeat ad nauseum)
> until it couldn't be any faster, then that's likely to be
> unbeatable by any language runtime machine (e.g. JVM).
>
> For relatively small projects, with engineering teams made
> up of skilled coders with sufficient domain knowledge,
> this is quite do-able (because the profile can be
> intelligently postulated up front).
>
> For larger projects, and/or teams without intricate coding
> skills, I think it's unsafe (code-wise), risky
> (project-wise) and expensive (resource-wise) to attempt
> this.
>
> Advances such as runtime profiling (e.g. Hotspot) combined
> with automatic GC and escape analysis allow a language
> runtime machine to make this trade-off at runtime, i.e. to
> burn CPU cycles and memory to do this analysis and work as
> the application executes, instead of at development time.
>
> For the simplest systems, such as those that run for a
> short duration, the start-up costs (CPU and memory) and
> the deferred returns from profile-based optimizations make
> it clear that this approach is hugely inefficient. (You
> can clearly see this in language performance comparisons
> that include JVM start-up time as part of the measurement
> for programs that run for a fraction of a second.)
>
> For larger systems, and for systems that run for long
> periods of time, the start-up costs are amortized to
> near-zero, and the returns from profile-based
> optimizations are near-impossible to replicate by hand
> coding.

I agree with the above, it seems obvious.

>
> What we lack today is a language / language runtime
> machine that combines the two. Java has a number of design
> flaws (and even more implementation flaws) that
> cumulatively saddle it with start-up processing costs --
> and a significant minimum footprint in terms of memory --
> that eliminate it from a large class of applications.

I couldn't agree more. There is a need for a new programming language with the characteristics you mention.

D is not up to the task yet; it needs to mature a lot.

> I don't personally believe that C/C++ are remotely usable
> for modern application development (an opinion that is
> obviously not universally shared ;-).

Indeed. Even if modern C++ techniques are used (shared pointers, for example), there is still the problem of arrays/pointers and out-of-bounds indexing, which is a major problem. It takes a lot of discipline to use the appropriate classes, but then again you are bounded by the discipline of the developers of the libraries you use.

>
> A language / language runtime _similar_ to Java (etc.)
> could address most of the issues, but it would have to be
> _designed_ to solve them.

And also this language should have a better type system - something like C++ concepts.

Anyone up for the task? :-)

Nemanja Trifunovic

Posts: 172
Nickname: ntrif
Registered: Jun, 2004

Re: Eric Bruno on the G1 Garbage Collector in JDK 6 Posted: Sep 2, 2009 12:34 PM
Reply to this message Reply
> I
> don't personally believe that C/C++ are remotely usable
> for modern application development (an opinion that is
> obviously not universally shared ;-).
>

Depends on your definition of "modern application development" :)

Flat View: This topic has 19 replies on 2 pages [ « | 1  2 ]
Topic: Final list of Project Coin changes for JDK 7 Previous Topic   Next Topic Topic: Creating a Custom Look and Feel for Flex 4 Components

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use