Allocate HEAP blocks in smaller blocks to get better memory utilization and more speed when used with safemalloc.
Don't initalize memory areas when run with --skip-safemalloc.
This commit is contained in:
parent
9b1d5b6f5f
commit
00e86fb5cc
@ -46929,10 +46929,12 @@ not yet 100% confident in this code.
|
|||||||
@node News-3.23.54, News-3.23.53, News-3.23.x, News-3.23.x
|
@node News-3.23.54, News-3.23.53, News-3.23.x, News-3.23.x
|
||||||
@appendixsubsec Changes in release 3.23.54
|
@appendixsubsec Changes in release 3.23.54
|
||||||
@itemize
|
@itemize
|
||||||
|
@item
|
||||||
Fixed reference to freed memory when doing complicated @code{GROUP BY
|
Fixed reference to freed memory when doing complicated @code{GROUP BY
|
||||||
... ORDER BY} queries. Symptom was that @code{mysqld} died in function
|
... ORDER BY} queries. Symptom was that @code{mysqld} died in function
|
||||||
@code{send_fields}.
|
@code{send_fields}.
|
||||||
queries.
|
@item
|
||||||
|
Allocate heap rows in smaller blocks to get better memory usage.
|
||||||
@end itemize
|
@end itemize
|
||||||
|
|
||||||
@node News-3.23.53, News-3.23.52, News-3.23.54, News-3.23.x
|
@node News-3.23.53, News-3.23.52, News-3.23.54, News-3.23.x
|
||||||
|
@ -22,6 +22,17 @@
|
|||||||
#endif
|
#endif
|
||||||
#include "heap.h" /* Structs & some defines */
|
#include "heap.h" /* Structs & some defines */
|
||||||
|
|
||||||
|
/*
|
||||||
|
When allocating keys /rows in the internal block structure, do it
|
||||||
|
within the following boundaries.
|
||||||
|
|
||||||
|
The challenge is to find the balance between allocate as few blocks
|
||||||
|
as possible and keep memory consumption down.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define HP_MIN_RECORDS_IN_BLOCK 16
|
||||||
|
#define HP_MAX_RECORDS_IN_BLOCK 8192
|
||||||
|
|
||||||
/* Some extern variables */
|
/* Some extern variables */
|
||||||
|
|
||||||
extern LIST *heap_open_list,*heap_share_list;
|
extern LIST *heap_open_list,*heap_share_list;
|
||||||
|
@ -157,8 +157,14 @@ static void init_block(HP_BLOCK *block, uint reclength, ulong min_records,
|
|||||||
max_records=1000; /* As good as quess as anything */
|
max_records=1000; /* As good as quess as anything */
|
||||||
recbuffer=(uint) (reclength+sizeof(byte**)-1) & ~(sizeof(byte**)-1);
|
recbuffer=(uint) (reclength+sizeof(byte**)-1) & ~(sizeof(byte**)-1);
|
||||||
records_in_block=max_records/10;
|
records_in_block=max_records/10;
|
||||||
if (records_in_block < 10 && max_records)
|
if (records_in_block < HP_MIN_RECORDS_IN_BLOCK && max_records)
|
||||||
records_in_block=10;
|
records_in_block= HP_MIN_RECORDS_IN_BLOCK;
|
||||||
|
/*
|
||||||
|
Don't allocate too many rows at one time too keep memory consumption
|
||||||
|
done when we don't need it.
|
||||||
|
*/
|
||||||
|
if (records_in_block > HP_MAX_RECORDS_IN_BLOCK)
|
||||||
|
records_in_block= HP_MAX_RECORDS_IN_BLOCK;
|
||||||
if (!records_in_block || records_in_block*recbuffer >
|
if (!records_in_block || records_in_block*recbuffer >
|
||||||
(my_default_record_cache_size-sizeof(HP_PTRS)*HP_MAX_LEVELS))
|
(my_default_record_cache_size-sizeof(HP_PTRS)*HP_MAX_LEVELS))
|
||||||
records_in_block=(my_default_record_cache_size-sizeof(HP_PTRS)*
|
records_in_block=(my_default_record_cache_size-sizeof(HP_PTRS)*
|
||||||
|
@ -194,9 +194,7 @@ gptr _mymalloc (uint uSize, const char *sFile, uint uLine, myf MyFlags)
|
|||||||
pthread_mutex_unlock(&THR_LOCK_malloc);
|
pthread_mutex_unlock(&THR_LOCK_malloc);
|
||||||
|
|
||||||
/* Set the memory to the aribtrary wierd value */
|
/* Set the memory to the aribtrary wierd value */
|
||||||
#ifdef HAVE_purify
|
if ((MyFlags & MY_ZEROFILL) || !sf_malloc_quick)
|
||||||
if (MyFlags & MY_ZEROFILL)
|
|
||||||
#endif
|
|
||||||
bfill(&pTmp -> aData[sf_malloc_prehunc],uSize,
|
bfill(&pTmp -> aData[sf_malloc_prehunc],uSize,
|
||||||
(char) (MyFlags & MY_ZEROFILL ? 0 : ALLOC_VAL));
|
(char) (MyFlags & MY_ZEROFILL ? 0 : ALLOC_VAL));
|
||||||
/* Return a pointer to the real data */
|
/* Return a pointer to the real data */
|
||||||
@ -315,6 +313,7 @@ void _myfree (gptr pPtr, const char *sFile, uint uLine, myf myflags)
|
|||||||
|
|
||||||
#ifndef HAVE_purify
|
#ifndef HAVE_purify
|
||||||
/* Mark this data as free'ed */
|
/* Mark this data as free'ed */
|
||||||
|
if (!sf_malloc_quick)
|
||||||
bfill(&pRec->aData[sf_malloc_prehunc],pRec->uDataSize,(pchar) FREE_VAL);
|
bfill(&pRec->aData[sf_malloc_prehunc],pRec->uDataSize,(pchar) FREE_VAL);
|
||||||
#endif
|
#endif
|
||||||
*((long*) ((char*) &pRec -> lSpecialValue+sf_malloc_prehunc)) = ~MAGICKEY;
|
*((long*) ((char*) &pRec -> lSpecialValue+sf_malloc_prehunc)) = ~MAGICKEY;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user