[concurrency-interest] @Contended (JEP-142)

Doug Lea dl at cs.oswego.edu
Tue Nov 27 15:13:28 EST 2012

On 11/27/12 13:46, Kasper Nielsen wrote:
> 1)
> Without having read Alekseys previous post to hotspot-dev I would have had a
> hard time figuring how the group stuff would work.
> While the layout might not be identical on platforms with different cache-line
> sizes. I think the examples might be worth including in the javadoc

Yes indeed. We'd like to have good, appropriate examples so that
people not only see what's up, but also get a good sense of when
@Contended is warranted. Ideas about self-contained examples
are welcome. There are a few possible from inside j.u.c (that we
will adapt to use @Contended) but we can probably do better,
especially with all the concern out there that the wrong people
will try to use @Contended for the wrong reasons.

> 2)
> I'm fine with sun.misc. But wouldn't it make sense to introduce a vm package
> (for example, java.lang.vm) which contains vm/cpu integration classes.

Maybe JDK9 modularity will force this. But until then,
you might as well think of sun.misc as a standin for this --
functionality that no one wants to make part of the Java spec
proper, but everyone still wants all JVMs to support.

> 3)
> It probably already is, but I'm just making sure Instrumentation#getObjectSize()
> returns the correct number.

(I'll let Aleksey answer this.)


> I know it is probably out of scope for Java 8 but some tools (without requiring
> an agent class) for calculating the object size is missing. I lot of projects
> goes through a lot of trouble to calculate the size. See for example
> http://www.codespot.net/blog/2012/01/measuring-java-object-sizes/ or just google
> 'calculate java object size'. These alternative methods are only going to be
> more broken after introducing @Contended, especially the reflection based once.
> Perhaps adding the method #getObjectSize() to sun.misc.Unsafe for now would help.
> Cheers
>    Kasper
> On Tue, Nov 27, 2012 at 6:40 PM, Doug Lea <dl at cs.oswego.edu
> <mailto:dl at cs.oswego.edu>> wrote:
>     Aleksey has been making progress on a hotspot implementation of
>     the @Contended annotation. While this progresses, we'd also
>     like continued feedback about the java-level information, guidance,
>     examples, etc.
>     As a compromise that helps avoid controversy about its status
>     and specs, the @Contended annotation itself will probably be placed
>     in sun.misc, not java.util.concurrent.*. A staging version of
>     Contended.java is in our CVS though, with javadoc at:
>     http://gee.cs.oswego.edu/dl/__jsr166/src/dl/sun/misc/sun/__misc/Contended.html
>     <http://gee.cs.oswego.edu/dl/jsr166/src/dl/sun/misc/sun/misc/Contended.html>
>     Any comments and suggestions will be welcome.
>     -Doug
>     _________________________________________________
>     Concurrency-interest mailing list
>     Concurrency-interest at cs.__oswego.edu <mailto:Concurrency-interest at cs.oswego.edu>
>     http://cs.oswego.edu/mailman/__listinfo/concurrency-interest
>     <http://cs.oswego.edu/mailman/listinfo/concurrency-interest>

More information about the Concurrency-interest mailing list