[14] RFR(S): 8224624: Inefficiencies in CodeStrings::add_comment cause timeouts

Tobias Hartmann tobias.hartmann at oracle.com
Tue Aug 20 15:35:29 UTC 2019


Thanks, Vladimir.

Best regards,
Tobias

On 20.08.19 17:24, Vladimir Kozlov wrote:
> Good.
> 
> thanks,
> Vladimir
> 
> On 8/20/19 6:03 AM, Tobias Hartmann wrote:
>> Hi,
>>
>> please review the following patch:
>> https://bugs.openjdk.java.net/browse/JDK-8224624
>> http://cr.openjdk.java.net/~thartmann/8224624/webrev.00/
>>
>> The test that was added with the fix for JDK-8207355 [1] forces C1 to generate hundreds of exception
>> handlers. If CommentedAssembly is enabled, LIR_Assembler::emit_exception_entries adds comments to
>> the assembly code that is generated for these exception adapter blocks [2]. To add the comments to
>> the right offset, CodeStrings::add_comment searches through *all* _code_strings in the CodeBuffer
>> until it finds the last comment with that offset. This is extremely slow with a large amount of code
>> strings (see compile times for the single test method [3]) and is repeated for every new comment
>> that is added.
>>
>> I've fixed this by changing CodeStrings to a doubly-linked-list and searching for the comment with
>> the right offset in reverse (because especially for these exception handlers, we add comments with
>> increasing offset). In addition, the code now maintains the invariant that comments in the linked
>> list a sorted by increasing offset. When reverse-searching the list, we can therefore bail out if we
>> encounter a comment with offset <= the offset we are searching for. This improves C1 compiled time
>> of the test method dramatically from 92s to 1,8s [4].
>>
>> Thanks,
>> Tobias
>>
>>
>> [1] https://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/2018-August/029973.html
>>
>> [2] Commented assembly code for exception adapter blocks:
>> [...]
>>   ;; Exception adapter block
>>    0x00007f2aed9885de:   mov    0x248(%rsp),%rsi
>>   ;;      branch [AL] [B61]
>>    0x00007f2aed9885e6:   jmpq   0x00007f2aed974f0c
>>   ;; Exception adapter block
>>    0x00007f2aed9885eb:   mov    0x240(%rsp),%rsi
>>   ;;      branch [AL] [B63]
>>    0x00007f2aed9885f3:   jmpq   0x00007f2aed974f94
>>   ;; Exception adapter block
>> [...]
>>
>> [3] Compile times without patch:
>>
>> Individual compiler times (for compiled methods only)
>> ------------------------------------------------
>>
>>    C1 {speed: 0 bytes/s; standard:  0,000 s, 0 bytes, 0 methods; osr:  0,000 s, 0 bytes, 0 methods;
>> nmethods_size: 0 bytes; nmethods_code_size: 0 bytes}
>>      C1 Compile Time:       92,966 s
>>         Setup time:            0,000 s
>>         Build HIR:             1,651 s
>>           Parse:                 0,039 s
>>           Optimize blocks:       1,558 s
>>           GVN:                   0,034 s
>>           Null checks elim:      0,002 s
>>           Range checks elim:     0,000 s
>>           Other:                 0,019 s
>>         Emit LIR:              0,237 s
>>           LIR Gen:               0,002 s
>>           Linear Scan:           0,235 s
>>           Other:                 0,000 s
>>         Code Emission:        91,078 s
>>         Code Installation:     0,000 s
>>         Other:                 0,000 s
>>         JVMCI code install time:         0,000 s
>>
>> [4] Compile times with patch:
>> Individual compiler times (for compiled methods only)
>> ------------------------------------------------
>>
>>    C1 {speed: 0 bytes/s; standard:  0,000 s, 0 bytes, 0 methods; osr:  0,000 s, 0 bytes, 0 methods;
>> nmethods_size: 0 bytes; nmethods_code_size: 0 bytes}
>>      C1 Compile Time:        1,849 s
>>         Setup time:            0,000 s
>>         Build HIR:             1,575 s
>>           Parse:                 0,038 s
>>           Optimize blocks:       1,483 s
>>           GVN:                   0,033 s
>>           Null checks elim:      0,002 s
>>           Range checks elim:     0,000 s
>>           Other:                 0,019 s
>>         Emit LIR:              0,228 s
>>           LIR Gen:               0,002 s
>>           Linear Scan:           0,226 s
>>           Other:                 0,000 s
>>         Code Emission:         0,047 s
>>         Code Installation:     0,000 s
>>         Other:                 0,000 s
>>         JVMCI code install time:         0,000 s
>>


More information about the hotspot-compiler-dev mailing list