summaryrefslogtreecommitdiff
path: root/innobase
diff options
context:
space:
mode:
authorheikki@hundin.mysql.fi <>2003-10-17 23:44:34 +0300
committerheikki@hundin.mysql.fi <>2003-10-17 23:44:34 +0300
commit91f5c5e3379869c82b1477a37cefe54be084f261 (patch)
tree27c4cf6a0ebf62c4a01fd1fe3028b1d331e84e4a /innobase
parent4aedeb3a607a51a3bc1476770842bb5e89fb1a18 (diff)
downloadmariadb-git-91f5c5e3379869c82b1477a37cefe54be084f261.tar.gz
thr0loc.c, srv0start.c, srv0srv.c, srv0srv.h, os0thread.h, ha_innodb.cc:
Backport from 4.1: reduce InnoDB memory consumption if buf pool < 8 MB
Diffstat (limited to 'innobase')
-rw-r--r--innobase/include/os0thread.h11
-rw-r--r--innobase/include/srv0srv.h2
-rw-r--r--innobase/srv/srv0srv.c14
-rw-r--r--innobase/srv/srv0start.c22
-rw-r--r--innobase/thr/thr0loc.c1
5 files changed, 39 insertions, 11 deletions
diff --git a/innobase/include/os0thread.h b/innobase/include/os0thread.h
index 491d8866af4..554ca0563e4 100644
--- a/innobase/include/os0thread.h
+++ b/innobase/include/os0thread.h
@@ -15,14 +15,9 @@ Created 9/8/1995 Heikki Tuuri
/* Maximum number of threads which can be created in the program;
this is also the size of the wait slot array for MySQL threads which
can wait inside InnoDB */
-#if defined(__WIN__) || defined(__NETWARE__)
-/* Create less event semaphores because Win 98/ME had difficult creating
-40000 event semaphores */
-/* TODO: these just take a lot of memory on NetWare. should netware move up? */
-#define OS_THREAD_MAX_N 1000
-#else
-#define OS_THREAD_MAX_N 10000
-#endif
+
+#define OS_THREAD_MAX_N srv_max_n_threads
+
/* Possible fixed priorities for threads */
#define OS_THREAD_PRIORITY_NONE 100
diff --git a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h
index f4255fc9a98..87df3904f19 100644
--- a/innobase/include/srv0srv.h
+++ b/innobase/include/srv0srv.h
@@ -80,6 +80,8 @@ extern ulint srv_max_dirty_pages_pct;
extern ulint srv_force_recovery;
extern ulint srv_thread_concurrency;
+extern ulint srv_max_n_threads;
+
extern lint srv_conc_n_threads;
extern ibool srv_fast_shutdown;
diff --git a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
index f31d275eff0..8aba1b4f414 100644
--- a/innobase/srv/srv0srv.c
+++ b/innobase/srv/srv0srv.c
@@ -142,7 +142,7 @@ byte srv_latin1_ordering[256] /* The sort order table of the latin1
ulint srv_pool_size = ULINT_MAX; /* size in database pages;
MySQL originally sets this
- value in megabytes */
+ value in bytes */
ulint srv_mem_pool_size = ULINT_MAX; /* size in bytes */
ulint srv_lock_table_size = ULINT_MAX;
@@ -169,6 +169,12 @@ the user from forgetting the innodb_force_recovery keyword to my.cnf */
ulint srv_force_recovery = 0;
/*-----------------------*/
+/* We are prepared for a situation that we have this many threads waiting for
+a semaphore inside InnoDB. innobase_start_or_create_for_mysql() sets the
+value. */
+
+ulint srv_max_n_threads = 0;
+
/* The following controls how many threads we let inside InnoDB concurrently:
threads waiting for locks are not counted into the number because otherwise
we could get a deadlock. MySQL creates a thread for each user session, and
@@ -208,7 +214,7 @@ struct srv_conc_slot_struct{
UT_LIST_BASE_NODE_T(srv_conc_slot_t) srv_conc_queue; /* queue of threads
waiting to get in */
-srv_conc_slot_t srv_conc_slots[OS_THREAD_MAX_N]; /* array of wait
+srv_conc_slot_t* srv_conc_slots; /* array of wait
slots */
/* Number of times a thread is allowed to enter InnoDB within the same
@@ -1693,6 +1699,8 @@ srv_init(void)
os_fast_mutex_init(&srv_conc_mutex);
UT_LIST_INIT(srv_conc_queue);
+
+ srv_conc_slots = mem_alloc(OS_THREAD_MAX_N * sizeof(srv_conc_slot_t));
for (i = 0; i < OS_THREAD_MAX_N; i++) {
conc_slot = srv_conc_slots + i;
@@ -1740,7 +1748,7 @@ srv_conc_enter_innodb(
thread */
{
ibool has_slept = FALSE;
- srv_conc_slot_t* slot;
+ srv_conc_slot_t* slot = NULL;
ulint i;
char err_buf[1000];
diff --git a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c
index a85c3615c1b..af4ca71d443 100644
--- a/innobase/srv/srv0start.c
+++ b/innobase/srv/srv0start.c
@@ -1087,6 +1087,28 @@ innobase_start_or_create_for_mysql(void)
return(DB_ERROR);
}
+ /* Set the maximum number of threads which can wait for a semaphore
+ inside InnoDB */
+#if defined(__WIN__) || defined(__NETWARE__)
+
+/* Create less event semaphores because Win 98/ME had difficulty creating
+40000 event semaphores.
+Comment from Novell, Inc.: also, these just take a lot of memory on
+NetWare. */
+ srv_max_n_threads = 1000;
+#else
+ if (srv_pool_size >= 8 * 1024 * 1024) {
+ /* Here we still have srv_pool_size counted
+ in bytes, srv_boot converts the value to
+ pages; if buffer pool is less than 8 MB,
+ assume fewer threads. */
+ srv_max_n_threads = 10000;
+ } else {
+ srv_max_n_threads = 1000; /* saves several MB of memory,
+ especially in 64-bit
+ computers */
+ }
+#endif
err = srv_boot();
if (err != DB_SUCCESS) {
diff --git a/innobase/thr/thr0loc.c b/innobase/thr/thr0loc.c
index fbf3e3a1dad..839cb024f25 100644
--- a/innobase/thr/thr0loc.c
+++ b/innobase/thr/thr0loc.c
@@ -14,6 +14,7 @@ Created 10/5/1995 Heikki Tuuri
#include "sync0sync.h"
#include "hash0hash.h"
#include "mem0mem.h"
+#include "srv0srv.h"
/*
IMPLEMENTATION OF THREAD LOCAL STORAGE