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

Peter Levart peter.levart at gmail.com
Mon Dec 3 07:41:20 UTC 2012


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 "declaredAnnotations" fields. Previously - and 
in the original code - this only happened for java.lang.Object and 
interfaces.

Here's the updated webrev:

http://dl.dropbox.com/u/101777488/jdk8-tl/JEP-149/webrev.02/index.html

I have also rewritten the performance micro-benchmarks. With the 
addition of repeating annotations, one performance aspect surfaces: when 
asking for a particular annotation type on a Class and that annotation 
is not present, the new repeating annotations support method 
AnnotationSupport.getOneAnnotation asks for @ContainedBy meta-annotation 
on the annotation type. This can result in an even more apparent 
synchronization hot-spot with original code that uses synchronized 
initAnnotationsIfNecessary(). This aspect is tested with the 3rd test. 
Other 2 tests test the same thing as before but are more stable now, 
since now they measure retrieval of 5 different annotation types from 
each AnnotatedElement, previously they only measured retrieval of 1 
which was very sensitive to HashMap irregularities (it could happen that 
a particular key mapped to a bucket that was overloaded in one test-run 
and not in another)...

Here're the new tests:

https://raw.github.com/plevart/jdk8-tl/JEP-149/test/src/test/ReflectionTest.java

And the corresponding results when run on an i7 CPU on Linux:

https://raw.github.com/plevart/jdk8-tl/JEP-149/test/benchmark_results_i7-2600K.txt


Regards, Peter



On 12/03/2012 02:15 AM, David Holmes wrote:
> 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 to do a detail review. I think it will require extensive
>> performance testing too, perhaps with some large applications.
>
> Indeed I do plan a detailed review and have initiated some initial 
> performance tests.
>
> I am also swamped but will try to get to the review this week - and 
> will also need to check the referenced annotations updates.
>
> David
>
>> -Alan
>>




More information about the core-libs-dev mailing list