summaryrefslogtreecommitdiff
path: root/sql/unireg.cc
diff options
context:
space:
mode:
authorDavi Arnaut <Davi.Arnaut@Sun.COM>2010-07-08 18:20:08 -0300
committerDavi Arnaut <Davi.Arnaut@Sun.COM>2010-07-08 18:20:08 -0300
commita10ae35328ec800eff63c0bbb06d279e44c0a5a1 (patch)
tree6c88c3c07b30acb464ca8bf81bbef916216da616 /sql/unireg.cc
parentd4cd1f843da60019664dfad2b0ad6987f82f01c6 (diff)
downloadmariadb-git-a10ae35328ec800eff63c0bbb06d279e44c0a5a1.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.
Diffstat (limited to 'sql/unireg.cc')
-rw-r--r--sql/unireg.cc22
1 files changed, 11 insertions, 11 deletions
diff --git a/sql/unireg.cc b/sql/unireg.cc
index 802e5b7429c..6433b8bc7c2 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -148,7 +148,7 @@ bool mysql_create_frm(THD *thd, const char *file_name,
if (error)
{
- my_free(screen_buff, MYF(0));
+ my_free(screen_buff);
if (! pack_header_error_handler.is_handled)
DBUG_RETURN(1);
@@ -159,7 +159,7 @@ bool mysql_create_frm(THD *thd, const char *file_name,
create_fields,info_length,
screens, create_info->table_options, data_offset, db_file))
{
- my_free(screen_buff, MYF(0));
+ my_free(screen_buff);
DBUG_RETURN(1);
}
}
@@ -228,7 +228,7 @@ bool mysql_create_frm(THD *thd, const char *file_name,
{
my_error(ER_TOO_LONG_TABLE_COMMENT, MYF(0),
real_table_name, (uint) TABLE_COMMENT_MAXLEN);
- my_free(screen_buff,MYF(0));
+ my_free(screen_buff);
DBUG_RETURN(1);
}
char warn_buff[MYSQL_ERRMSG_SIZE];
@@ -259,7 +259,7 @@ bool mysql_create_frm(THD *thd, const char *file_name,
if ((file=create_frm(thd, file_name, db, table, reclength, fileinfo,
create_info, keys, key_info)) < 0)
{
- my_free(screen_buff, MYF(0));
+ my_free(screen_buff);
DBUG_RETURN(1);
}
@@ -374,15 +374,15 @@ bool mysql_create_frm(THD *thd, const char *file_name,
delete crypted;
if (mysql_file_pwrite(file, disk_buff, read_length, filepos+256, MYF_RW))
{
- my_free(disk_buff,MYF(0));
+ my_free(disk_buff);
goto err;
}
- my_free(disk_buff,MYF(0));
+ my_free(disk_buff);
}
#endif
- my_free(screen_buff,MYF(0));
- my_free(keybuff, MYF(0));
+ my_free(screen_buff);
+ my_free(keybuff);
if (opt_sync_frm && !(create_info->options & HA_LEX_CREATE_TMP_TABLE) &&
(mysql_file_sync(file, MYF(MY_WME)) ||
@@ -411,8 +411,8 @@ bool mysql_create_frm(THD *thd, const char *file_name,
DBUG_RETURN(0);
err:
- my_free(screen_buff, MYF(0));
- my_free(keybuff, MYF(0));
+ my_free(screen_buff);
+ my_free(keybuff);
err2:
(void) mysql_file_close(file, MYF(MY_WME));
err3:
@@ -1095,7 +1095,7 @@ static bool make_empty_rec(THD *thd, File file,enum legacy_db_type table_type,
error= mysql_file_write(file, buff, (size_t) reclength, MYF_RW) != 0;
err:
- my_free(buff, MYF(MY_FAE));
+ my_free(buff);
thd->count_cuted_fields= old_count_cuted_fields;
DBUG_RETURN(error);
} /* make_empty_rec */