Does JMH support Tycho?

Bureck, Max max.bureck at fokus.fraunhofer.de
Wed Apr 2 14:11:07 UTC 2014


Hi Aleksey,

Thanks for your quick answer. Let me try to give more details, as far as I can. I am no Tycho developer, just a user, so I can only report my observations. I hope these are helpful.

1) It seems that the dependencies are available on the classpath during compilation. After the maven build I have all class files for the JMH benchmark classes in "target/classes" (including generated classes with "_jmh" name suffixes and black holes and stuff :-) ) and the "target/microbenchmarks.jar" and "benchmark.jar" files exist. But the "target/microbenchmarks.jar" does not include the OSGi dependencies (jar files). I have a main method in one of the classes using the Java API to start the JMH benchmarks and I can take the class files in "target/classes" and run the benchmarks from Eclipse, because the Eclipse runner recognizes that the project is an OSGi project and puts dependencies on the classpath.

2) I am not sure how dependency resolving is done by the Tycho build, but I guess it is needed, because you need not only to find dependent classes for compilation, but also need to respect the package visibility rules (only packages exported from one bundle can be imported by other bundles/made visible to other bundles).

I will create a simple sample project that demonstrates the problem and come back to you.

I guess the Eclipse world will be very interested in Tycho support, since Tycho is an essential component of the "Common Build Infrastructure" at the Eclipse foundation. I myself am committer to the tiny Eclipse UPR project and I would be thrilled to be able to easily use benchmarking there, too. Please refrain from puns about Eclipse needing performance benchmarks badly ;-)

Thanks again for taking the time,
Max

-----Original Message-----
From: Aleksey Shipilev [mailto:aleksey.shipilev at oracle.com] 
Sent: Wednesday, April 02, 2014 12:37 PM
To: Bureck, Max; jmh-dev at openjdk.java.net
Subject: Re: Does JMH support Tycho?

Hi Max,

On 04/02/2014 02:21 PM, Bureck, Max wrote:
> I have a question: I am trying to test some functionality located in 
> an OSGi bundle which uses Tycho for dependency resolution (based on 
> the bundle's manifest file). Unfortunately the benchmark does not 
> include the dependencies resolved by Tycho. Is there a way to make JMH 
> include those dependencies? I don't need any OSGi class loading; the 
> dependent bundles just have to be on the classpath.

I am not familiar with Tycho (and have only a rudimentary understanding of OSGi), so my answer is pure speculation.

There are two facets you should be aware of:

  1) JMH compilation usually requires the dependencies during the compilation; that is, the @GMB-annotated classes should be resolvable on classpath. You can check if that's the case by listing the benchmarks in the final JAR (those would be synthetic generated classes which are calling back into your dependencies).

  2) Once JMH had compiled the benchmarks, it is customary to have the dependencies packed in the single JAR. Can Tycho resolve and bundle the dependencies during the build? (If feels to counter OSGi goals though) Either way, it is not the JMH problem per se, but rather the build  problem.

If you want a more concrete answer, please provide the simple Tycho-driven JMH project which is not working, we can then look closely to what is wrong.

-Aleksey.


More information about the jmh-dev mailing list