RFR: 8311248: Refactor CodeCache::initialize_heaps to simplify adding new CodeCache segments [v4]
Evgeny Astigeevich
eastigeevich at openjdk.org
Tue Jan 23 22:06:30 UTC 2024
On Thu, 18 Jan 2024 17:08:29 GMT, Boris Ulasevich <bulasevich at openjdk.org> wrote:
>> These changes clean up the logic and the code of allocating codecache segments and add more testing of it, to open a door for further optimization of code cache segmentation. The goal was to keep the behavior as close to the existing behavior as possible, even if it's not quite logical.
>>
>> Also, these changes better account for alignment - PrintFlagsFinal shows the final aligned segment sizes, and the segments fill the ReservedCodeCacheSize without gaps caused by alignment.
>
> Boris Ulasevich has refreshed the contents of this pull request, and previous commits have been removed. The incremental views will show differences compared to the previous content of the PR. The pull request contains one new commit since the last revision:
>
> apply suggestions
src/hotspot/share/code/codeCache.cpp line 281:
> 279: if (!profiled.set && non_profiled.set) {
> 280: profiled.size = subtract_size(cache_size, non_nmethod.size + non_profiled.size, min_size);
> 281: }
`subtract_size` can do subtracting or nothing by return `min_size`. This is not obvious from its name.
What about a function:
// Precondition: either or both of heaps must be set.
//
// If either of heaps size is not set, its size is set to max(available_size - set_heap.size, min_size).
static void set_size_of_unset_code_heap(CodeHeapInfo *heap1, CodeHeapInfo *heap2, size_t available_size, size_t min_size) {
assert(...); //check precondition
if (heap1->set && heap2->set)
return;
if (!heap2->set)
swap(heap1, heap2);
heap1->size = (available_size > heap2->size + min_size) ? (available_size - heap2->size) : min_size;
}
Now we can unite two IFs into `else` case of `if (!profiled.set && !non_profiled.set)`:
if (!profiled.set && !non_profiled.set) {
...
} else {
set_size_of_unset_code_heap(&profiled, &non_profiled, cache_size - non_profiled.size, min_size)
}
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/17244#discussion_r1464049834
More information about the hotspot-dev
mailing list