Skip to content

Commit

Permalink
8257901: ZGC: Take virtual memory usage into account when sizing heap
Browse files Browse the repository at this point in the history
  • Loading branch information
pliden committed Dec 8, 2020
1 parent 1d0adbb commit 09bf660
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/hotspot/share/gc/shared/gcArguments.cpp
Expand Up @@ -172,3 +172,7 @@ void GCArguments::initialize_heap_flags_and_sizes() {

DEBUG_ONLY(assert_flags();)
}

size_t GCArguments::max_virtual_memory_fraction() {
return MaxVirtMemFraction;
}
1 change: 1 addition & 0 deletions src/hotspot/share/gc/shared/gcArguments.hpp
Expand Up @@ -46,6 +46,7 @@ class GCArguments {
public:
virtual void initialize();
virtual size_t conservative_max_heap_alignment() = 0;
virtual size_t max_virtual_memory_fraction();
virtual CollectedHeap* create_heap() = 0;

// Allows GCs to tell external code if it's supported or not in the current setup.
Expand Down
3 changes: 2 additions & 1 deletion src/hotspot/share/gc/z/zAddressSpaceLimit.cpp
Expand Up @@ -24,6 +24,7 @@
#include "precompiled.hpp"
#include "gc/z/zAddressSpaceLimit.hpp"
#include "gc/z/zGlobals.hpp"
#include "runtime/globals.hpp"
#include "runtime/os.hpp"
#include "utilities/align.hpp"

Expand All @@ -46,6 +47,6 @@ size_t ZAddressSpaceLimit::mark_stack() {

size_t ZAddressSpaceLimit::heap_view() {
// Allow all heap views to occupy 50% of the address space
const size_t limit = address_space_limit() / 2 / ZHeapViews;
const size_t limit = address_space_limit() / MaxVirtMemFraction / ZHeapViews;
return align_up(limit, ZGranuleSize);
}
8 changes: 8 additions & 0 deletions src/hotspot/share/gc/z/zArguments.cpp
Expand Up @@ -25,6 +25,7 @@
#include "gc/z/zAddressSpaceLimit.hpp"
#include "gc/z/zArguments.hpp"
#include "gc/z/zCollectedHeap.hpp"
#include "gc/z/zGlobals.hpp"
#include "gc/z/zHeuristics.hpp"
#include "gc/shared/gcArguments.hpp"
#include "runtime/globals.hpp"
Expand Down Expand Up @@ -94,6 +95,13 @@ void ZArguments::initialize() {
}
}

size_t ZArguments::max_virtual_memory_fraction() {
// Used by heap size heuristics to determine max amount of address
// space to use. Inflates the default MaxVirtMemFraction to account
// for all heap views and the virtual-to-physical ratio.
return MaxVirtMemFraction * ZHeapViews * ZVirtualToPhysicalRatio;
}

size_t ZArguments::conservative_max_heap_alignment() {
return 0;
}
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/gc/z/zArguments.hpp
Expand Up @@ -34,6 +34,7 @@ class ZArguments : public GCArguments {

virtual void initialize();
virtual size_t conservative_max_heap_alignment();
virtual size_t max_virtual_memory_fraction();
virtual CollectedHeap* create_heap();

virtual bool is_supported() const;
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/runtime/arguments.cpp
Expand Up @@ -1659,7 +1659,7 @@ julong Arguments::limit_by_allocatable_memory(julong limit) {
julong max_allocatable;
julong result = limit;
if (os::has_allocatable_memory_limit(&max_allocatable)) {
result = MIN2(result, max_allocatable / MaxVirtMemFraction);
result = MIN2(result, max_allocatable / GCConfig::arguments()->max_virtual_memory_fraction());
}
return result;
}
Expand Down

0 comments on commit 09bf660

Please sign in to comment.