Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixing the case for per heap hard_limit and some styling changes.
  • Loading branch information
mangod9 committed Oct 3, 2022
commit e68e93e708ca5f3ba9285951d7ce5a1027dbc3d6
36 changes: 25 additions & 11 deletions src/coreclr/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44893,11 +44893,18 @@ HRESULT GCHeap::Initialize()
if (gc_heap::regions_range == 0)
{
if (gc_heap::heap_hard_limit)
{
// We will initially reserve 5x the configured hard limit and 2x if
// large pages are enabled
gc_heap::regions_range = (gc_heap::use_large_pages_p) ? 2 * gc_heap::heap_hard_limit // large pages
: 5 * gc_heap::heap_hard_limit;
{
if (gc_heap::heap_hard_limit_oh[soh])
{
gc_heap::regions_range = gc_heap::heap_hard_limit;
}
else
{
// We will initially reserve 5x the configured hard limit and 2x if
// large pages are enabled as this is closer to segments
gc_heap::regions_range = ((gc_heap::use_large_pages_p) ? (2 * gc_heap::heap_hard_limit) // large pages
: (5 * gc_heap::heap_hard_limit));
}
}
else
{
Expand Down Expand Up @@ -45053,16 +45060,23 @@ HRESULT GCHeap::Initialize()
// like to keep Region sizes small. We choose between 4, 2 and 1mb based on the calculations
// below (unless its configured explictly) such that there are at least 2 regions available
// except for the smallest case. Now the lowest limit possible is 4mb.
if (gc_region_size == 0){
if ((gc_heap::regions_range / nhp / 19) / 2 >= (4 * 1024 * 1024)){
if (gc_region_size == 0)
{
if ((gc_heap::regions_range / nhp / min_regions_per_heap) / 2 >= (4 * 1024 * 1024))
{
gc_region_size = 4 * 1024 * 1024;
} else if ((gc_heap::regions_range / nhp / 19) / 2 >= (2 * 1024 * 1024)){
}
else if ((gc_heap::regions_range / nhp / min_regions_per_heap) / 2 >= (2 * 1024 * 1024))
{
gc_region_size = 2 * 1024 * 1024;
} else
gc_region_size = 1 * 1024 * 1024;
}
else
{
gc_region_size = 1 * 1024 * 1024;
}
}

if (!power_of_two_p(gc_region_size) || ((gc_region_size * nhp * 19) > gc_heap::regions_range))
if (!power_of_two_p(gc_region_size) || ((gc_region_size * nhp * min_regions_per_heap) > gc_heap::regions_range))
{
return E_OUTOFMEMORY;
}
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/gc/gcpriv.h
Original file line number Diff line number Diff line change
Expand Up @@ -5807,6 +5807,8 @@ class heap_segment

#define region_alloc_free_bit (1 << (sizeof (uint32_t) * 8 - 1))

const int min_regions_per_heap = ((ephemeral_generation_count + 1) + ((total_generation_count - uoh_start_generation) * LARGE_REGION_FACTOR));

enum allocate_direction
{
allocate_forward = 1,
Expand Down