Re: bottleneck by java.lang.Class.getAnnotations() - rebased patch

2012-12-12 Thread David Holmes
Peter, Many thanks for preparing that patch. As we're leaving annotations behind lets continue any further discussion of this patch in a new email thread specific to JEP-149. I'll run this patch through some basic testing and performance benchmarks. The JEP will also need updating so I'll be

Re: bottleneck by java.lang.Class.getAnnotations() - rebased patch

2012-12-12 Thread Mandy Chung
Hi Peter, On 12/12/12 4:31 AM, Peter Levart wrote: Hi all, Ok, no problem. So here's a patch that summarizes what I did in the previous patch, but only for reflective fields (Field[], Method[], Constructor[]) not including annotations: http://dl.dropbox.com/u/101777488/jdk8-tl/JEP-149.c/web

Re: bottleneck by java.lang.Class.getAnnotations() - rebased patch

2012-12-12 Thread Peter Levart
On 12/12/2012 04:34 PM, Peter Levart wrote: On 12/12/2012 11:59 AM, Joel Borggrén-Franck wrote: Hi all, First, thanks all of you that are involved in this! I agree with David here, lets split this up (for now) and do reflective objects in the context of jep-149 and annotations separately. A

Re: bottleneck by java.lang.Class.getAnnotations() - rebased patch

2012-12-12 Thread Peter Levart
On 12/12/2012 11:59 AM, Joel Borggrén-Franck wrote: Hi all, First, thanks all of you that are involved in this! I agree with David here, lets split this up (for now) and do reflective objects in the context of jep-149 and annotations separately. As you may know there are even more annotation

Re: bottleneck by java.lang.Class.getAnnotations() - rebased patch

2012-12-12 Thread Peter Levart
Hi all, Ok, no problem. So here's a patch that summarizes what I did in the previous patch, but only for reflective fields (Field[], Method[], Constructor[]) not including annotations: http://dl.dropbox.com/u/101777488/jdk8-tl/JEP-149.c/webrev/index.html The annotations part is unchanged sem

Re: bottleneck by java.lang.Class.getAnnotations() - rebased patch

2012-12-12 Thread Joel Borggrén-Franck
Hi all, First, thanks all of you that are involved in this! I agree with David here, lets split this up (for now) and do reflective objects in the context of jep-149 and annotations separately. As you may know there are even more annotation coming in with JSR 308 annotations on type (use), so

Re: bottleneck by java.lang.Class.getAnnotations() - rebased patch

2012-12-10 Thread Joe Darcy
Hi Peter, On 12/10/2012 02:23 PM, Peter Levart wrote: Hi David, Joe, I unpacked the src.zip of the first release of JDK 1.5.0. Here's the relevant part: private transient Map annotations; private transient Map declaredAnnotations; private synchronized void initAnnotationsIfNeces

Re: bottleneck by java.lang.Class.getAnnotations() - rebased patch

2012-12-10 Thread Peter Levart
Hi David, Joe, I unpacked the src.zip of the first release of JDK 1.5.0. Here's the relevant part: private transient Map annotations; private transient Map declaredAnnotations; private synchronized void initAnnotationsIfNecessary() { if (annotations != null) re

Re: bottleneck by java.lang.Class.getAnnotations() - rebased patch

2012-12-10 Thread Joe Darcy
Yes; the OpenJDK sources only go back to circa 2007, which was part-way into the JDK 7 release. The exact changesets of how annotations were added back in JDK 5 are not available publicly. However, the final results of that process may be mostly visible in the src.zip from JDK 5. HTH, -Joe

Re: bottleneck by java.lang.Class.getAnnotations() - rebased patch

2012-12-10 Thread Peter Levart
Ok, I've got it. Downloaded j2sdk1.4_19 and unpacked src.zip ... There are SoftReferences for individual Field/Method/Constructor arrays: // Caches for certain reflective results private static boolean useCaches = true; private volatile transient SoftReference declaredFields; pri

Re: bottleneck by java.lang.Class.getAnnotations() - rebased patch

2012-12-10 Thread Peter Levart
Hi David, It would be informative to look at how java.lang.Class evolved during history. The oldest revision I can access is from 1st of Dec. 2007, which already contains Java 1.5 code (annotations) and is more or less unchanged until now. The most interesting changesets would be those that i

Re: bottleneck by java.lang.Class.getAnnotations() - rebased patch

2012-12-10 Thread Peter Levart
On 12/10/2012 07:18 AM, David Holmes wrote: Hi Peter, Sorry for the delay on this. Thank you for taking it into consideration. I can only imagine how busy you are with other things. Generally your VolatileData and my ReflectionHelper are doing a similar job. But I agree with your reasoni

Re: bottleneck by java.lang.Class.getAnnotations() - rebased patch

2012-12-09 Thread David Holmes
Hi Peter, Sorry for the delay on this. Generally your VolatileData and my ReflectionHelper are doing a similar job. But I agree with your reasoning that all of the cached SoftReferences are likely to be cleared at once, and so a SoftReference to a helper object with direct references, is more

Re: bottleneck by java.lang.Class.getAnnotations() - rebased patch

2012-12-02 Thread Peter Levart
Hi David, Alan, Alexander and others, In the meanwhile I have added another annotations space optimization to the patch. If a Class doesn't inherit any annotations from a superclass, which I think is a common case, it assigns the same Map instance to "annotations" as well as "declaredAnnotatio

Re: bottleneck by java.lang.Class.getAnnotations() - rebased patch

2012-12-02 Thread David Holmes
On 1/12/2012 4:54 AM, Alan Bateman wrote: On 30/11/2012 18:36, Peter Levart wrote: : So, what do you think? What kind of tests should I prepare in addidion to those 3 so that the patch might get a consideration? I think this is good work and thanks for re-basing your patch. I know David plans

Re: bottleneck by java.lang.Class.getAnnotations() - rebased patch

2012-11-30 Thread Alan Bateman
On 30/11/2012 18:36, Peter Levart wrote: : So, what do you think? What kind of tests should I prepare in addidion to those 3 so that the patch might get a consideration? I think this is good work and thanks for re-basing your patch. I know David plans to do a detail review. I think it will req

Re: bottleneck by java.lang.Class.getAnnotations() - rebased patch

2012-11-30 Thread Peter Levart
Hi Alan, David, Alexander and others, I noticed the push of Joe Darcy's code for repeating annotations which makes my proposed patch not entirely compatible with new code. So I rebased the patch to current code in jdk8/tl/jdk repository. I had to revert my last improvement (the replacement of

Re: bottleneck by java.lang.Class.getAnnotations() - a better patch

2012-11-23 Thread Peter Levart
Hi again, I have found an inconsistency in the last patch I posted. Specifically the Method.getAnnotation(Class) and Constructor.getAnnotation(Class) did not delegate to the root instance as .getAnnotations() did. I corrected that in new revision of the patch: http://dl.dropbox.com/u/1017774

Re: bottleneck by java.lang.Class.getAnnotations() - a better patch

2012-11-23 Thread Peter Levart
Hi David, Alan, Alexander and others, Here's a refinement of a patch I proposed in this thread a couple of weeks ago: http://dl.dropbox.com/u/101777488/jdk8-hacks/JEP-149/webrev.02/index.html The changed sources can be browsed here: https://github.com/plevart/jdk8-hacks/tree/annotation-array

Re: bottleneck by java.lang.Class.getAnnotations() - a better patch

2012-11-07 Thread Peter Levart
Hi all, I have redone the static memory footprint comparison calculations (taking correct object headers and padding into account) and I hope this time I've done it right. Here's what I got: 64bit addressing (16 byte object header): patched Class uses 76 bytes less than original Class when e

Re: bottleneck by java.lang.Class.getAnnotations() - proposed patch

2012-11-07 Thread Martin Buchholz
On Wed, Nov 7, 2012 at 11:02 AM, Peter Levart wrote: > On 11/07/2012 06:59 PM, Martin Buchholz wrote: > > We've also seen deadlocks in accessing annotations in the wild. > So, many thanks for working on this (both performance improvements and > deadlock removal). > We don't have a test case to c

Re: bottleneck by java.lang.Class.getAnnotations() - proposed patch

2012-11-07 Thread Peter Levart
On 11/07/2012 06:59 PM, Martin Buchholz wrote: We've also seen deadlocks in accessing annotations in the wild. So, many thanks for working on this (both performance improvements and deadlock removal). We don't have a test case to contribute, but here's a stacktrace: That's one thread. What abo

Re: bottleneck by java.lang.Class.getAnnotations() - proposed patch

2012-11-07 Thread Martin Buchholz
We've also seen deadlocks in accessing annotations in the wild. So, many thanks for working on this (both performance improvements and deadlock removal). We don't have a test case to contribute, but here's a stacktrace: sun.reflect.annotation.AnnotationType.getInstance(AnnotationType.java:80)

Re: bottleneck by java.lang.Class.getAnnotations() - proposed patch

2012-11-07 Thread Peter Levart
On 11/06/2012 08:37 AM, Peter Levart wrote: Hi all, I have prepared a better patch. It addresses the goals of JEP-149 more seriously. I also have some benchmarks. Stay tuned... Regards, Peter For easier viewing, here's also a webrev: http://dl.dropbox.com/u/101777488/jdk8-hacks/JEP-149/

Re: bottleneck by java.lang.Class.getAnnotations() - a better patch

2012-11-07 Thread Peter Levart
On 11/07/2012 03:10 AM, David Holmes wrote: Hi Peter, The movement of the reflection caches to a helper object is exactly what I had previously proposed here (some differences in the details of course): http://cr.openjdk.java.net/~dholmes/JEP-149/webrev/ and discussed here: http://mail.ope

Re: bottleneck by java.lang.Class.getAnnotations() - a better patch

2012-11-06 Thread David Holmes
Hi Peter, The movement of the reflection caches to a helper object is exactly what I had previously proposed here (some differences in the details of course): http://cr.openjdk.java.net/~dholmes/JEP-149/webrev/ and discussed here: http://mail.openjdk.java.net/pipermail/core-libs-dev/2012-Apr

Re: bottleneck by java.lang.Class.getAnnotations() - a better patch

2012-11-06 Thread Peter Levart
On 11/06/2012 03:00 PM, Alan Bateman wrote: Peter, I haven't studied your patch yet but moving the fields into a helper class is what was envisaged. Here's another reminder that the initialization has been crying out to be re-worked for some time: http://bugs.sun.com/view_bug.do?bug_id=71221

Re: bottleneck by java.lang.Class.getAnnotations() - a better patch

2012-11-06 Thread Alan Bateman
Peter, I haven't studied your patch yet but moving the fields into a helper class is what was envisaged. Here's another reminder that the initialization has been crying out to be re-worked for some time: http://bugs.sun.com/view_bug.do?bug_id=7122142 -Alan.

Re: bottleneck by java.lang.Class.getAnnotations() - a better patch

2012-11-06 Thread Peter Levart
On 11/05/2012 06:23 AM, David Holmes wrote: Hi Peter, Moving the annotations fields into a helper object would tie in with the Class-instance size reduction effort that was investigated as part of "JEP 149: Reduce Core-Library Memory Usage": http://openjdk.java.net/jeps/149 The investigatio

Re: bottleneck by java.lang.Class.getAnnotations() - proposed patch

2012-11-05 Thread Peter Levart
Hi all, I have prepared a better patch. It addresses the goals of JEP-149 more seriously. I also have some benchmarks. Stay tuned... Regards, Peter On Nov 6, 2012 2:29 AM, "David Holmes" wrote: > Hi Alex, > > On 5/11/2012 11:36 PM, Alexander Knöller wrote: > >> Hi David. >> >> What about my pro

Re: bottleneck by java.lang.Class.getAnnotations() - proposed patch

2012-11-05 Thread David Holmes
Hi Alex, On 5/11/2012 11:36 PM, Alexander Knöller wrote: Hi David. What about my proposal for a simple double-checked-locking for the redefinitions fields and the use of local variables for "annotations" in getAnnotations() and initAnnotationsIfNecessary() ? Sorry I thought Peter's proposed

Re: bottleneck by java.lang.Class.getAnnotations() - proposed patch

2012-11-05 Thread Alexander Knöller
Hi David. What about my proposal for a simple double-checked-locking for the redefinitions fields and the use of local variables for "annotations" in getAnnotations() and initAnnotationsIfNecessary() ? Are additional local Variables similar "bad habit" for memory usage (although they only affect

Re: bottleneck by java.lang.Class.getAnnotations()

2012-11-05 Thread Alan Bateman
On 04/11/2012 20:27, Peter Levart wrote: : I digress. Javadocs say: "The redefinition may change method bodies, the constant pool and attributes. The redefinition must not add, remove or rename fields or methods, change the signatures of methods, or change inheritance. These restrictions maybe

Re: bottleneck by java.lang.Class.getAnnotations() - proposed patch

2012-11-04 Thread David Holmes
Hi Peter, Moving the annotations fields into a helper object would tie in with the Class-instance size reduction effort that was investigated as part of "JEP 149: Reduce Core-Library Memory Usage": http://openjdk.java.net/jeps/149 The investigations there to date only looked at relocating th

Re: bottleneck by java.lang.Class.getAnnotations() - proposed patch

2012-11-04 Thread Peter Levart
Hi, I propose the following patch to java.lang.Class in order to overcome the synchronization bottleneck when accessing annotations from multiple threads. The patch packs the 'annotations' and 'declaredAnnotations' Maps together with an int redefinedCount into a structure: static class A

Re: bottleneck by java.lang.Class.getAnnotations()

2012-11-04 Thread Peter Levart
he lock on initAnnotationsIfNecessary()). Regards Alex Anfang der weitergeleiteten E-Mail: Von: Alexander Knöller Betreff: Re: bottleneck by java.lang.Class.getAnnotations() Datum: 2. November 2012 08:43:06 MEZ An: Joe Darcy Kopie: Alan Bateman , [email protected] I know. But there is a usual s

Re: bottleneck by java.lang.Class.getAnnotations()

2012-11-02 Thread Peter Levart
Anfang der weitergeleiteten E-Mail: Von: Alexander Knöller Betreff: Re: bottleneck by java.lang.Class.getAnnotations() Datum: 2. November 2012 08:43:06 MEZ An: Joe Darcy Kopie: Alan Bateman , [email protected] I know. But there is a usual solution to those kind of problems: double checked locking.