RFR: 8357258: x86: Improve receiver type profiling reliability

Aleksey Shipilev shade at openjdk.org
Fri Sep 5 11:45:20 UTC 2025


On Mon, 19 May 2025 14:59:36 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

> See the bug for discussion what issues current machinery has. 
> 
> This PR executes the plan outlined in the bug:
>  1. Common the receiver type profiling code in interpreter and C1
>  2. Rewrite receiver type profiling code to only do atomic receiver slot installations
>  3. Trim `C1OptimizeVirtualCallProfiling` to only claim slots when receiver is installed 
> 
> This PR does _not_ do atomic counter updates themselves, as it may have much wider performance implications, including regressions. This PR should be at least performance neutral.
> 
> Additional testing:
>   - [x] Linux x86_64 server fastdebug, `compiler/`
>   - [ ] Linux x86_64 server fastdebug, `all`

In addition to reliability improvements, doing a denser loop allows to significantly optimize tier3 code density. With larger `TypeProfileWidth`, type profile checks are the significant part of generated code. This density improvement allows us to do the CAS without increasing the code size. It also allows us to store (more) tier3 code in AOTCache going forward. If/when folks (looking at @theRealAph, really) start doing probabilistic profiling counters, this budget increase would also help to cram in more code.


$ for I in 1 2 3 4; do build/linux-x86_64-server-release/images/jdk/bin/java -XX:TieredStopAtLevel=${I} \
  -Xcomp -XX:+CITime -Xmx2g Hello.java 2>&1 | grep "Tier${I}" | cut -d' ' -f 3,23-; done

=== -XX:TypeProfileWidth=2 (default)

# Baseline
Tier1 nmethods_code_size:  7091616 bytes
Tier2 nmethods_code_size:  7579424 bytes
Tier3 nmethods_code_size: 17494984 bytes
Tier4 nmethods_code_size:  6058128 bytes

# Patched
Tier1 nmethods_code_size:  7091648 bytes
Tier2 nmethods_code_size:  7581808 bytes
Tier3 nmethods_code_size: 16806440 bytes (-4.1%)
Tier4 nmethods_code_size:  6057920 bytes

=== -XX:TypeProfileWidth=8 (default with +UseJVMCICompiler)

# Baseline
Tier1 nmethods_code_size:  7091672 bytes
Tier2 nmethods_code_size:  7580576 bytes
Tier3 nmethods_code_size: 28096448 bytes
Tier4 nmethods_code_size:  6061280 bytes

# Patched
Tier1 nmethods_code_size:  7090760 bytes
Tier2 nmethods_code_size:  7579432 bytes
Tier3 nmethods_code_size: 16837688 bytes (-66.7% !!!)
Tier4 nmethods_code_size:  6058104 bytes

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

PR Comment: https://git.openjdk.org/jdk/pull/25305#issuecomment-3258049226


More information about the hotspot-compiler-dev mailing list