Bump corefx
[mono-project.git] / mono / sgen / sgen-conf.h
blob429dcb26af30a8b2370225bf988dc247aa7db7b5
1 /*
2 * sgen-conf.h: Tunable parameters and debugging switches.
4 * Copyright 2001-2003 Ximian, Inc
5 * Copyright 2003-2010 Novell, Inc.
6 * Copyright 2011 Xamarin Inc (http://www.xamarin.com)
7 * Copyright (C) 2012 Xamarin Inc
9 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
11 #ifndef __MONO_SGENCONF_H__
12 #define __MONO_SGENCONF_H__
14 #include <glib.h>
16 /*Basic defines and static tunables */
18 #if SIZEOF_VOID_P == 4
19 typedef guint32 mword;
20 #else
21 typedef guint64 mword;
22 #endif
24 typedef mword SgenDescriptor;
25 #define SGEN_DESCRIPTOR_NULL 0
28 * Turning on heavy statistics will turn off the managed allocator and
29 * the managed write barrier.
31 // #define HEAVY_STATISTICS
33 #ifdef HEAVY_STATISTICS
34 #define HEAVY_STAT(x) x
35 #else
36 #define HEAVY_STAT(x)
37 #endif
40 * Define this to allow the user to change the nursery size by
41 * specifying its value in the MONO_GC_PARAMS environmental
42 * variable. See mono_gc_base_init for details.
44 #define USER_CONFIG 1
47 * The binary protocol enables logging a lot of the GC ativity in a way that is not very
48 * intrusive and produces a compact file that can be searched using a custom tool. This
49 * option enables very fine-grained binary protocol events, which will make the GC a tiny
50 * bit less efficient even if no binary protocol file is generated.
52 //#define SGEN_HEAVY_BINARY_PROTOCOL
55 * This extends the heavy binary protocol to record the provenance of an object
56 * for every allocation.
58 //#define SGEN_OBJECT_PROVENANCE
61 * This enables checks whenever objects are enqueued in gray queues.
62 * Right now the only check done is that we never enqueue nursery
63 * pointers in the concurrent collector.
65 //#define SGEN_CHECK_GRAY_OBJECT_ENQUEUE
68 * This keeps track of where a gray object queue section is and
69 * whether it is where it should be.
71 //#define SGEN_CHECK_GRAY_OBJECT_SECTIONS
74 * Enable this to check every reference update for null references and whether the update is
75 * made in a worker thread. In only a few cases do we potentially update references by
76 * writing nulls, so we assert in all the cases where it's not allowed. The concurrent
77 * collector's worker thread is not allowed to update references at all, so we also assert
78 * that we're not in the worker thread.
80 //#define SGEN_CHECK_UPDATE_REFERENCE
83 * Define this and use the "xdomain-checks" MONO_GC_DEBUG option to
84 * have cross-domain checks in the write barrier.
86 //#define XDOMAIN_CHECKS_IN_WBARRIER
89 * Define this to get number of objects marked information in the
90 * concurrent GC DTrace probes. Has a small performance impact, so
91 * it's disabled by default.
93 //#define SGEN_COUNT_NUMBER_OF_MAJOR_OBJECTS_MARKED
96 * Object layout statistics gather a histogram of reference locations
97 * over all scanned objects. We use this information to improve GC
98 * descriptors to speed up scanning. This does not provide any
99 * troubleshooting assistance (unless you are troubled in highly
100 * unusual ways) and makes scanning slower.
102 //#define SGEN_OBJECT_LAYOUT_STATISTICS
104 #ifndef SGEN_HEAVY_BINARY_PROTOCOL
105 #ifndef HEAVY_STATISTICS
106 #define MANAGED_ALLOCATION
107 #ifndef XDOMAIN_CHECKS_IN_WBARRIER
108 #define MANAGED_WBARRIER
109 #endif
110 #endif
111 #endif
114 * Maximum level of debug to enable on this build.
115 * Making this a constant enables us to put logging in a lot of places and
116 * not pay its cost on release builds.
118 #define SGEN_MAX_DEBUG_LEVEL 2
121 * Maximum level of asserts to enable on this build.
122 * FIXME replace all magic numbers with defines.
124 #define SGEN_MAX_ASSERT_LEVEL 5
127 #define GC_BITS_PER_WORD (sizeof (mword) * 8)
129 /*Size of the section used by the copying GC. */
130 #define SGEN_SIZEOF_GC_MEM_SECTION ((sizeof (GCMemSection) + 7) & ~7)
133 * to quickly find the head of an object pinned by a conservative
134 * address we keep track of the objects allocated for each
135 * SGEN_SCAN_START_SIZE memory chunk in the nursery or other memory
136 * sections. Larger values have less memory overhead and bigger
137 * runtime cost. 4-8 KB are reasonable values.
139 #define SGEN_SCAN_START_SIZE (4096*2)
142 * Objects bigger then this go into the large object space. This size has a few
143 * constraints. At least two of them must fit into a major heap block. It must also play
144 * well with the run length GC descriptor, which encodes the object size.
146 #define SGEN_MAX_SMALL_OBJ_SIZE 8000
149 * This is the maximum ammount of memory we're willing to waste in order to speed up allocation.
150 * Wastage comes in thre forms:
152 * -when building the nursery fragment list, small regions are discarded;
153 * -when allocating memory from a fragment if it ends up below the threshold, we remove it from the fragment list; and
154 * -when allocating a new tlab, we discard the remaining space of the old one
156 * Increasing this value speeds up allocation but will cause more frequent nursery collections as less space will be used.
157 * Descreasing this value will cause allocation to be slower since we'll have to cycle thru more fragments.
158 * 512 annedoctally keeps wastage under control and doesn't impact allocation performance too much.
160 #define SGEN_MAX_NURSERY_WASTE 512
164 * Minimum allowance for nursery allocations, as a multiple of the size of nursery.
166 * We allow at least this much allocation to happen to the major heap from multiple
167 * minor collections before triggering a major collection.
169 * Bigger values increases throughput by allowing more garbage to sit in the major heap.
170 * Smaller values leads to better memory effiency but more frequent major collections.
172 #define SGEN_DEFAULT_ALLOWANCE_NURSERY_SIZE_RATIO 4.0
174 #define SGEN_MIN_ALLOWANCE_NURSERY_SIZE_RATIO 1.0
175 #define SGEN_MAX_ALLOWANCE_NURSERY_SIZE_RATIO 10.0
178 * How much more we allow the heap to grow before triggering another major collection
180 #define SGEN_DEFAULT_ALLOWANCE_HEAP_SIZE_RATIO 0.33
183 * Default ratio of memory we want to release in a major collection in relation to the the current heap size.
185 * A major collection target is to free a given amount of memory. This amount is a ratio of the major heap size.
187 * Values above 0.5 cause the heap to agressively grow when it's small and waste memory when it's big.
188 * Lower values will produce more reasonable sized heaps when it's small, but will be suboptimal at large
189 * sizes as they will use a small fraction only.
192 #define SGEN_DEFAULT_SAVE_TARGET_RATIO 0.5
194 #define SGEN_MIN_SAVE_TARGET_RATIO 0.1
195 #define SGEN_MAX_SAVE_TARGET_RATIO 2.0
198 * Configurable cementing parameters.
200 * If there are too many pinned nursery objects with many references
201 * from the major heap, the hash table size must be increased.
203 * The threshold is the number of references from the major heap to a
204 * pinned nursery object which triggers cementing: if there are more
205 * than that number of references, the pinned object is cemented until
206 * the next major collection.
208 #define SGEN_CEMENT_HASH_SHIFT 6
209 #define SGEN_CEMENT_HASH_SIZE (1 << SGEN_CEMENT_HASH_SHIFT)
210 #define SGEN_CEMENT_HASH(hv) (((hv) ^ ((hv) >> SGEN_CEMENT_HASH_SHIFT)) & (SGEN_CEMENT_HASH_SIZE - 1))
211 #define SGEN_CEMENT_THRESHOLD 1000
213 #endif