# HG changeset patch # User Doug Simon # Date 1387295102 -3600 # Node ID 5a4293f24642cfb51b1d96a6673e52fef7722fda # Parent 5c891b2983c5575378df609e7b3d9d6f0568817b added -G:PrintCompRate option for periodically printing out the current compilation rate diff -r 5c891b2983c5 -r 5a4293f24642 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java Tue Dec 17 16:43:52 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java Tue Dec 17 16:45:02 2013 +0100 @@ -189,6 +189,8 @@ */ void notifyCompilationStatistics(int id, HotSpotResolvedJavaMethod method, boolean osr, int processedBytecodes, long time, long timeUnitsPerSecond, HotSpotInstalledCode installedCode); + void printCompilationStatistics(boolean perCompiler, boolean aggregate); + void resetCompilationStatistics(); void initializeConfiguration(HotSpotVMConfig config); diff -r 5c891b2983c5 -r 5a4293f24642 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java Tue Dec 17 16:43:52 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java Tue Dec 17 16:45:02 2013 +0100 @@ -154,6 +154,8 @@ public synchronized native void notifyCompilationStatistics(int id, HotSpotResolvedJavaMethod method, boolean osr, int processedBytecodes, long time, long timeUnitsPerSecond, HotSpotInstalledCode installedCode); + public synchronized native void printCompilationStatistics(boolean perCompiler, boolean aggregate); + public native void resetCompilationStatistics(); /** diff -r 5c891b2983c5 -r 5a4293f24642 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java Tue Dec 17 16:43:52 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java Tue Dec 17 16:45:02 2013 +0100 @@ -67,6 +67,10 @@ @Option(help = "Print compilation queue activity periodically") private static final OptionValue PrintQueue = new OptionValue<>(false); + @Option(help = "Interval in milliseconds at which to print compilation rate periodically. " + + "The compilation statistics are reset after each print out.") + private static final OptionValue PrintCompRate = new OptionValue<>(0); + @Option(help = "Print bootstrap progress and summary") private static final OptionValue PrintBootstrap = new OptionValue<>(true); @@ -182,6 +186,29 @@ t.start(); } + if (PrintCompRate.getValue() != 0) { + if (!runtime.getConfig().ciTime && !runtime.getConfig().ciTimeEach) { + TTY.println("PrintCompRate requires CITime or CITimeEach"); + } else { + Thread t = new Thread() { + + @Override + public void run() { + while (true) { + runtime.getCompilerToVM().printCompilationStatistics(true, false); + runtime.getCompilerToVM().resetCompilationStatistics(); + try { + Thread.sleep(PrintCompRate.getValue()); + } catch (InterruptedException e) { + } + } + } + }; + t.setDaemon(true); + t.start(); + } + } + BenchmarkCounters.initialize(runtime.getCompilerToVM()); compilerStartTime = System.nanoTime(); diff -r 5c891b2983c5 -r 5a4293f24642 src/share/vm/compiler/compileBroker.cpp --- a/src/share/vm/compiler/compileBroker.cpp Tue Dec 17 16:43:52 2013 +0100 +++ b/src/share/vm/compiler/compileBroker.cpp Tue Dec 17 16:45:02 2013 +0100 @@ -2311,7 +2311,7 @@ } } -void CompileBroker::print_times() { +void CompileBroker::print_times(bool per_compiler, bool aggregate) { #ifdef GRAAL elapsedTimer standard_compilation; elapsedTimer total_compilation; @@ -2331,7 +2331,7 @@ for (unsigned int i = 0; i < sizeof(_compilers) / sizeof(AbstractCompiler*); i++) { AbstractCompiler* comp = _compilers[i]; if (comp != NULL) { - if (!printedHeader) { + if (per_compiler && aggregate && !printedHeader) { printedHeader = true; tty->cr(); tty->print_cr("Individual compiler times (for compiled methods only)"); @@ -2352,11 +2352,13 @@ nmethods_size += stats->_nmethods_size; nmethods_code_size += stats->_nmethods_code_size; + if (per_compiler) { tty->print_cr(" %s {speed: %d bytes/s; standard: %6.3f s, %d bytes, %d methods; osr: %6.3f s, %d bytes, %d methods; nmethods_size: %d bytes; nmethods_code_size: %d bytes}", comp->name(), stats->bytes_per_second(), stats->_standard._time.seconds(), stats->_standard._bytes, stats->_standard._count, stats->_osr._time.seconds(), stats->_osr._bytes, stats->_osr._count, stats->_nmethods_size, stats->_nmethods_code_size); + } } } total_compile_count = osr_compile_count + standard_compile_count; @@ -2378,6 +2380,9 @@ int nmethods_code_size = CompileBroker::_sum_nmethod_size; #endif + if (!aggregate) { + return; + } tty->cr(); tty->print_cr("Accumulated compiler times (for compiled methods only)"); tty->print_cr("------------------------------------------------"); diff -r 5c891b2983c5 -r 5a4293f24642 src/share/vm/compiler/compileBroker.hpp --- a/src/share/vm/compiler/compileBroker.hpp Tue Dec 17 16:43:52 2013 +0100 +++ b/src/share/vm/compiler/compileBroker.hpp Tue Dec 17 16:45:02 2013 +0100 @@ -434,7 +434,7 @@ static void mark_on_stack(); // Print a detailed accounting of compilation time - static void print_times(); + static void print_times(bool per_compiler = true, bool aggregate = true); // Debugging output for failure static void print_last_compile(); diff -r 5c891b2983c5 -r 5a4293f24642 src/share/vm/graal/graalCompilerToVM.cpp --- a/src/share/vm/graal/graalCompilerToVM.cpp Tue Dec 17 16:43:52 2013 +0100 +++ b/src/share/vm/graal/graalCompilerToVM.cpp Tue Dec 17 16:45:02 2013 +0100 @@ -670,6 +670,10 @@ } C2V_END +C2V_VMENTRY(void, printCompilationStatistics, (JNIEnv *jniEnv, jobject, jboolean per_compiler, jboolean aggregate)) +CompileBroker::print_times(per_compiler, aggregate); +C2V_END + C2V_VMENTRY(void, resetCompilationStatistics, (JNIEnv *jniEnv, jobject)) CompilerStatistics* stats = GraalCompiler::instance()->stats(); stats->_standard._time.reset(); @@ -908,6 +912,7 @@ {CC"initializeConfiguration", CC"("HS_CONFIG")V", FN_PTR(initializeConfiguration)}, {CC"installCode0", CC"("HS_COMPILED_CODE HS_INSTALLED_CODE"[Z)I", FN_PTR(installCode0)}, {CC"notifyCompilationStatistics", CC"(I"HS_RESOLVED_METHOD"ZIJJ"HS_INSTALLED_CODE")V", FN_PTR(notifyCompilationStatistics)}, + {CC"printCompilationStatistics", CC"(ZZ)V", FN_PTR(printCompilationStatistics)}, {CC"resetCompilationStatistics", CC"()V", FN_PTR(resetCompilationStatistics)}, {CC"disassembleCodeBlob", CC"(J)"STRING, FN_PTR(disassembleCodeBlob)}, {CC"executeCompiledMethodVarargs", CC"(["OBJECT HS_INSTALLED_CODE")"OBJECT, FN_PTR(executeCompiledMethodVarargs)},