From 61632073ac9473e00d5e0c88078880d3af575828 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 13 Oct 2002 23:42:37 +0300 Subject: 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. Docs/manual.texi: ChangeLog heap/heapdef.h: Allocate HEAP blocks in smaller blocks to get better memory utilization and more speed when used with safemalloc. heap/hp_open.c: Allocate HEAP blocks in smaller blocks to get better memory utilization and more speed when used with safemalloc. mysys/safemalloc.c: Don't initalize memory areas when run with --skip-safemalloc. This can in some cases increase speed with 20 times when debugging --- heap/heapdef.h | 11 +++++++++++ heap/hp_open.c | 10 ++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'heap') diff --git a/heap/heapdef.h b/heap/heapdef.h index 938cb55c0eb..6b85e234c5e 100644 --- a/heap/heapdef.h +++ b/heap/heapdef.h @@ -22,6 +22,17 @@ #endif #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 */ extern LIST *heap_open_list,*heap_share_list; diff --git a/heap/hp_open.c b/heap/hp_open.c index 692142de14a..e0615879193 100644 --- a/heap/hp_open.c +++ b/heap/hp_open.c @@ -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 */ recbuffer=(uint) (reclength+sizeof(byte**)-1) & ~(sizeof(byte**)-1); records_in_block=max_records/10; - if (records_in_block < 10 && max_records) - records_in_block=10; + if (records_in_block < HP_MIN_RECORDS_IN_BLOCK && max_records) + 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 > (my_default_record_cache_size-sizeof(HP_PTRS)*HP_MAX_LEVELS)) records_in_block=(my_default_record_cache_size-sizeof(HP_PTRS)* -- cgit v1.2.1