RFR: 8299061: Using lambda to optimize GraphKit::compute_stack_effects()

Kim Barrett kbarrett at openjdk.org
Tue Dec 20 09:43:49 UTC 2022


On Tue, 20 Dec 2022 07:18:05 GMT, Xin Liu <xliu at openjdk.org> wrote:

> Some bytecodes donot need rsize in GraphKit::compute_stack_effects(). 
> This change defines rsize as a lambda and avoid computation if it's not in use. 
> 
> We utilize CTW($openjdk/test/hotspot/jtreg/testlibrary/ctw/dist) to test this patch.
> We compile 2 builtin modules: java.base and jdk.compiler(javac).
> 
> 
> JAVA_OPTIONS="-XX:+CITime -XX:-TieredCompilation" ./ctw.sh modules:java.base
> JAVA_OPTIONS="-XX:+CITime -XX:-TieredCompilation" ./ctw.sh modules:jdk.compiler
> 
> 
> For java.base module, the average compilation speed increases from 12011 bytes/s to 12301 bytes/s, or +2.41%.
> For jdk.compiler module, the average compilation speed is almost same(+0.16%)
> 
> 
> | java.base                 | before    | after     |diff   |
> |---------------------------|-----------|-----------|-------|
> | C2 Compile Time(s)        | 333.767   | 325.939   |       |
> | Parse Time(s)             | 123.076   | 120.976   |       |
> | ratio                     | 36.87%    | 37.12%    |       |
> | throughput(bytes/s)*      | 12073.418 | 12368.028 | 2.44% |
> | Average compilation speed | 12011     | 12301     | 2.41% |
> | Total compiled methods    | 58151     | 58145     |       |
> 
> 
> | jdk.compiler              | before    | after     |diff   |
> |---------------------------|-----------|-----------|-------|
> | C2 Compile Time(s)        | 66.313    | 66.196    |       |
> | Parse Time(s)             | 21.681    | 21.445    |       |
> | ratio                     | 32.69%    | 32.40%    |       |
> | throughput(bytes/s)       | 14350.804 | 14399.76  | 0.34% |
> | Average compilation speed | 13255     | 13276     | 0.16% |
> | Total compiled methods    | 13729     | 13733     |       |
> 
> 
> *Throughtput is reported from Tier4 row. It's very close to 'Average compilation speed' but not exactly same. eg. here is from java.base module.
> 
> 
> before:
>   Tier4 {speed: 12073.418 bytes/s; standard: 332.362 s, 4004535 bytes, 58121 methods; osr:  0.327 s, 12154 bytes, 30 methods; nmethods_size: 52104768 bytes; nmethods_code_size: 32117912 bytes}
> after:
>   Tier4 {speed: 12368.028 bytes/s; standard: 324.500 s, 4004111 bytes, 58113 methods; osr:  0.344 s, 13565 bytes, 32 methods; nmethods_size: 52110000 bytes; nmethods_code_size: 32118984 bytes}

Changes requested by kbarrett (Reviewer).

src/hotspot/share/opto/graphKit.cpp line 1027:

> 1025: 
> 1026:   auto rsize = [&]() {
> 1027:     BasicType rtype = T_ILLEGAL;

Rather than initializing `rtype` to a dummy value and then almost immediately assigning `rtype`, just initialize `rtype` properly to begin with.

src/hotspot/share/opto/graphKit.cpp line 1032:

> 1030:     rtype = Bytecodes::result_type(code); // checkcast=P, athrow=V
> 1031:     if (rtype < T_CONFLICT)
> 1032:       sz = type2size[rtype];

[pre-existing] Missing braces around the consequent.  Maybe write this instead as

if (rtype < T_CONFLICT) {
  return type2size[rtype];
} else {
  return 0;
}

avoiding the introduction of the `sz` variable.

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

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


More information about the hotspot-compiler-dev mailing list