RFR: 8319955: Improve dependencies removal during class unloading
Thomas Schatzl
tschatzl at openjdk.org
Tue Nov 14 10:27:26 UTC 2023
On Tue, 14 Nov 2023 07:59:57 GMT, David Holmes <dholmes at openjdk.org> wrote:
> So this batches the operation by moving the batch to the purge list, but it doesn't actually release anything. Who/what will process the purge list and when? The implications of this change in terms of concurrent activities is far from clear.
There is no observable difference (apart from being faster) here - the move of the dependencies from the (single) Klass to the purge list is and has been under the `ClassLoaderData_lock` anyway, locking out "everything" already.
The current basic structure is like:
(indentation means call level)
lock ClassLoaderDataGraph_lock
CLGD::do_unloading()
CLD::unload
foreach (Klass in CLD) {
remove_all_dependents()
}
unlock ClassLoaderDataGraph_lock
The only thing that change is the performance of `remove_all_dependents`, from
void DependencyContext::remove_all_dependents() {
for (all dependents x) {
loadload barrier
cmpxchg x into purge list
}
}
to
void DependencyContext::remove_all_dependents() {
find last pointer of dependents list of the dead(!) Klass, i.e. verified unreachable by the mutator
cmpxchg first/last into purge list
}
Literally no change in locking or the scope of the `ClassLoaderDataGraph_lock`. Everything else is already locked out (for a really long time in that stress test).
The only change is the amount of atomic operations.
Actually, the time to hold the `CLDG_lock` is *much shorter* now as indicated by the numbers in the CR.
The purge list is processed as before at some point afterwards. No change here.
Unfortunately the code still needs to traverse the linked list (and there are really many linked lists here and in nmethod management :( ) which are not very amenable to performance improvements (e.g. parallelization).
It is a non-goal for this CR to change data structures.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/16639#issuecomment-1809932543
More information about the hotspot-gc-dev
mailing list