14

i have a caliper benchmark (1.0-beta-2):

import com.google.caliper.Benchmark;
import com.google.caliper.runner.CaliperMain;

public class MyBenchmark {

    @Benchmark public int a(int rep) {
        return 0;
    }

    public static void main(String[] args) {
        CaliperMain.main(MyBenchmark.class, args);
    }   
}

i run it from eclipse or from command line with:

mvn exec:java -Dexec.mainClass="com.google.caliper.runner.CaliperMain" -Dexec.args="MyBenchmark" 

in both cases i got an error:

ERROR: Trial failed to complete (its results will not be included in the run):
  The worker exited without producing data. It has likely crashed. Inspect /tmp/1427055470061-0/trial-1.log to see any worker output.

in this file i see:

Trial Number: 1
Trial Id: d663a0b5-55b4-43c3-97d8-93f14f436342
Experiment: {instrument=allocation, benchmarkMethod=a, vm=default, parameters={}}

[stderr] CICompilerCount of 1 is invalid; must be at least 2
[stderr] Error: Could not create the Java Virtual Machine.
[stderr] Error: A fatal exception has occurred. Program will exit.

ubuntu 14.04, java:

java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b25)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)

any ideas how to fix it?

piotrek
  • 13,982
  • 13
  • 79
  • 165

2 Answers2

15

i found a solution. flag -XX:-TieredCompilation helps. it can be used directly in microbenchmark java class as:

import com.google.caliper.api.VmOptions;

@VmOptions("-XX:-TieredCompilation")
public class MyMicrobenchmark {
...
piotrek
  • 13,982
  • 13
  • 79
  • 165
  • 1
    This is not good since it significantly changes the default behavior of JVM, and it breaks the main idea of benchmarking: there is no sence in measuring one thing if you run different thing in production. – apangin May 01 '15 at 13:58
  • 2
    I personally suggest using [JMH](http://openjdk.java.net/projects/code-tools/jmh/) instead of Caliper. This tool is developed and used by JVM engineers. – apangin May 01 '15 at 14:00
  • Thank you very much. After adding the VmOption, I forgot to build the class again, and because of that it took me one hour to realize how helpful was your post. – Mehmet Jul 23 '15 at 14:41
4

It's a bug in Caliper. It uses -XX:CICompilerCount=1 as a default JVM argument. However, when Tiered compilation is on, there must be at least 2 compiler threads (one for C1 and one for C2).

Try overriding -XX:CICompilerCount manually with a larger value.

apangin
  • 92,924
  • 10
  • 193
  • 247