2010/3/11 Pavel Stehule <pavel.stehule@gmail.com>:
> 2010/3/11 Tom Lane <tgl@sss.pgh.pa.us>:
>> Pavel Stehule <pavel.stehule@gmail.com> writes:
>>> There are some wrong in our implementation NISortDictionary. After
>>> initialisation is ts_cache memory context 55MB long and pg takes
>>> 190MB.
>>
>> What's your tsearch configuration exactly?
>>
I have a 64bit Linux.
The problem is in very large small allocations - there are 853215 nodes.
The memory can be minimalized with some block allocations
static void.
binit(void)
{
<------>data = NULL;
<------>allocated = 0;
}
static char *
balloc(size_t size)
{
<------>char *result;
<------>
<------>if (data == NULL || size > allocated )
<------>{
<------><------>data = palloc(1024 * 100);
<------><------>allocated = 1024 * 100;
<------>}
<------>
<------>result = data;
<------>data += size;
<------>allocated -= size;
<------>memset(result, 0, size);
<------>
<------>return result;
}
I replaced palloc0 inside mkSPnode by balloc
cspell: 25626352 total in 349 blocks; 11048 free (2 chunks); 25615304 used Ispell dictionary init context: 27615288
totalin 13 blocks; 7710864
free (34 chunks); 19904424 used
versus
cspell: 55853736 total in 6789 blocks; 130208 free (1553 chunks); 55723528 used Ispell dictionary init context:
27615288total in 13 blocks; 7710864
free (34 chunks); 19904424 used
Regards
Pavel