Integrated: 8355769: Optimize nmethod dependency recording

Aleksey Shipilev shade at openjdk.org
Thu May 1 07:33:02 UTC 2025


On Mon, 28 Apr 2025 18:01:42 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

> During nmethod installation, we record the dependencies between InstanceKlass/CallSite and newly coming `nmethod`. In `DependencyContext::add_dependent_nmethod`, we are linearly scanning to see if the `nmethod` is already in the dependencies list. This costs quite a bit, especially with lots of compiled methods per IK.
> 
> This is not a significant issue for normal JIT compilations, where the JIT costs dominate. But for Leyden, this kind of scan is a significant part of AOT code installation. For example in well-trained javac runs, there are chains of 500+ `nmethods` for some IKs that take 10+ us to scan. This is easily half of the entire AOT method installation cost.
> 
> Fortunately, the way we do the nmethod dependency recording, it allows us to shortcut the scan. Since dependency recording holds the `CodeCache_lock` while adding new `nmethod` all over the various dependency lists, those dependency lists are ever in two states: no `nmethod` in the chain (no need to scan!), or `nmethod` is at the head of the chain (no need to scan!). 
> 
> Additional testing:
>  - [x] Ad-hoc benchmarks
>  - [x] Linux x86_64 server fastdebug, `all`
>  - [x] Linux AArch64 server fastdebug, `all`

This pull request has now been integrated.

Changeset: 8ef7e256
Author:    Aleksey Shipilev <shade at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/8ef7e256a09115b475601b621c9b6842185289d0
Stats:     31 lines in 3 files changed: 24 ins; 2 del; 5 mod

8355769: Optimize nmethod dependency recording

Reviewed-by: adinn, vlivanov, kvn

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

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


More information about the hotspot-compiler-dev mailing list