summaryrefslogtreecommitdiff
path: root/mysys/safemalloc.c
diff options
context:
space:
mode:
authorMichael Widenius <monty@askmonty.org>2010-11-08 13:43:54 +0200
committerMichael Widenius <monty@askmonty.org>2010-11-08 13:43:54 +0200
commit7b047a31a09a7999353232cb6407b4e6338d5b70 (patch)
tree8b23cc836adb9afa6adfa701ac0593b1673625a8 /mysys/safemalloc.c
parent18292caa48f5cca9b651f62c1dbbffefadb33d9f (diff)
downloadmariadb-git-7b047a31a09a7999353232cb6407b4e6338d5b70.tar.gz
Make SQLString reallocation addaptive
Avoid doing reallocs Prealloc some strings / provide extension allocation size to some strings This gave a 25 % speedup in some mysql-test-run tests. mysys/safemalloc.c: More DBUG_PRINT sql/net_serv.cc: Make all mallocs() look the similar. (just-for-safety fix) sql/protocol.cc: Ensure that communication packet buffer is allocated. (It's freed by stored precedures and some DLL statements) sql/sp.cc: Fixed valgrind warning sql/sql_select.cc: Set extent allocation for buffer that has a lot of append() calls. sql/sql_show.cc: Fixed wrong usage of string buffer. Old code worked in test suite 'just-by-chance' sql/sql_string.cc: Call realloc_with_extra_if_needed() in append() functions. sql/sql_string.h: Added 'extra_alloc' member, to specify chunck size for realloc(). extra_alloc is addaptive to catch cases where preallocation of buffers is not done properly. Simplified free() to allow compiler to optimize things better (and to keep things consistent). Fixed shrink() to take into account the extra memory added to the Alloced_length in realloc(). This saves us a realloc() per query. sql/sql_test.cc: Set extent allocation for buffer that has a lot of append() calls. sql/table.cc: Set extent allocation for buffer that has a lot of append() calls.
Diffstat (limited to 'mysys/safemalloc.c')
-rw-r--r--mysys/safemalloc.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/mysys/safemalloc.c b/mysys/safemalloc.c
index 0d0ae2dabe5..0e489263c69 100644
--- a/mysys/safemalloc.c
+++ b/mysys/safemalloc.c
@@ -224,6 +224,8 @@ void *_myrealloc(register void *ptr, register size_t size,
struct st_irem *irem;
char *data;
DBUG_ENTER("_myrealloc");
+ DBUG_PRINT("my",("ptr: 0x%lx size: %lu my_flags: %d", (long) ptr,
+ (ulong) size, MyFlags));
if (!ptr && (MyFlags & MY_ALLOW_ZERO_PTR))
DBUG_RETURN(_mymalloc(size, filename, lineno, MyFlags));
@@ -245,6 +247,8 @@ void *_myrealloc(register void *ptr, register size_t size,
(void) fflush(stderr);
DBUG_RETURN((uchar*) NULL);
}
+ DBUG_PRINT("my", ("old_size: %lu -> new_size: %lu",
+ (ulong) irem->datasize, (ulong) size));
if ((data= _mymalloc(size,filename,lineno,MyFlags))) /* Allocate new area */
{