Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JMH and use of Blackhole #1205

Closed
benjchristensen opened this issue May 16, 2014 · 8 comments
Closed

JMH and use of Blackhole #1205

benjchristensen opened this issue May 16, 2014 · 8 comments

Comments

@benjchristensen
Copy link
Member

I was discussing JMH with @shipilev and he brought this to my attention while informing me our use of JMH may not be quite right: http://hg.openjdk.java.net/code-tools/jmh/file/48d149ac3218/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_28_BlackholeHelpers.java

Opening this issue to track it and get our JMH input class improved: https://github.com/Netflix/RxJava/blob/master/rxjava-core/src/perf/java/rx/jmh/InputWithIncrementingInteger.java#L74

@shipilev
Copy link

This should suffice:

      dependencies {
 -        perfCompile 'org.openjdk.jmh:jmh-core:0.5.3'
 -        perfCompile 'org.openjdk.jmh:jmh-generator-annprocess:0.5.3'
 +        perfCompile 'org.openjdk.jmh:jmh-core:0.7.1'
 +        perfCompile 'org.openjdk.jmh:jmh-generator-annprocess:0.7.1'
          //perfCompile project
      }

...and:

   private CountDownLatch latch;

      @Setup
 -    public void setup() {
 +    public void setup(final BlackHole bh) {
          observable = Observable.create(new OnSubscribe<Integer>() {
              @Override
              public void call(Subscriber<? super Integer> o) {
 @@ -55,7 +55,6 @@
              }
          });

 -        final BlackHole bh = new BlackHole();
          latch = new CountDownLatch(1);

          observer = new Observer<Integer>() {

@daschl
Copy link
Contributor

daschl commented May 16, 2014

I know that this needs to be passed in, but is it in this case because of DCE (the hole itself would be removed rendering the other part dead too?) @shipilev

@shipilev
Copy link

Yes, Blackhole itself is DCE-d, along with the computation it consumes.

With JMH 0.6+, the attempt to instantiate Blackhole directly will throw: http://hg.openjdk.java.net/code-tools/jmh/rev/de0365d7e4d0 (see the comment there for rationale). Therefore, if there are benchmarks which fail after updating the JMH version, you know what to fix :)

@daschl
Copy link
Contributor

daschl commented May 17, 2014

@shipilev alright staying cool ;). Thanks!

@daschl
Copy link
Contributor

daschl commented May 20, 2014

@benjchristensen should I take this on?

@benjchristensen
Copy link
Member Author

Thanks @shipilev for the information.

Yes @daschl If you can take this on I'd appreciate it.

@shipilev
Copy link

While you are at it, you may want to update to 0.7.2.

@benjchristensen
Copy link
Member Author

Finished upgrading to 0.7.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants