Skip to content

Commit

Permalink
make SIP not on by default (#73434)
Browse files Browse the repository at this point in the history
I'm seeing with SIP the heap size can increase noticeably because we don't compact the SIP regions, for workload that rarely ever does blocking gen2s. so I'm making these not on by default but can be turned on with the GCEnableSpecialRegions config.

there are a few methods that are currently compiled for both segments and regions but are only used for segments so made those only compiled for segments.
  • Loading branch information
Maoni0 authored Aug 6, 2022
1 parent 638a4c1 commit 63b2656
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
15 changes: 12 additions & 3 deletions src/coreclr/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2660,7 +2660,9 @@ bool gc_heap::use_large_pages_p = 0;
#ifdef HEAP_BALANCE_INSTRUMENTATION
size_t gc_heap::last_gc_end_time_us = 0;
#endif //HEAP_BALANCE_INSTRUMENTATION
#ifndef USE_REGIONS
#ifdef USE_REGIONS
bool gc_heap::enable_special_regions_p = false;
#else //USE_REGIONS
size_t gc_heap::min_segment_size = 0;
size_t gc_heap::min_uoh_segment_size = 0;
#endif //!USE_REGIONS
Expand Down Expand Up @@ -5622,7 +5624,6 @@ gc_heap::soh_get_segment_to_expand()
dprintf (GTC_LOG, ("(gen%d)creating new segment %Ix", settings.condemned_generation, result));
return result;
}
#endif //!USE_REGIONS

//returns 0 in case of allocation failure
heap_segment*
Expand Down Expand Up @@ -5768,6 +5769,7 @@ void gc_heap::release_segment (heap_segment* sg)
FIRE_EVENT(GCFreeSegment_V1, heap_segment_mem(sg));
virtual_free (sg, (uint8_t*)heap_segment_reserved (sg)-(uint8_t*)sg, sg);
}
#endif //!USE_REGIONS

heap_segment* gc_heap::get_segment_for_uoh (int gen_number, size_t size
#ifdef MULTIPLE_HEAPS
Expand Down Expand Up @@ -8886,6 +8888,7 @@ void gc_heap::set_fgm_result (failure_get_memory f, size_t s, BOOL loh_p)
#endif //MULTIPLE_HEAPS
}

#ifndef USE_REGIONS
//returns 0 for success, -1 otherwise
// We are doing all the decommitting here because we want to make sure we have
// enough memory to do so - if we do this during copy_brick_card_table and
Expand Down Expand Up @@ -9195,6 +9198,7 @@ int gc_heap::grow_brick_card_tables (uint8_t* start,

return 0;
}
#endif //!USE_REGIONS

//copy all of the arrays managed by the card table for a page aligned range
void gc_heap::copy_brick_card_range (uint8_t* la, uint32_t* old_card_table,
Expand Down Expand Up @@ -11146,7 +11150,6 @@ void gc_heap::clear_region_info (heap_segment* region)
}

// Note that returning a region to free does not decommit.
// REGIONS PERF TODO: should decommit if needed.
void gc_heap::return_free_region (heap_segment* region)
{
gc_oh_num oh = heap_segment_oh (region);
Expand Down Expand Up @@ -30798,6 +30801,11 @@ void gc_heap::update_start_tail_regions (generation* gen,
inline
bool gc_heap::should_sweep_in_plan (heap_segment* region)
{
if (!enable_special_regions_p)
{
return false;
}

if (settings.reason == reason_induced_aggressive)
{
return false;
Expand Down Expand Up @@ -44328,6 +44336,7 @@ HRESULT GCHeap::Initialize()
GCConfig::SetHeapCount(static_cast<int64_t>(nhp));

#ifdef USE_REGIONS
gc_heap::enable_special_regions_p = (bool)GCConfig::GetGCEnableSpecialRegions();
size_t gc_region_size = (size_t)GCConfig::GetGCRegionSize();
if (!power_of_two_p(gc_region_size) || ((gc_region_size * nhp * 19) > gc_heap::regions_range))
{
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/gc/gcconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class GCConfigStringHolder
INT_CONFIG (GCTotalPhysicalMemory, "GCTotalPhysicalMemory", NULL, 0, "Specifies what the GC should consider to be total physical memory") \
INT_CONFIG (GCRegionRange, "GCRegionRange", NULL, 0, "Specifies the range for the GC heap") \
INT_CONFIG (GCRegionSize, "GCRegionSize", NULL, 4194304, "Specifies the size for a basic GC region") \
INT_CONFIG (GCEnableSpecialRegions, "GCEnableSpecialRegions", NULL, 0, "Specifies to enable special handling some regions like SIP") \
STRING_CONFIG(LogFile, "GCLogFile", NULL, "Specifies the name of the GC log file") \
STRING_CONFIG(ConfigLogFile, "GCConfigLogFile", NULL, "Specifies the name of the GC config log file") \
INT_CONFIG (BGCFLTuningEnabled, "BGCFLTuningEnabled", NULL, 0, "Enables FL tuning") \
Expand Down
17 changes: 10 additions & 7 deletions src/coreclr/gc/gcpriv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1596,24 +1596,24 @@ class gc_heap
static
void get_card_table_element_sizes (uint8_t* start, uint8_t* end, size_t bookkeeping_sizes[total_bookkeeping_elements]);

static
void set_fgm_result (failure_get_memory f, size_t s, BOOL loh_p);

#ifdef USE_REGIONS
static
bool on_used_changed (uint8_t* left);

static
bool inplace_commit_card_table (uint8_t* from, uint8_t* to);
#endif //USE_REGIONS

static
void set_fgm_result (failure_get_memory f, size_t s, BOOL loh_p);

#else //USE_REGIONS
static
int grow_brick_card_tables (uint8_t* start,
uint8_t* end,
size_t size,
heap_segment* new_seg,
gc_heap* hp,
BOOL loh_p);
#endif //USE_REGIONS

PER_HEAP_ISOLATED
BOOL is_mark_set (uint8_t* o);
Expand Down Expand Up @@ -2001,11 +2001,11 @@ class gc_heap
#ifndef USE_REGIONS
PER_HEAP
heap_segment* soh_get_segment_to_expand();
#endif //!USE_REGIONS
PER_HEAP
heap_segment* get_segment (size_t size, gc_oh_num oh);
PER_HEAP_ISOLATED
void release_segment (heap_segment* sg);
#endif //!USE_REGIONS
PER_HEAP_ISOLATED
void seg_mapping_table_add_segment (heap_segment* seg, gc_heap* hp);
PER_HEAP_ISOLATED
Expand Down Expand Up @@ -4040,7 +4040,10 @@ class gc_heap
size_t last_gc_end_time_us;
#endif //HEAP_BALANCE_INSTRUMENTATION

#ifndef USE_REGIONS
#ifdef USE_REGIONS
PER_HEAP_ISOLATED
bool enable_special_regions_p;
#else //USE_REGIONS
PER_HEAP_ISOLATED
size_t min_segment_size;

Expand Down

0 comments on commit 63b2656

Please sign in to comment.