Commit aa70919b authored by inaam's avatar inaam

branches/zip: Implement the parameter innodb_use_sys_malloc

(false by default), for disabling InnoDB's internal memory allocator
and using system malloc/free instead.

rb://62 approved by Marko
parent 4ead562d
...@@ -9583,6 +9583,11 @@ static MYSQL_SYSVAR_STR(version, innodb_version_str, ...@@ -9583,6 +9583,11 @@ static MYSQL_SYSVAR_STR(version, innodb_version_str,
PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_READONLY, PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_READONLY,
"InnoDB version", NULL, NULL, INNODB_VERSION_STR); "InnoDB version", NULL, NULL, INNODB_VERSION_STR);
static MYSQL_SYSVAR_BOOL(use_sys_malloc, srv_use_sys_malloc,
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
"Use OS memory allocator instead of InnoDB's internal memory allocator",
NULL, NULL, FALSE);
static struct st_mysql_sys_var* innobase_system_variables[]= { static struct st_mysql_sys_var* innobase_system_variables[]= {
MYSQL_SYSVAR(additional_mem_pool_size), MYSQL_SYSVAR(additional_mem_pool_size),
MYSQL_SYSVAR(autoextend_increment), MYSQL_SYSVAR(autoextend_increment),
...@@ -9629,6 +9634,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= { ...@@ -9629,6 +9634,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= {
MYSQL_SYSVAR(thread_sleep_delay), MYSQL_SYSVAR(thread_sleep_delay),
MYSQL_SYSVAR(autoinc_lock_mode), MYSQL_SYSVAR(autoinc_lock_mode),
MYSQL_SYSVAR(version), MYSQL_SYSVAR(version),
MYSQL_SYSVAR(use_sys_malloc),
NULL NULL
}; };
......
...@@ -93,6 +93,7 @@ extern ulong srv_flush_log_at_trx_commit; ...@@ -93,6 +93,7 @@ extern ulong srv_flush_log_at_trx_commit;
/* The sort order table of the MySQL latin1_swedish_ci character set /* The sort order table of the MySQL latin1_swedish_ci character set
collation */ collation */
extern const byte* srv_latin1_ordering; extern const byte* srv_latin1_ordering;
extern my_bool srv_use_sys_malloc;
extern ulint srv_buf_pool_size; /* requested size in bytes */ extern ulint srv_buf_pool_size; /* requested size in bytes */
extern ulint srv_buf_pool_old_size; /* previously requested size */ extern ulint srv_buf_pool_old_size; /* previously requested size */
extern ulint srv_buf_pool_curr_size; /* current size in bytes */ extern ulint srv_buf_pool_curr_size; /* current size in bytes */
......
...@@ -11,6 +11,7 @@ Created 5/12/1997 Heikki Tuuri ...@@ -11,6 +11,7 @@ Created 5/12/1997 Heikki Tuuri
#include "mem0pool.ic" #include "mem0pool.ic"
#endif #endif
#include "srv0srv.h"
#include "sync0sync.h" #include "sync0sync.h"
#include "ut0mem.h" #include "ut0mem.h"
#include "ut0lst.h" #include "ut0lst.h"
...@@ -336,6 +337,12 @@ mem_area_alloc( ...@@ -336,6 +337,12 @@ mem_area_alloc(
ulint n; ulint n;
ibool ret; ibool ret;
/* If we are using os allocator just make a simple call
to malloc */
if (srv_use_sys_malloc) {
return(malloc(*psize));
}
size = *psize; size = *psize;
n = ut_2_log(ut_max(size + MEM_AREA_EXTRA_SIZE, MEM_AREA_MIN_SIZE)); n = ut_2_log(ut_max(size + MEM_AREA_EXTRA_SIZE, MEM_AREA_MIN_SIZE));
...@@ -470,6 +477,10 @@ mem_area_free( ...@@ -470,6 +477,10 @@ mem_area_free(
ulint size; ulint size;
ulint n; ulint n;
if (srv_use_sys_malloc) {
return(free(ptr));
}
/* It may be that the area was really allocated from the OS with /* It may be that the area was really allocated from the OS with
regular malloc: check if ptr points within our memory pool */ regular malloc: check if ptr points within our memory pool */
......
--innodb-use-sys-malloc=true
--innodb-use-sys-malloc=true
SELECT @@GLOBAL.innodb_use_sys_malloc;
@@GLOBAL.innodb_use_sys_malloc
1
1 Expected
SET @@GLOBAL.innodb_use_sys_malloc=0;
ERROR HY000: Variable 'innodb_use_sys_malloc' is a read only variable
Expected error 'Read only variable'
SELECT @@GLOBAL.innodb_use_sys_malloc;
@@GLOBAL.innodb_use_sys_malloc
1
1 Expected
drop table if exists t1;
create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
insert into t1 values (1),(2),(3),(4),(5),(6),(7);
select * from t1;
a
1
2
3
4
5
6
7
drop table t1;
SELECT @@GLOBAL.innodb_use_sys_malloc;
@@GLOBAL.innodb_use_sys_malloc
1
1 Expected
SET @@GLOBAL.innodb_use_sys_malloc=0;
ERROR HY000: Variable 'innodb_use_sys_malloc' is a read only variable
Expected error 'Read only variable'
SELECT @@GLOBAL.innodb_use_sys_malloc;
@@GLOBAL.innodb_use_sys_malloc
1
1 Expected
drop table if exists t1;
create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
insert into t1 values (1),(2),(3),(4),(5),(6),(7);
select * from t1;
a
1
2
3
4
5
6
7
drop table t1;
--source include/have_innodb.inc
#display current value of innodb_use_sys_malloc
SELECT @@GLOBAL.innodb_use_sys_malloc;
--echo 1 Expected
#try changing it. Should fail.
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SET @@GLOBAL.innodb_use_sys_malloc=0;
--echo Expected error 'Read only variable'
SELECT @@GLOBAL.innodb_use_sys_malloc;
--echo 1 Expected
#do some stuff to see if it works.
--disable_warnings
drop table if exists t1;
--enable_warnings
create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
insert into t1 values (1),(2),(3),(4),(5),(6),(7);
select * from t1;
drop table t1;
--source include/have_innodb.inc
#display current value of innodb_use_sys_malloc
SELECT @@GLOBAL.innodb_use_sys_malloc;
--echo 1 Expected
#try changing it. Should fail.
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SET @@GLOBAL.innodb_use_sys_malloc=0;
--echo Expected error 'Read only variable'
SELECT @@GLOBAL.innodb_use_sys_malloc;
--echo 1 Expected
#do some stuff to see if it works.
--disable_warnings
drop table if exists t1;
--enable_warnings
create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
insert into t1 values (1),(2),(3),(4),(5),(6),(7);
select * from t1;
drop table t1;
...@@ -136,6 +136,8 @@ UNIV_INTERN ulong srv_flush_log_at_trx_commit = 1; ...@@ -136,6 +136,8 @@ UNIV_INTERN ulong srv_flush_log_at_trx_commit = 1;
collation */ collation */
UNIV_INTERN const byte* srv_latin1_ordering; UNIV_INTERN const byte* srv_latin1_ordering;
/* use os/external memory allocator */
UNIV_INTERN my_bool srv_use_sys_malloc = FALSE;
/* requested size in kilobytes */ /* requested size in kilobytes */
UNIV_INTERN ulint srv_buf_pool_size = ULINT_MAX; UNIV_INTERN ulint srv_buf_pool_size = ULINT_MAX;
/* previously requested size */ /* previously requested size */
......
...@@ -1047,6 +1047,11 @@ innobase_start_or_create_for_mysql(void) ...@@ -1047,6 +1047,11 @@ innobase_start_or_create_for_mysql(void)
"InnoDB: !!!!!!!! UNIV_MEM_DEBUG switched on !!!!!!!!!\n"); "InnoDB: !!!!!!!! UNIV_MEM_DEBUG switched on !!!!!!!!!\n");
#endif #endif
if (srv_use_sys_malloc) {
fprintf(stderr,
"InnoDB: The InnoDB memory heap is disabled\n");
}
/* Since InnoDB does not currently clean up all its internal data /* Since InnoDB does not currently clean up all its internal data
structures in MySQL Embedded Server Library server_end(), we structures in MySQL Embedded Server Library server_end(), we
print an error message if someone tries to start up InnoDB a print an error message if someone tries to start up InnoDB a
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment