mirror of
https://github.com/MariaDB/server.git
synced 2025-02-02 03:51:50 +01:00
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
This commit is contained in:
parent
e940107e2d
commit
09a089ecf8
8 changed files with 123 additions and 0 deletions
|
@ -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[]= {
|
||||||
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;
|
||||||
/* 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
|
||||||
#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(
|
||||||
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(
|
||||||
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 */
|
||||||
|
|
||||||
|
|
2
mysql-test/innodb-use-sys-malloc-master.opt
Normal file
2
mysql-test/innodb-use-sys-malloc-master.opt
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
--innodb-use-sys-malloc=true
|
||||||
|
--innodb-use-sys-malloc=true
|
48
mysql-test/innodb-use-sys-malloc.result
Normal file
48
mysql-test/innodb-use-sys-malloc.result
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
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;
|
48
mysql-test/innodb-use-sys-malloc.test
Normal file
48
mysql-test/innodb-use-sys-malloc.test
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
--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;
|
||||||
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)
|
||||||
"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
|
||||||
|
|
Loading…
Add table
Reference in a new issue