RFR: 8317007: Add bulk removal of dead nmethods during class unloading [v7]
Albert Mingkun Yang
ayang at openjdk.org
Fri Dec 15 13:50:42 UTC 2023
On Fri, 15 Dec 2023 12:24:01 GMT, Thomas Schatzl <tschatzl at openjdk.org> wrote:
>> Hi all,
>>
>> please review this change that bulk-removes dead nmethods for the STW collectors instead of unregistering nmethod by nmethod. This significantly speeds up the class unloading phase.
>>
>> For G1, this is almost 100% the code that has been removed from the review for JDK-8315503.
>>
>> For Serial and Parallel GC, the code is new.
>>
>> This change does not try to improve the situation for concurrent collectors - this would at first glance require extending the scope of the `CodeCache_lock` which I did not want to do. See the CR for more details.
>>
>> Also, no parallelism for Parallel GC: the existing data structure for code root remembered set is a linked list. There is in almost all cases no point in trying to parallelize what is basically a traversal of the linked list (with each element not having a lot of work to do). I filed JDK-8320067. There should already be a significant speedup with this change, as each `unregister_nmethod` call previously traversed the entire linked list to find that element (i.e. complexity reduction of O(n^2) -> O(n)).
>>
>> One more comment:
>>
>> * So it would be possible to merge the `ScavengableNMethod::prune_nmethods_not_into_young` which removes elements from the code root sets that do no longer need to be remembered (due to object movement) with removing dead/unlinked nmethods. However, this would mean to put that class unloading code to the end of gc as during phase 1 the new locations which are relevant for pruning uninteresting code root remembered set entries did not move yet. I wanted to keep determining the unlinking nmethods and class/code unloading them together in the code, but I could be convinced to move it.
>>
>> Testing: tier1-4
>>
>> Depends on #16759, please review first.
>>
>> Thanks,
>> Thomas
>
> Thomas Schatzl has updated the pull request incrementally with one additional commit since the last revision:
>
> iwalulya review, renamings
Marked as reviewed by ayang (Reviewer).
src/hotspot/share/code/nmethod.cpp line 1469:
> 1467:
> 1468: if (unregister_nmethod) {
> 1469: assert(!free_code_cache_data, "must not free when postponing unregistering");
This assert is obsolete given the same one at the beginning.
src/hotspot/share/code/nmethod.cpp line 1476:
> 1474:
> 1475: CodeBlob::purge(free_code_cache_data, unregister_nmethod);
> 1476: if (free_code_cache_data) {
This is effectively `true`.
-------------
PR Review: https://git.openjdk.org/jdk/pull/16767#pullrequestreview-1784068816
PR Review Comment: https://git.openjdk.org/jdk/pull/16767#discussion_r1427993410
PR Review Comment: https://git.openjdk.org/jdk/pull/16767#discussion_r1427993809
More information about the hotspot-gc-dev
mailing list