Skip to content

Commit 0dc0bee

Browse files
authored
Removed the hard heap limit heap balancing logic for regions + UOH and fixed infinite retries in case at the LOH boundary (#67406)
* Removed the hard heap limit heap balancing logic for uoh and fixed inifite retries * Addressed feedback - refactored region checking directives * Removed all instances of hard_limit_exceeded_p as it is no longer needed
1 parent 2eddb3d commit 0dc0bee

File tree

2 files changed

+9
-22
lines changed

2 files changed

+9
-22
lines changed

src/coreclr/gc/gc.cpp

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6803,7 +6803,7 @@ bool gc_heap::virtual_alloc_commit_for_heap (void* addr, size_t size, int h_numb
68036803
return GCToOSInterface::VirtualCommit(addr, size);
68046804
}
68056805

6806-
bool gc_heap::virtual_commit (void* address, size_t size, gc_oh_num oh, int h_number, bool* hard_limit_exceeded_p)
6806+
bool gc_heap::virtual_commit (void* address, size_t size, gc_oh_num oh, int h_number)
68076807
{
68086808
#ifndef HOST_64BIT
68096809
assert (heap_hard_limit == 0);
@@ -6841,9 +6841,6 @@ bool gc_heap::virtual_commit (void* address, size_t size, gc_oh_num oh, int h_nu
68416841

68426842
check_commit_cs.Leave();
68436843

6844-
if (hard_limit_exceeded_p)
6845-
*hard_limit_exceeded_p = exceeded_p;
6846-
68476844
if (exceeded_p)
68486845
{
68496846
dprintf (1, ("can't commit %Ix for %Id bytes > HARD LIMIT %Id", (size_t)address, size, heap_hard_limit));
@@ -14220,13 +14217,10 @@ BOOL gc_heap::a_size_fit_p (size_t size, uint8_t* alloc_pointer, uint8_t* alloc_
1422014217
}
1422114218

1422214219
// Grow by committing more pages
14223-
BOOL gc_heap::grow_heap_segment (heap_segment* seg, uint8_t* high_address, bool* hard_limit_exceeded_p)
14220+
BOOL gc_heap::grow_heap_segment (heap_segment* seg, uint8_t* high_address)
1422414221
{
1422514222
assert (high_address <= heap_segment_reserved (seg));
1422614223

14227-
if (hard_limit_exceeded_p)
14228-
*hard_limit_exceeded_p = false;
14229-
1423014224
//return 0 if we are at the end of the segment.
1423114225
if (align_on_page (high_address) > heap_segment_reserved (seg))
1423214226
return FALSE;
@@ -14245,7 +14239,7 @@ BOOL gc_heap::grow_heap_segment (heap_segment* seg, uint8_t* high_address, bool*
1424514239
"Growing heap_segment: %Ix high address: %Ix\n",
1424614240
(size_t)seg, (size_t)high_address);
1424714241

14248-
bool ret = virtual_commit (heap_segment_committed (seg), c_size, heap_segment_oh (seg), heap_number, hard_limit_exceeded_p);
14242+
bool ret = virtual_commit (heap_segment_committed (seg), c_size, heap_segment_oh (seg), heap_number);
1424914243
if (ret)
1425014244
{
1425114245
heap_segment_committed (seg) += c_size;
@@ -16130,7 +16124,6 @@ BOOL gc_heap::a_fit_segment_end_p (int gen_number,
1613016124
{
1613116125
*commit_failed_p = FALSE;
1613216126
size_t limit = 0;
16133-
bool hard_limit_short_seg_end_p = false;
1613416127
#ifdef BACKGROUND_GC
1613516128
int cookie = -1;
1613616129
#endif //BACKGROUND_GC
@@ -16169,21 +16162,13 @@ BOOL gc_heap::a_fit_segment_end_p (int gen_number,
1616916162
(end - allocated),
1617016163
gen_number, align_const);
1617116164

16172-
if (grow_heap_segment (seg, (allocated + limit), &hard_limit_short_seg_end_p))
16165+
if (grow_heap_segment (seg, (allocated + limit)))
1617316166
{
1617416167
goto found_fit;
1617516168
}
1617616169
else
1617716170
{
16178-
if (!hard_limit_short_seg_end_p)
16179-
{
16180-
dprintf (2, ("can't grow segment, doing a full gc"));
16181-
*commit_failed_p = TRUE;
16182-
}
16183-
else
16184-
{
16185-
assert (heap_hard_limit);
16186-
}
16171+
*commit_failed_p = TRUE;
1618716172
}
1618816173
}
1618916174

@@ -17796,6 +17781,7 @@ void gc_heap::balance_heaps (alloc_context* acontext)
1779617781

1779717782
ptrdiff_t gc_heap::get_balance_heaps_uoh_effective_budget (int generation_num)
1779817783
{
17784+
#ifndef USE_REGIONS
1779917785
if (heap_hard_limit)
1780017786
{
1780117787
const ptrdiff_t free_list_space = generation_free_list_space (generation_of (generation_num));
@@ -17807,6 +17793,7 @@ ptrdiff_t gc_heap::get_balance_heaps_uoh_effective_budget (int generation_num)
1780717793
return free_list_space - allocated;
1780817794
}
1780917795
else
17796+
#endif // !USE_REGIONS
1781017797
{
1781117798
return dd_new_allocation (dynamic_data_of (generation_num));
1781217799
}

src/coreclr/gc/gcpriv.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2027,7 +2027,7 @@ class gc_heap
20272027
PER_HEAP_ISOLATED
20282028
bool virtual_alloc_commit_for_heap (void* addr, size_t size, int h_number);
20292029
PER_HEAP_ISOLATED
2030-
bool virtual_commit (void* address, size_t size, gc_oh_num oh, int h_number=-1, bool* hard_limit_exceeded_p=NULL);
2030+
bool virtual_commit (void* address, size_t size, gc_oh_num oh, int h_number=-1);
20312031
PER_HEAP_ISOLATED
20322032
bool virtual_decommit (void* address, size_t size, gc_oh_num oh, int h_number=-1);
20332033
PER_HEAP_ISOLATED
@@ -2128,7 +2128,7 @@ class gc_heap
21282128
BOOL find_card (uint32_t* card_table, size_t& card,
21292129
size_t card_word_end, size_t& end_card);
21302130
PER_HEAP
2131-
BOOL grow_heap_segment (heap_segment* seg, uint8_t* high_address, bool* hard_limit_exceeded_p=NULL);
2131+
BOOL grow_heap_segment (heap_segment* seg, uint8_t* high_address);
21322132
PER_HEAP
21332133
int grow_heap_segment (heap_segment* seg, uint8_t* high_address, uint8_t* old_loc, size_t size, BOOL pad_front_p REQD_ALIGN_AND_OFFSET_DCL);
21342134
PER_HEAP

0 commit comments

Comments
 (0)