From 882ae6dc81f3f001b394937cc6df0290f429b90c Mon Sep 17 00:00:00 2001 From: Vlad Brezae Date: Mon, 3 Apr 2017 14:52:57 +0300 Subject: [PATCH] [sgen] Kill USER_CONFIG It is useless and confusing. We always support setting the nursery-size through MONO_GC_PARAMS. --- mono/metadata/sgen-mono.c | 2 +- mono/sgen/sgen-alloc.c | 2 +- mono/sgen/sgen-cardtable.c | 2 +- mono/sgen/sgen-conf.h | 7 ------- mono/sgen/sgen-debug.c | 2 +- mono/sgen/sgen-gc.c | 7 +------ mono/sgen/sgen-gc.h | 15 +-------------- mono/sgen/sgen-memory-governor.c | 2 +- mono/sgen/sgen-nursery-allocator.c | 4 ++-- 9 files changed, 9 insertions(+), 34 deletions(-) diff --git a/mono/metadata/sgen-mono.c b/mono/metadata/sgen-mono.c index fc379e52a8f..44adebbc003 100644 --- a/mono/metadata/sgen-mono.c +++ b/mono/metadata/sgen-mono.c @@ -2665,7 +2665,7 @@ void* mono_gc_get_nursery (int *shift_bits, size_t *size) { *size = sgen_nursery_size; - *shift_bits = DEFAULT_NURSERY_BITS; + *shift_bits = sgen_nursery_bits; return sgen_get_nursery_start (); } diff --git a/mono/sgen/sgen-alloc.c b/mono/sgen/sgen-alloc.c index 6f6a45e8b1a..2e1178ad392 100644 --- a/mono/sgen/sgen-alloc.c +++ b/mono/sgen/sgen-alloc.c @@ -211,7 +211,7 @@ sgen_alloc_obj_nolock (GCVTable vtable, size_t size) /* when running in degraded mode, we continue allocing that way * for a while, to decrease the number of useless nursery collections. */ - if (degraded_mode && degraded_mode < DEFAULT_NURSERY_SIZE) + if (degraded_mode && degraded_mode < sgen_nursery_size) return alloc_degraded (vtable, size, FALSE); available_in_tlab = (int)(TLAB_REAL_END - TLAB_NEXT);//We'll never have tlabs > 2Gb diff --git a/mono/sgen/sgen-cardtable.c b/mono/sgen/sgen-cardtable.c index 4fd859ac9fe..c3a1cf23d3c 100644 --- a/mono/sgen/sgen-cardtable.c +++ b/mono/sgen/sgen-cardtable.c @@ -138,7 +138,7 @@ sgen_card_table_wbarrier_range_copy (gpointer _dest, gpointer _src, int size) GCObject **dest = (GCObject **)_dest; GCObject **src = (GCObject **)_src; - size_t nursery_bits = DEFAULT_NURSERY_BITS; + size_t nursery_bits = sgen_nursery_bits; char *start = sgen_nursery_start; G_GNUC_UNUSED char *end = sgen_nursery_end; diff --git a/mono/sgen/sgen-conf.h b/mono/sgen/sgen-conf.h index d9296ca1594..64bdac2f8a9 100644 --- a/mono/sgen/sgen-conf.h +++ b/mono/sgen/sgen-conf.h @@ -37,13 +37,6 @@ typedef mword SgenDescriptor; #define HEAVY_STAT(x) #endif -/* - * Define this to allow the user to change the nursery size by - * specifying its value in the MONO_GC_PARAMS environmental - * variable. See mono_gc_base_init for details. - */ -#define USER_CONFIG 1 - /* * The binary protocol enables logging a lot of the GC ativity in a way that is not very * intrusive and produces a compact file that can be searched using a custom tool. This diff --git a/mono/sgen/sgen-debug.c b/mono/sgen/sgen-debug.c index b519a1ec58e..e7a316c440a 100644 --- a/mono/sgen/sgen-debug.c +++ b/mono/sgen/sgen-debug.c @@ -325,7 +325,7 @@ static void setup_valid_nursery_objects (void) { if (!valid_nursery_objects) - valid_nursery_objects = (GCObject **)sgen_alloc_os_memory (DEFAULT_NURSERY_SIZE, (SgenAllocFlags)(SGEN_ALLOC_INTERNAL | SGEN_ALLOC_ACTIVATE), "debugging data", MONO_MEM_ACCOUNT_SGEN_DEBUGGING); + valid_nursery_objects = (GCObject **)sgen_alloc_os_memory (sgen_nursery_size, (SgenAllocFlags)(SGEN_ALLOC_INTERNAL | SGEN_ALLOC_ACTIVATE), "debugging data", MONO_MEM_ACCOUNT_SGEN_DEBUGGING); valid_nursery_object_count = 0; sgen_scan_area_with_callback (nursery_section->data, nursery_section->end_data, setup_mono_sgen_scan_area_with_callback, NULL, FALSE, FALSE); } diff --git a/mono/sgen/sgen-gc.c b/mono/sgen/sgen-gc.c index 7f1a8c3d39d..ce86cf4ea05 100644 --- a/mono/sgen/sgen-gc.c +++ b/mono/sgen/sgen-gc.c @@ -968,7 +968,7 @@ alloc_nursery (void) /* If there isn't enough space even for the nursery we should simply abort. */ g_assert (sgen_memgov_try_alloc_space (alloc_size, SPACE_NURSERY)); - data = (char *)major_collector.alloc_heap (alloc_size, alloc_size, DEFAULT_NURSERY_BITS); + data = (char *)major_collector.alloc_heap (alloc_size, alloc_size, sgen_nursery_bits); sgen_update_heap_boundaries ((mword)data, (mword)(data + sgen_nursery_size)); SGEN_LOG (4, "Expanding nursery size (%p-%p): %lu, total: %lu", data, data + alloc_size, (unsigned long)sgen_nursery_size, (unsigned long)sgen_gc_get_total_heap_allocation ()); section->data = section->next_data = data; @@ -3097,8 +3097,6 @@ sgen_gc_init (void) goto use_default_major; } - sgen_nursery_size = DEFAULT_NURSERY_SIZE; - if (opts) { gboolean usage_printed = FALSE; @@ -3135,8 +3133,6 @@ sgen_gc_init (void) } continue; } - -#ifdef USER_CONFIG if (g_str_has_prefix (opt, "nursery-size=")) { size_t val; opt = strchr (opt, '=') + 1; @@ -3162,7 +3158,6 @@ sgen_gc_init (void) } continue; } -#endif if (g_str_has_prefix (opt, "save-target-ratio=")) { double val; opt = strchr (opt, '=') + 1; diff --git a/mono/sgen/sgen-gc.h b/mono/sgen/sgen-gc.h index db2e35a292f..5fbfda2c67a 100644 --- a/mono/sgen/sgen-gc.h +++ b/mono/sgen/sgen-gc.h @@ -186,29 +186,16 @@ sgen_aligned_addr_hash (gconstpointer ptr) #define SGEN_PTR_IN_NURSERY(p,bits,start,end) (((mword)(p) & ~(((mword)1 << (bits)) - 1)) == (mword)(start)) -#ifdef USER_CONFIG - -/* good sizes are 512KB-1MB: larger ones increase a lot memzeroing time */ -#define DEFAULT_NURSERY_SIZE (sgen_nursery_size) extern size_t sgen_nursery_size; -/* The number of trailing 0 bits in DEFAULT_NURSERY_SIZE */ -#define DEFAULT_NURSERY_BITS (sgen_nursery_bits) extern int sgen_nursery_bits; -#else - -#define DEFAULT_NURSERY_SIZE (4*1024*1024) -#define DEFAULT_NURSERY_BITS 22 - -#endif - extern char *sgen_nursery_start; extern char *sgen_nursery_end; static inline MONO_ALWAYS_INLINE gboolean sgen_ptr_in_nursery (void *p) { - return SGEN_PTR_IN_NURSERY ((p), DEFAULT_NURSERY_BITS, sgen_nursery_start, sgen_nursery_end); + return SGEN_PTR_IN_NURSERY ((p), sgen_nursery_bits, sgen_nursery_start, sgen_nursery_end); } static inline MONO_ALWAYS_INLINE char* diff --git a/mono/sgen/sgen-memory-governor.c b/mono/sgen/sgen-memory-governor.c index 3bf90115b85..9be31ad76e6 100644 --- a/mono/sgen/sgen-memory-governor.c +++ b/mono/sgen/sgen-memory-governor.c @@ -23,7 +23,7 @@ #include "mono/sgen/sgen-workers.h" #include "mono/sgen/sgen-client.h" -#define MIN_MINOR_COLLECTION_ALLOWANCE ((mword)(DEFAULT_NURSERY_SIZE * default_allowance_nursery_size_ratio)) +#define MIN_MINOR_COLLECTION_ALLOWANCE ((mword)(sgen_nursery_size * default_allowance_nursery_size_ratio)) static SgenPointerQueue log_entries = SGEN_POINTER_QUEUE_INIT (INTERNAL_MEM_TEMPORARY); static MonoCoopMutex log_entries_mutex; diff --git a/mono/sgen/sgen-nursery-allocator.c b/mono/sgen/sgen-nursery-allocator.c index 91611877ce6..41e9478dcbc 100644 --- a/mono/sgen/sgen-nursery-allocator.c +++ b/mono/sgen/sgen-nursery-allocator.c @@ -72,10 +72,10 @@ static char *nursery_last_pinned_end = NULL; char *sgen_nursery_start; char *sgen_nursery_end; -#ifdef USER_CONFIG +/* good sizes are 512KB-1MB: larger ones increase a lot memzeroing time */ size_t sgen_nursery_size = (1 << 22); +/* The number of trailing 0 bits in sgen_nursery_size */ int sgen_nursery_bits = 22; -#endif char *sgen_space_bitmap; size_t sgen_space_bitmap_size; -- 2.25.1