Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8017163: G1: Refactor remembered sets #4116

Closed
Closed
Changes from 12 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8a13a1e
Initial implementation
tschatzl May 19, 2021
e959ba7
Remove unnecessary changes
tschatzl May 19, 2021
6596fae
Trailing whitespace fixes
tschatzl May 19, 2021
a588852
Fix 32 bit platforms after premature optimization, implement 64 bit A…
tschatzl May 20, 2021
d566ab9
iwalulya, sjohanss review
tschatzl May 26, 2021
01ecd28
Remove prefetching of log buffers
tschatzl May 26, 2021
c1b83e0
Rename FOUND
tschatzl May 26, 2021
f54c350
More cleanup after sjohanss comments
tschatzl May 28, 2021
346247f
Merge branch 'master' of gh:openjdk/jdk into 8017163-refactor-remembe…
tschatzl May 31, 2021
e2c3c30
sjohanss-review 3
tschatzl Jun 1, 2021
f87b398
Rename G1CardSetContainerOnHeap to G1CardSetContainer on popular demand
tschatzl Jun 1, 2021
97e6360
Improve comment
tschatzl Jun 1, 2021
2edffc1
Improved documentation
tschatzl Jun 1, 2021
ace8172
Always have power-of-2 Howl buckets to avoid memory waste (these entr…
tschatzl Jun 1, 2021
39a41f6
Merge branch 'master' of gh:openjdk/jdk into tschatzl:submit/8017163-…
tschatzl Jun 2, 2021
338b482
Merge branch 'master' into submit/8017163-refactor-remembered-set
tschatzl Jun 9, 2021
d9b8c70
Merge branch 'master' into 8017163-refactor-remembered-set
tschatzl Jun 15, 2021
c865797
Update obsoletion/removal versions
tschatzl Jun 15, 2021
86f7484
Merge branch 'submit/8017163-refactor-remembered-set' of gh:tschatzl/…
tschatzl Jun 15, 2021
3dd0e7a
sjohanss review - remove debug code
tschatzl Jun 15, 2021
487b5f6
Merge branch 'master' into 8017163-refactor-remembered-set
tschatzl Jun 18, 2021
6df9cf3
sjohanss review - more removal of dead code
tschatzl Jun 18, 2021
b8e67fe
iwalulya review - comments
tschatzl Jun 18, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -25,6 +25,8 @@

#include "precompiled.hpp"
#include "gc/g1/g1Arguments.hpp"
#include "gc/g1/g1CardSet.hpp"
#include "gc/g1/g1CardSetContainers.inline.hpp"
#include "gc/g1/g1CollectedHeap.inline.hpp"
#include "gc/g1/g1HeapVerifier.hpp"
#include "gc/g1/heapRegion.hpp"
@@ -49,10 +51,13 @@ void G1Arguments::initialize_alignments() {
// size, but the heap size should be aligned with the region size. To get
// around this we use the unaligned values for the heap.
HeapRegion::setup_heap_region_size(MaxHeapSize);
HeapRegionRemSet::setup_remset_size();

SpaceAlignment = HeapRegion::GrainBytes;
HeapAlignment = calculate_heap_alignment(SpaceAlignment);

// We need to initialize card set configuration as soon as heap region size is
// known as it depends on it and is used really early.
initialize_card_set_configuration();
}

size_t G1Arguments::conservative_max_heap_alignment() {
@@ -112,6 +117,40 @@ void G1Arguments::initialize_mark_stack_size() {
log_trace(gc)("MarkStackSize: %uk MarkStackSizeMax: %uk", (uint)(MarkStackSize / K), (uint)(MarkStackSizeMax / K));
}


void G1Arguments::initialize_card_set_configuration() {
assert(HeapRegion::LogOfHRGrainBytes != 0, "not initialized");
// Array of Cards card set container globals.
const int LOG_M = 20;
uint region_size_log_mb = (uint)MAX2(HeapRegion::LogOfHRGrainBytes - LOG_M, 0);

if (FLAG_IS_DEFAULT(G1RemSetArrayOfCardsEntries)) {
uint num_cards_in_inline_ptr = G1CardSetConfiguration::num_cards_in_inline_ptr(HeapRegion::LogOfHRGrainBytes - CardTable::card_shift);
FLAG_SET_ERGO(G1RemSetArrayOfCardsEntries, MAX2(num_cards_in_inline_ptr * 2,
G1RemSetArrayOfCardsEntriesBase * (1u << (region_size_log_mb + 1))));
}

// Round to next 8 byte boundary for array to maximize space usage.
size_t const cur_size = G1CardSetArray::size_in_bytes(G1RemSetArrayOfCardsEntries);
FLAG_SET_ERGO(G1RemSetArrayOfCardsEntries,
G1RemSetArrayOfCardsEntries + (uint)(align_up(cur_size, G1CardSetAllocOptions::BufferAlignment) - cur_size) / sizeof(G1CardSetArray::EntryDataType));

// Howl card set container globals.
if (FLAG_IS_DEFAULT(G1RemSetHowlNumBuckets)) {
FLAG_SET_ERGO(G1RemSetHowlNumBuckets, G1CardSetHowl::num_buckets(HeapRegion::CardsPerRegion,
G1RemSetArrayOfCardsEntries,
G1RemSetHowlMaxNumBuckets));
}

if (FLAG_IS_DEFAULT(G1RemSetHowlMaxNumBuckets)) {
FLAG_SET_ERGO(G1RemSetHowlMaxNumBuckets, MAX2(G1RemSetHowlMaxNumBuckets, G1RemSetHowlNumBuckets));
} else if (G1RemSetHowlMaxNumBuckets < G1RemSetHowlNumBuckets) {
FormatBuffer<> buf("Maximum Howl card set container bucket size %u smaller than requested bucket size %u",
G1RemSetHowlMaxNumBuckets, G1RemSetHowlNumBuckets);
vm_exit_during_initialization(buf);
}
}

void G1Arguments::initialize() {
GCArguments::initialize();
assert(UseG1GC, "Error");
@@ -189,6 +228,14 @@ void G1Arguments::initialize() {

initialize_mark_stack_size();
initialize_verification_types();

// Verify that the maximum parallelism isn't too high to eventually overflow
// the refcount in G1CardSetContainer.
uint max_parallel_refinement_threads = G1ConcRefinementThreads + G1DirtyCardQueueSet::num_par_ids();
uint const divisor = 3; // Safe divisor; we increment by 2 for each claim, but there is a small initial value.
if (max_parallel_refinement_threads > UINTPTR_MAX / divisor) {
vm_exit_during_initialization("Too large parallelism for remembered sets.");
}
}

void G1Arguments::initialize_heap_flags_and_sizes() {
@@ -34,6 +34,7 @@ class G1Arguments : public GCArguments {
friend class G1HeapVerifierTest;

static void initialize_mark_stack_size();
static void initialize_card_set_configuration();
static void initialize_verification_types();
static void parse_verification_type(const char* type);