Skip to content

Commit

Permalink
Johan review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
tstuefe committed Sep 17, 2024
1 parent 28a26ae commit 352e708
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
3 changes: 1 addition & 2 deletions src/hotspot/share/memory/classLoaderMetaspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ void ClassLoaderMetaspace::deallocate(MetaWord* ptr, size_t word_size) {
MutexLocker fcl(lock(), Mutex::_no_safepoint_check_flag);
NOT_LP64(word_size = align_down(word_size, Metaspace::min_allocation_word_size);)
MetaBlock bl(ptr, word_size);
// If the block would be reusable for a Klass, add to class arena, otherwise to
// then non-class arena.
// Add to class arena only if block is usable for encodable Klass storage.
MetaspaceArena* receiving_arena = non_class_space_arena();
if (Metaspace::using_class_space() && Metaspace::is_in_class_space(ptr) &&
is_aligned(ptr, class_space_arena()->allocation_alignment_bytes())) {
Expand Down
16 changes: 6 additions & 10 deletions src/hotspot/share/memory/metaspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -651,29 +651,25 @@ void Metaspace::ergo_initialize() {
MaxMetaspaceSize = MAX2(MaxMetaspaceSize, commit_alignment());

if (UseCompressedClassPointers) {
// Adjust size of the compressed class space.

const size_t res_align = reserve_alignment();

// Let Class Space not be larger than 80% of MaxMetaspaceSize. Note that is
// grossly over-dimensioned for most usage scenarios; typical ratio of
// class space : non class space usage is about 1:6. With many small classes,
// it can get as low as 1:2. It is not a big deal though since ccs is only
// reserved and will be committed on demand only.
const size_t max_ccs_size = 8 * (MaxMetaspaceSize / 10);

// Sanity check: The max. Klass Range allowed by the narrowKlass geometry must cover
// at least a root chunk (16MB). That is of course given.
// Sanity check.
const size_t max_klass_range = CompressedKlassPointers::max_klass_range_size();
assert(max_klass_range >= res_align,
assert(max_klass_range >= reserve_alignment(),
"Klass range (%zu) must cover at least a full root chunk (%zu)",
max_klass_range, res_align);
max_klass_range, reserve_alignment());

size_t adjusted_ccs_size = MIN3(CompressedClassSpaceSize, max_ccs_size, max_klass_range);

// CCS must be aligned to root chunk size, and be at least the size of one
// root chunk. But impose a miminum size of 1 root chunk (16MB).
adjusted_ccs_size = MAX2(align_down(adjusted_ccs_size, res_align), res_align);
// root chunk.
adjusted_ccs_size = align_up(adjusted_ccs_size, reserve_alignment());
adjusted_ccs_size = MAX2(adjusted_ccs_size, reserve_alignment());

// Print a warning if the adjusted size differs from the users input
if (CompressedClassSpaceSize != adjusted_ccs_size) {
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/memory/metaspace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class Metaspace : public AllStatic {
// The largest possible single allocation
static size_t max_allocation_word_size();

// Minimum allocation alignment, in bytes. All MetaData shall be aligned correclty
// Minimum allocation alignment, in bytes. All MetaData shall be aligned correctly
// to be able to hold 64-bit data types. Unlike malloc, we don't care for larger
// data types.
static constexpr size_t min_allocation_alignment_bytes = sizeof(uint64_t);
Expand Down
3 changes: 2 additions & 1 deletion src/hotspot/share/memory/metaspace/metaspaceArena.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ namespace metaspace {

class ArenaGrowthPolicy;
struct ArenaStats;
class MetaspaceContext;
class ChunkManager;
class FreeBlocks;
class Metachunk;
class MetaspaceContext;


// The MetaspaceArena is a growable metaspace memory pool belonging to a CLD;
Expand Down Expand Up @@ -81,6 +81,7 @@ class MetaspaceArena : public CHeapObj<mtClass> {
// Please note that access to a metaspace arena may be shared
// between threads and needs to be synchronized in CLMS.

// Allocation alignment specific to this arena
const size_t _allocation_alignment_words;

// Reference to the chunk manager to allocate chunks from.
Expand Down

0 comments on commit 352e708

Please sign in to comment.