diff options
author | Davi Arnaut <Davi.Arnaut@Sun.COM> | 2010-07-08 18:20:08 -0300 |
---|---|---|
committer | Davi Arnaut <Davi.Arnaut@Sun.COM> | 2010-07-08 18:20:08 -0300 |
commit | f56dd32bf7c5b8a8cf35984f39f1a253b75945ff (patch) | |
tree | 6c88c3c07b30acb464ca8bf81bbef916216da616 /storage/ndb | |
parent | d3b01fef18b20f3ac589f2ecc95d64326570583f (diff) | |
download | mariadb-git-f56dd32bf7c5b8a8cf35984f39f1a253b75945ff.tar.gz |
Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled
Essentially, the problem is that safemalloc is excruciatingly
slow as it checks all allocated blocks for overrun at each
memory management primitive, yielding a almost exponential
slowdown for the memory management functions (malloc, realloc,
free). The overrun check basically consists of verifying some
bytes of a block for certain magic keys, which catches some
simple forms of overrun. Another minor problem is violation
of aliasing rules and that its own internal list of blocks
is prone to corruption.
Another issue with safemalloc is rather the maintenance cost
as the tool has a significant impact on the server code.
Given the magnitude of memory debuggers available nowadays,
especially those that are provided with the platform malloc
implementation, maintenance of a in-house and largely obsolete
memory debugger becomes a burden that is not worth the effort
due to its slowness and lack of support for detecting more
common forms of heap corruption.
Since there are third-party tools that can provide the same
functionality at a lower or comparable performance cost, the
solution is to simply remove safemalloc. Third-party tools
can provide the same functionality at a lower or comparable
performance cost.
The removal of safemalloc also allows a simplification of the
malloc wrappers, removing quite a bit of kludge: redefinition
of my_malloc, my_free and the removal of the unused second
argument of my_free. Since free() always check whether the
supplied pointer is null, redudant checks are also removed.
Also, this patch adds unit testing for my_malloc and moves
my_realloc implementation into the same file as the other
memory allocation primitives.
client/mysqldump.c:
Pass my_free directly as its signature is compatible with the
callback type -- which wasn't the case for free_table_ent.
Diffstat (limited to 'storage/ndb')
-rw-r--r-- | storage/ndb/config/win-lib.am | 2 | ||||
-rw-r--r-- | storage/ndb/config/win-prg.am | 2 | ||||
-rw-r--r-- | storage/ndb/include/util/NdbAutoPtr.hpp | 4 | ||||
-rw-r--r-- | storage/ndb/src/mgmapi/mgmapi.cpp | 6 | ||||
-rw-r--r-- | storage/ndb/src/mgmapi/ndb_logevent.cpp | 2 | ||||
-rw-r--r-- | storage/ndb/test/ndbapi/testIndexStat.cpp | 6 | ||||
-rw-r--r-- | storage/ndb/tools/restore/consumer_restore.cpp | 4 |
7 files changed, 13 insertions, 13 deletions
diff --git a/storage/ndb/config/win-lib.am b/storage/ndb/config/win-lib.am index 05ac1ec8a40..1e7bbfae19b 100644 --- a/storage/ndb/config/win-lib.am +++ b/storage/ndb/config/win-lib.am @@ -68,7 +68,7 @@ LIB32=xilink6.exe -lib # PROP Intermediate_Dir "debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /G6 /MTd /W3 /Z7 /Od /Gf /D "WIN32" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_WINDOWS" /FD /c +# ADD CPP /nologo /G6 /MTd /W3 /Z7 /Od /Gf /D "WIN32" /D "_DEBUG" /D "SAFE_MUTEX" /D "_WINDOWS" /FD /c # ADD BASE CPP @includes@ # ADD CPP @includes@ # SUBTRACT CPP /YX diff --git a/storage/ndb/config/win-prg.am b/storage/ndb/config/win-prg.am index 70c19a70c6d..5d56d79c41e 100644 --- a/storage/ndb/config/win-prg.am +++ b/storage/ndb/config/win-prg.am @@ -71,7 +71,7 @@ LINK32=xilink6.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "NDB_WIN32" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G6 /MTd /W3 /Z7 /Od /D "NDB_WIN32" /I "../include" /I "../regex" /I "../zlib" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "HAVE_INNOBASE_DB" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "HAVE_DLOPEN" /FD /c +# ADD CPP /nologo /G6 /MTd /W3 /Z7 /Od /D "NDB_WIN32" /I "../include" /I "../regex" /I "../zlib" /D "_DEBUG" /D "SAFE_MUTEX" /D "HAVE_INNOBASE_DB" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "HAVE_DLOPEN" /FD /c # ADD BASE CPP @includes@ # ADD CPP @includes@ # SUBTRACT CPP /Fr /YX diff --git a/storage/ndb/include/util/NdbAutoPtr.hpp b/storage/ndb/include/util/NdbAutoPtr.hpp index 5210fbc6dde..f11b8f0d5bc 100644 --- a/storage/ndb/include/util/NdbAutoPtr.hpp +++ b/storage/ndb/include/util/NdbAutoPtr.hpp @@ -51,8 +51,8 @@ class My_auto_ptr { T * m_obj; public: My_auto_ptr(T * obj = 0){ m_obj = obj;} - void reset(T * obj = 0) { if (m_obj) my_free(m_obj,MYF(0)); m_obj = obj; } - ~My_auto_ptr() { if (m_obj) my_free(m_obj,MYF(0));} + void reset(T * obj = 0) { if (m_obj) my_free(m_obj); m_obj = obj; } + ~My_auto_ptr() { if (m_obj) my_free(m_obj);} }; #endif diff --git a/storage/ndb/src/mgmapi/mgmapi.cpp b/storage/ndb/src/mgmapi/mgmapi.cpp index 662e5c22f48..78c767c31c6 100644 --- a/storage/ndb/src/mgmapi/mgmapi.cpp +++ b/storage/ndb/src/mgmapi/mgmapi.cpp @@ -212,7 +212,7 @@ extern "C" void ndb_mgm_set_name(NdbMgmHandle handle, const char *name) { - my_free(handle->m_name, MYF(MY_ALLOW_ZERO_PTR)); + my_free(handle->m_name); handle->m_name= my_strdup(name, MYF(MY_WME)); } @@ -278,10 +278,10 @@ ndb_mgm_destroy_handle(NdbMgmHandle * handle) } #endif (*handle)->cfg.~LocalConfig(); - my_free((*handle)->m_name, MYF(MY_ALLOW_ZERO_PTR)); + my_free((*handle)->m_name); if ((*handle)->m_bindaddress) free((*handle)->m_bindaddress); - my_free((char*)* handle,MYF(MY_ALLOW_ZERO_PTR)); + my_free(* handle); * handle = 0; DBUG_VOID_RETURN; } diff --git a/storage/ndb/src/mgmapi/ndb_logevent.cpp b/storage/ndb/src/mgmapi/ndb_logevent.cpp index fbf026fd79d..c372f852144 100644 --- a/storage/ndb/src/mgmapi/ndb_logevent.cpp +++ b/storage/ndb/src/mgmapi/ndb_logevent.cpp @@ -82,7 +82,7 @@ void ndb_mgm_destroy_logevent_handle(NdbLogEventHandle * h) if ( *h ) close((*h)->socket); - my_free((char*)* h,MYF(MY_ALLOW_ZERO_PTR)); + my_free(* h); * h = 0; } diff --git a/storage/ndb/test/ndbapi/testIndexStat.cpp b/storage/ndb/test/ndbapi/testIndexStat.cpp index 0e15cdd80d1..559fade3132 100644 --- a/storage/ndb/test/ndbapi/testIndexStat.cpp +++ b/storage/ndb/test/ndbapi/testIndexStat.cpp @@ -404,9 +404,9 @@ static void freekeys() { if (g_keys != 0) - my_free((char*)g_keys, MYF(0)); + my_free(g_keys); if (g_sortkeys != 0) - my_free((char*)g_sortkeys, MYF(0)); + my_free(g_sortkeys); g_keys = 0; g_sortkeys = 0; } @@ -896,7 +896,7 @@ static void freeranges() { if (g_ranges != 0) - my_free((char*)g_ranges, MYF(0)); + my_free(g_ranges); g_ranges = 0; } diff --git a/storage/ndb/tools/restore/consumer_restore.cpp b/storage/ndb/tools/restore/consumer_restore.cpp index e8e8d584f09..f63cbdd2aa2 100644 --- a/storage/ndb/tools/restore/consumer_restore.cpp +++ b/storage/ndb/tools/restore/consumer_restore.cpp @@ -449,13 +449,13 @@ bool BackupRestore::translate_frm(NdbDictionary::Table *table) } if (map_in_frm(new_data, (const char*)data, data_len, &new_data_len)) { - my_free(new_data, MYF(0)); + my_free(new_data); DBUG_RETURN(TRUE); } if (packfrm((uchar*) new_data, new_data_len, &new_pack_data, &new_pack_len)) { - my_free(new_data, MYF(0)); + my_free(new_data); DBUG_RETURN(TRUE); } table->setFrm(new_pack_data, new_pack_len); |