Fix null sessions in HttpContextWrapper.Session
[mono.git] / mono / metadata / sgen-conf.h
1 /*
2  * Copyright 2001-2003 Ximian, Inc
3  * Copyright 2003-2010 Novell, Inc.
4  * Copyright 2011 Xamarin Inc (http://www.xamarin.com)
5  * 
6  * Permission is hereby granted, free of charge, to any person obtaining
7  * a copy of this software and associated documentation files (the
8  * "Software"), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sublicense, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  * 
14  * The above copyright notice and this permission notice shall be
15  * included in all copies or substantial portions of the Software.
16  * 
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  */
25 #ifndef __MONO_SGENCONF_H__
26 #define __MONO_SGENCONF_H__
27
28 /*Basic defines and static tunables */
29
30 #if SIZEOF_VOID_P == 4
31 typedef guint32 mword;
32 #define MWORD_MAX_VALUE ((uint32_t) 0xffffffff)
33 #else
34 typedef guint64 mword;
35 #define MWORD_MAX_VALUE (G_MAXUINT64)
36 #endif
37
38
39 /*
40  * Turning on heavy statistics will turn off the managed allocator and
41  * the managed write barrier.
42  */
43 //#define HEAVY_STATISTICS
44
45 /*
46  * Define this to allow the user to change the nursery size by
47  * specifying its value in the MONO_GC_PARAMS environmental
48  * variable. See mono_gc_base_init for details.
49  */
50 #define USER_CONFIG 1
51
52
53 /*
54  * If this is set, the nursery is aligned to an address aligned to its size, ie.
55  * a 1MB nursery will be aligned to an address divisible by 1MB. This allows us to
56  * speed up ptr_in_nursery () checks which are very frequent. This requires the
57  * nursery size to be a compile time constant.
58  */
59 #define SGEN_ALIGN_NURSERY 1
60
61 /*
62  * The binary protocol enables logging a lot of the GC ativity in a way that is not very
63  * intrusive and produce a compact file that can be searched using a custom tool.
64  *
65  */
66 //#define SGEN_BINARY_PROTOCOL
67
68 /*
69  * Define this and use the "xdomain-checks" MONO_GC_DEBUG option to
70  * have cross-domain checks in the write barrier.
71  */
72 //#define XDOMAIN_CHECKS_IN_WBARRIER
73
74 #ifndef SGEN_BINARY_PROTOCOL
75 #ifndef HEAVY_STATISTICS
76 #define MANAGED_ALLOCATION
77 #ifndef XDOMAIN_CHECKS_IN_WBARRIER
78 #define MANAGED_WBARRIER
79 #endif
80 #endif
81 #endif
82
83 /*
84  * Maximum level of debug to enable on this build.
85  * Making this a static variable enables us to put logging in a lot of places.
86  * FIXME decouple logging from assertions
87  */
88 #define SGEN_MAX_DEBUG_LEVEL 2
89
90
91 #define GC_BITS_PER_WORD (sizeof (mword) * 8)
92
93 /*Size of the section used by the copying GC. */
94 #define SGEN_SIZEOF_GC_MEM_SECTION      ((sizeof (GCMemSection) + 7) & ~7)
95
96 /*
97  * to quickly find the head of an object pinned by a conservative
98  * address we keep track of the objects allocated for each
99  * SGEN_SCAN_START_SIZE memory chunk in the nursery or other memory
100  * sections. Larger values have less memory overhead and bigger
101  * runtime cost. 4-8 KB are reasonable values.
102  */
103 #define SGEN_SCAN_START_SIZE (4096*2)
104
105 /*
106  * Objects bigger then this go into the large object space.  This size
107  * has a few constraints.  It must fit into the major heap, which in
108  * the case of the copying collector means that it must fit into a
109  * pinned chunk.  It must also play well with the GC descriptors, some
110  * of which (DESC_TYPE_RUN_LENGTH, DESC_TYPE_SMALL_BITMAP) encode the
111  * object size.
112  */
113 #define SGEN_MAX_SMALL_OBJ_SIZE 8000
114
115 /*
116  * This is the maximum ammount of memory we're willing to waste in order to speed up allocation.
117  * Wastage comes in thre forms:
118  *
119  * -when building the nursery fragment list, small regions are discarded;
120  * -when allocating memory from a fragment if it ends up below the threshold, we remove it from the fragment list; and
121  * -when allocating a new tlab, we discard the remaining space of the old one
122  *
123  * Increasing this value speeds up allocation but will cause more frequent nursery collections as less space will be used.
124  * Descreasing this value will cause allocation to be slower since we'll have to cycle thru more fragments.
125  * 512 annedoctally keeps wastage under control and doesn't impact allocation performance too much. 
126 */
127 #define SGEN_MAX_NURSERY_WASTE 512
128
129
130 /* This is also the MAJOR_SECTION_SIZE for the copying major
131    collector */
132 #define SGEN_PINNED_CHUNK_SIZE  (128 * 1024)
133
134 /*
135  * Number of entries of a sequential store buffer.
136  * This number represents how frequently we'll have to alloc
137  * a new buffer, so it's a tradeoff of potential wasted space and
138  * increased performance.
139  * 
140  * The current value of 1024 was probably selected because it fits a x86 page.
141  * There's no history on the why's of this value besides this.
142  */
143 #define DEFAULT_REMSET_SIZE 1024
144
145
146 /*
147  * Minimum allowance for nursery allocations, as a multiple of the size of nursery.
148  *
149  * We allow at least this much allocation to happen to the major heap from multiple
150  * minor collections before triggering a major collection.
151  *
152  * Bigger values increases throughput by allowing more garbage to sit in the major heap.
153  * Smaller values leads to better memory effiency but more frequent major collections.
154  */
155 #define SGEN_DEFAULT_ALLOWANCE_NURSERY_SIZE_RATIO 4.0
156
157 #define SGEN_MIN_ALLOWANCE_NURSERY_SIZE_RATIO 1.0
158 #define SGEN_MAX_ALLOWANCE_NURSERY_SIZE_RATIO 10.0
159
160 /*
161  * Default ratio of memory we want to release in a major collection in relation to the the current heap size.
162  *
163  * A major collection target is to free a given amount of memory. This amount is a ratio of the major heap size.
164  *
165  * Values above 0.5 cause the heap to agressively grow when it's small and waste memory when it's big.
166  * Lower values will produce more reasonable sized heaps when it's small, but will be suboptimal at large
167  * sizes as they will use a small fraction only.
168  *
169  */
170 #define SGEN_DEFAULT_SAVE_TARGET_RATIO 0.5
171
172 #define SGEN_MIN_SAVE_TARGET_RATIO 0.1
173 #define SGEN_MAX_SAVE_TARGET_RATIO 2.0
174
175 #endif