RFR: 8255746: Make PrintCompilation available on a per method level

Joshua Cao duke at openjdk.org
Wed Oct 12 13:25:10 UTC 2022


On Wed, 12 Oct 2022 07:18:04 GMT, Christian Hagedorn <chagedorn at openjdk.org> wrote:

>> Example:
>> 
>> 
>> [~/jdk/jdk]$ build/linux-x86_64-server-fastdebug/jdk/bin/java -XX:CompileCommand=PrintCompilation,java.lang.String::length Hello
>> CompileCommand: PrintCompilation java/lang/String.length bool PrintCompilation = true
>>     223   12       3       java.lang.String::length (11 bytes)
>>     405  307       4       java.lang.String::length (11 bytes)
>> hello world
>> 
>> 
>> Running `java -XX:+PrintCompilation` still prints every method. This change also moves the declaration of `elapsedTimer`, but it should have insignificant impact on actual elapsed time.
>> 
>> ---
>> 
>> Additionally, I make a change to `test/lib-test/jdk/test/whitebox/vm_flags/BooleanTest.java` so that it does not depend on PrintCompilation. The test was failing because it updates global `PrintCompilation` during the middle of the run, but this does not change the value of `PrintCompilationOption` for individual CompileTask directives.
>> 
>> I modified the test so that it is similar to other [WhiteBox vm_flag test](https://github.com/openjdk/jdk/tree/master/test/lib-test/jdk/test/whitebox/vm_flags). It still tests `VmFlagTest.WHITE_BOX::get/setBooleanVMFlag`, without having to depend on the behavior on the specific flag.
>
> src/hotspot/share/compiler/compileBroker.cpp line 2138:
> 
>> 2136:     task->print_tty();
>> 2137:   }
>> 2138:   elapsedTimer time;
> 
> Shouldn't this timer start at the very top of the method? Printing needs time but it kinda adds to the compilation time, so it's probably not wrong to count that time as well when explicitly using print flags.

I've kept it this way because the timer was started after printing prior to this change as well. If a dev is benchmarking compilation time, it is better to not include the timer. Printing adds noise that is not there during real-world runs.

-------------

PR: https://git.openjdk.org/jdk/pull/10668


More information about the hotspot-compiler-dev mailing list