]>
Commit | Line | Data |
---|---|---|
89b96684 ER |
1 | diff -ruN a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h |
2 | --- a/innobase/include/srv0srv.h 2009-07-06 15:59:52.000000000 +0900 | |
3 | +++ b/innobase/include/srv0srv.h 2009-07-06 16:06:51.000000000 +0900 | |
4 | @@ -90,6 +90,7 @@ | |
5 | extern ulint srv_mem_pool_size; | |
6 | extern ulint srv_lock_table_size; | |
7 | ||
8 | +extern ibool srv_use_sys_malloc; | |
9 | extern ibool srv_thread_concurrency_timer_based; | |
10 | ||
11 | extern ulint srv_n_file_io_threads; | |
12 | diff -ruN a/innobase/include/ut0mem.h b/innobase/include/ut0mem.h | |
13 | --- a/innobase/include/ut0mem.h 2009-07-07 21:54:07.000000000 +0900 | |
14 | +++ b/innobase/include/ut0mem.h 2009-08-03 14:42:17.000000000 +0900 | |
15 | @@ -30,6 +30,13 @@ | |
16 | ||
17 | ||
18 | /************************************************************************** | |
19 | +Initializes the mem block list at database startup. */ | |
20 | + | |
21 | +void | |
22 | +ut_mem_block_list_init(void); | |
23 | +/*========================*/ | |
24 | + | |
25 | +/************************************************************************** | |
26 | Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is | |
27 | defined and set_to_zero is TRUE. */ | |
28 | ||
29 | diff -ruN a/innobase/mem/mem0dbg.c b/innobase/mem/mem0dbg.c | |
30 | --- a/innobase/mem/mem0dbg.c 2009-05-08 06:12:10.000000000 +0900 | |
31 | +++ b/innobase/mem/mem0dbg.c 2009-07-06 16:48:17.000000000 +0900 | |
32 | @@ -134,6 +134,14 @@ | |
33 | mem_hash_initialized = TRUE; | |
34 | #endif | |
35 | ||
36 | + if (UNIV_LIKELY(srv_use_sys_malloc)) { | |
37 | + /* When innodb_use_sys_malloc is set, the | |
38 | + mem_comm_pool won't be used for any allocations. We | |
39 | + create a dummy mem_comm_pool, because some statistics | |
40 | + and debugging code relies on it being initialized. */ | |
41 | + size = 1; | |
42 | + } | |
43 | + | |
44 | mem_comm_pool = mem_pool_create(size); | |
45 | } | |
46 | ||
47 | diff -ruN a/innobase/mem/mem0pool.c b/innobase/mem/mem0pool.c | |
48 | --- a/innobase/mem/mem0pool.c 2009-05-08 06:12:10.000000000 +0900 | |
49 | +++ b/innobase/mem/mem0pool.c 2009-07-06 17:22:09.000000000 +0900 | |
50 | @@ -11,6 +11,7 @@ | |
51 | #include "mem0pool.ic" | |
52 | #endif | |
53 | ||
54 | +#include "srv0srv.h" | |
55 | #include "sync0sync.h" | |
56 | #include "ut0mem.h" | |
57 | #include "ut0lst.h" | |
58 | @@ -191,8 +192,6 @@ | |
59 | ulint i; | |
60 | ulint used; | |
61 | ||
62 | - ut_a(size > 10000); | |
63 | - | |
64 | pool = ut_malloc(sizeof(mem_pool_t)); | |
65 | ||
66 | /* We do not set the memory to zero (FALSE) in the pool, | |
67 | @@ -330,6 +329,10 @@ | |
68 | ulint n; | |
69 | ibool ret; | |
70 | ||
71 | + if (UNIV_LIKELY(srv_use_sys_malloc)) { | |
72 | + return(malloc(size)); | |
73 | + } | |
74 | + | |
75 | n = ut_2_log(ut_max(size + MEM_AREA_EXTRA_SIZE, MEM_AREA_MIN_SIZE)); | |
76 | ||
77 | mutex_enter(&(pool->mutex)); | |
78 | @@ -457,6 +460,11 @@ | |
79 | ulint size; | |
80 | ulint n; | |
81 | ||
82 | + if (UNIV_LIKELY(srv_use_sys_malloc)) { | |
83 | + free(ptr); | |
84 | + return; | |
85 | + } | |
86 | + | |
87 | /* It may be that the area was really allocated from the OS with | |
88 | regular malloc: check if ptr points within our memory pool */ | |
89 | ||
90 | diff -ruN a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c | |
91 | --- a/innobase/srv/srv0srv.c 2009-07-06 15:59:52.000000000 +0900 | |
92 | +++ b/innobase/srv/srv0srv.c 2009-07-06 16:08:06.000000000 +0900 | |
93 | @@ -273,6 +273,7 @@ | |
94 | computer. Bigger computers need bigger values. Value 0 will disable the | |
95 | concurrency check. */ | |
96 | ||
97 | +ibool srv_use_sys_malloc = TRUE; | |
98 | ibool srv_thread_concurrency_timer_based = TRUE; | |
99 | ulong srv_thread_concurrency = 0; | |
100 | ulong srv_commit_concurrency = 0; | |
101 | @@ -1012,6 +1013,7 @@ | |
102 | srv_general_init(void) | |
103 | /*==================*/ | |
104 | { | |
105 | + ut_mem_block_list_init(); | |
106 | os_sync_init(); | |
107 | sync_init(); | |
108 | mem_init(srv_mem_pool_size); | |
109 | diff -ruN a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c | |
110 | --- a/innobase/srv/srv0start.c 2009-07-06 15:59:52.000000000 +0900 | |
111 | +++ b/innobase/srv/srv0start.c 2009-07-06 16:23:38.000000000 +0900 | |
112 | @@ -1040,6 +1040,11 @@ | |
113 | return(DB_ERROR); | |
114 | } | |
115 | ||
116 | + if (UNIV_LIKELY(srv_use_sys_malloc)) { | |
117 | + fprintf(stderr, | |
118 | + "InnoDB: The InnoDB memory heap is disabled\n"); | |
119 | + } | |
120 | + | |
121 | #ifdef HAVE_ATOMIC_BUILTINS | |
122 | fprintf(stderr, | |
123 | "InnoDB: use atomic builtins.\n"); | |
124 | diff -ruN a/innobase/ut/ut0mem.c b/innobase/ut/ut0mem.c | |
125 | --- a/innobase/ut/ut0mem.c 2009-05-08 06:12:13.000000000 +0900 | |
126 | +++ b/innobase/ut/ut0mem.c 2009-07-06 16:42:26.000000000 +0900 | |
127 | @@ -15,6 +15,7 @@ | |
128 | #include "mem0mem.h" | |
129 | #include "os0sync.h" | |
130 | #include "os0thread.h" | |
131 | +#include "srv0srv.h" | |
132 | ||
133 | /* This struct is placed first in every allocated memory block */ | |
134 | typedef struct ut_mem_block_struct ut_mem_block_t; | |
135 | @@ -43,7 +44,7 @@ | |
136 | ||
137 | /************************************************************************** | |
138 | Initializes the mem block list at database startup. */ | |
139 | -static | |
140 | + | |
141 | void | |
142 | ut_mem_block_list_init(void) | |
143 | /*========================*/ | |
144 | @@ -70,11 +71,21 @@ | |
145 | ulint retry_count = 0; | |
146 | void* ret; | |
147 | ||
148 | - ut_ad((sizeof(ut_mem_block_t) % 8) == 0); /* check alignment ok */ | |
149 | + if (UNIV_LIKELY(srv_use_sys_malloc)) { | |
150 | + ret = malloc(n); | |
151 | + ut_a(ret || !assert_on_error); | |
152 | ||
153 | - if (!ut_mem_block_list_inited) { | |
154 | - ut_mem_block_list_init(); | |
155 | +#ifdef UNIV_SET_MEM_TO_ZERO | |
156 | + if (set_to_zero) { | |
157 | + memset(ret, '\0', n); | |
158 | + } | |
159 | +#endif | |
160 | + return(ret); | |
161 | } | |
162 | + | |
163 | + ut_ad((sizeof(ut_mem_block_t) % 8) == 0); /* check alignment ok */ | |
164 | + | |
165 | + ut_a(ut_mem_block_list_inited); | |
166 | retry: | |
167 | os_fast_mutex_lock(&ut_list_mutex); | |
168 | ||
169 | @@ -223,6 +236,11 @@ | |
170 | { | |
171 | ut_mem_block_t* block; | |
172 | ||
173 | + if (UNIV_LIKELY(srv_use_sys_malloc)) { | |
174 | + free(ptr); | |
175 | + return; | |
176 | + } | |
177 | + | |
178 | block = (ut_mem_block_t*)((byte*)ptr - sizeof(ut_mem_block_t)); | |
179 | ||
180 | os_fast_mutex_lock(&ut_list_mutex); | |
181 | @@ -275,6 +293,10 @@ | |
182 | ulint min_size; | |
183 | void* new_ptr; | |
184 | ||
185 | + if (UNIV_LIKELY(srv_use_sys_malloc)) { | |
186 | + return(realloc(ptr, size)); | |
187 | + } | |
188 | + | |
189 | if (ptr == NULL) { | |
190 | ||
191 | return(ut_malloc(size)); | |
192 | diff -ruN a/patch_info/innodb_use_sys_malloc.info b/patch_info/innodb_use_sys_malloc.info | |
193 | --- /dev/null 1970-01-01 09:00:00.000000000 +0900 | |
194 | +++ b/patch_info/innodb_use_sys_malloc.info 2009-07-06 16:04:24.000000000 +0900 | |
195 | @@ -0,0 +1,6 @@ | |
196 | +File=innodb_use_sys_malloc.patch | |
197 | +Name=InnoDB uses malloc directly (backport from InnoDB-Plugin) | |
198 | +Version=1.0 | |
199 | +Author=Percona <info@percona.com> | |
200 | +License=GPL | |
201 | +Comment | |
202 | diff -ruN a/sql/ha_innodb.cc b/sql/ha_innodb.cc | |
203 | --- a/sql/ha_innodb.cc 2009-07-06 15:59:52.000000000 +0900 | |
204 | +++ b/sql/ha_innodb.cc 2009-07-06 16:10:15.000000000 +0900 | |
205 | @@ -152,6 +152,7 @@ | |
206 | innobase_open_files; | |
207 | ||
208 | long innobase_read_io_threads, innobase_write_io_threads; | |
209 | +my_bool innobase_use_sys_malloc; | |
210 | my_bool innobase_thread_concurrency_timer_based; | |
211 | long innobase_extra_rsegments; | |
212 | longlong innobase_buffer_pool_size, innobase_log_file_size; | |
213 | @@ -1492,6 +1493,8 @@ | |
214 | srv_n_log_files = (ulint) innobase_log_files_in_group; | |
215 | srv_log_file_size = (ulint) innobase_log_file_size; | |
216 | ||
217 | + srv_use_sys_malloc = (ibool) innobase_use_sys_malloc; | |
218 | + | |
219 | srv_thread_concurrency_timer_based = | |
220 | (ibool) innobase_thread_concurrency_timer_based; | |
221 | ||
222 | diff -ruN a/sql/ha_innodb.h b/sql/ha_innodb.h | |
223 | --- a/sql/ha_innodb.h 2009-07-06 15:59:52.000000000 +0900 | |
224 | +++ b/sql/ha_innodb.h 2009-07-06 16:10:42.000000000 +0900 | |
225 | @@ -205,6 +205,7 @@ | |
226 | extern long innobase_buffer_pool_awe_mem_mb; | |
227 | extern long innobase_file_io_threads, innobase_lock_wait_timeout; | |
228 | extern long innobase_read_io_threads, innobase_write_io_threads; | |
229 | +extern my_bool innobase_use_sys_malloc; | |
230 | extern my_bool innobase_thread_concurrency_timer_based; | |
231 | extern long innobase_extra_rsegments; | |
232 | extern long innobase_force_recovery; | |
233 | diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc | |
234 | --- a/sql/mysqld.cc 2009-07-06 15:59:52.000000000 +0900 | |
235 | +++ b/sql/mysqld.cc 2009-07-06 16:16:56.000000000 +0900 | |
236 | @@ -5102,6 +5102,7 @@ | |
237 | OPT_INNODB_ADAPTIVE_CHECKPOINT, | |
238 | OPT_INNODB_READ_IO_THREADS, | |
239 | OPT_INNODB_WRITE_IO_THREADS, | |
240 | + OPT_INNODB_USE_SYS_MALLOC, | |
241 | OPT_INNODB_THREAD_CONCURRENCY_TIMER_BASED, | |
242 | OPT_INNODB_EXTRA_RSEGMENTS, | |
243 | OPT_INNODB_DICT_SIZE_LIMIT, | |
244 | @@ -5470,6 +5471,10 @@ | |
245 | "Number of background write I/O threads in InnoDB.", | |
246 | (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads, | |
247 | 0, GET_LONG, REQUIRED_ARG, 8, 1, 64, 0, 0, 0}, | |
248 | + {"innodb_use_sys_malloc", OPT_INNODB_USE_SYS_MALLOC, | |
249 | + "Use OS memory allocator instead of InnoDB's internal memory allocator", | |
250 | + (gptr*) &innobase_use_sys_malloc, (gptr*) &innobase_use_sys_malloc, | |
251 | + 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, | |
252 | {"innodb_thread_concurrency_timer_based", OPT_INNODB_THREAD_CONCURRENCY_TIMER_BASED, | |
253 | "Use InnoDB timer based concurrency throttling. ", | |
254 | (gptr*) &innobase_thread_concurrency_timer_based, | |
255 | diff -ruN a/sql/set_var.cc b/sql/set_var.cc | |
256 | --- a/sql/set_var.cc 2009-07-06 15:59:52.000000000 +0900 | |
257 | +++ b/sql/set_var.cc 2009-07-06 16:22:05.000000000 +0900 | |
258 | @@ -1093,6 +1093,7 @@ | |
259 | {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS}, | |
260 | {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG}, | |
261 | {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG}, | |
262 | + {"innodb_use_sys_malloc", (char*) &innobase_use_sys_malloc, SHOW_MY_BOOL}, | |
263 | {"innodb_thread_concurrency_timer_based", (char*) &innobase_thread_concurrency_timer_based, SHOW_MY_BOOL}, | |
264 | {"innodb_extra_rsegments", (char*) &innobase_extra_rsegments, SHOW_LONG}, | |
265 | {sys_innodb_dict_size_limit.name, (char*) &sys_innodb_dict_size_limit, SHOW_SYS}, |