add function fast_mpool_log_stats
parent
d6b0f1b0c4
commit
5d3c3c576c
|
|
@ -49,6 +49,7 @@ src/tests/test_split_string
|
|||
src/tests/test_uniq_skiplist
|
||||
|
||||
# other
|
||||
*.swp
|
||||
php-fastcommon/.deps
|
||||
php-fastcommon/.libs/
|
||||
|
||||
|
|
|
|||
3
HISTORY
3
HISTORY
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
Version 1.44 2020-02-09
|
||||
Version 1.44 2020-02-12
|
||||
* add test file src/tests/test_pthread_lock.c
|
||||
* add uniq_skiplist.[hc]
|
||||
* add function split_string_ex
|
||||
|
|
@ -7,6 +7,7 @@ Version 1.44 2020-02-09
|
|||
* struct fast_task_info add field: nio_stage
|
||||
* add function fc_memrchr
|
||||
* add function is_network_error
|
||||
* add function fast_mpool_log_stats
|
||||
|
||||
Version 1.43 2019-12-25
|
||||
* replace function call system to getExecResult,
|
||||
|
|
|
|||
|
|
@ -200,7 +200,8 @@ void fast_mpool_reset(struct fast_mpool_man *mpool)
|
|||
}
|
||||
}
|
||||
|
||||
void fast_mpool_stats(struct fast_mpool_man *mpool, struct fast_mpool_stats *stats)
|
||||
void fast_mpool_stats(struct fast_mpool_man *mpool,
|
||||
struct fast_mpool_stats *stats)
|
||||
{
|
||||
struct fast_mpool_malloc *pMallocNode;
|
||||
|
||||
|
|
@ -213,7 +214,8 @@ void fast_mpool_stats(struct fast_mpool_man *mpool, struct fast_mpool_stats *sta
|
|||
while (pMallocNode != NULL)
|
||||
{
|
||||
stats->total_bytes += pMallocNode->alloc_size;
|
||||
stats->free_bytes += (int)(pMallocNode->end_ptr - pMallocNode->free_ptr);
|
||||
stats->free_bytes += (int)(pMallocNode->end_ptr -
|
||||
pMallocNode->free_ptr);
|
||||
stats->total_trunk_count++;
|
||||
|
||||
pMallocNode = pMallocNode->malloc_next;
|
||||
|
|
@ -227,3 +229,15 @@ void fast_mpool_stats(struct fast_mpool_man *mpool, struct fast_mpool_stats *sta
|
|||
}
|
||||
}
|
||||
|
||||
void fast_mpool_log_stats(struct fast_mpool_man *mpool)
|
||||
{
|
||||
struct fast_mpool_stats stats;
|
||||
|
||||
fast_mpool_stats(mpool, &stats);
|
||||
logInfo("alloc_size_once: %d, discard_size: %d, "
|
||||
"bytes: {total: %"PRId64", free: %"PRId64"}, "
|
||||
"trunk_count: {total: %d, free: %d}",
|
||||
mpool->alloc_size_once, mpool->discard_size,
|
||||
stats.total_bytes, stats.free_bytes,
|
||||
stats.total_trunk_count, stats.free_trunk_count);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,8 +130,18 @@ get stats
|
|||
parameters:
|
||||
mpool: the mpool pointer
|
||||
stats: return the stats
|
||||
return none
|
||||
*/
|
||||
void fast_mpool_stats(struct fast_mpool_man *mpool, struct fast_mpool_stats *stats);
|
||||
void fast_mpool_stats(struct fast_mpool_man *mpool,
|
||||
struct fast_mpool_stats *stats);
|
||||
|
||||
/**
|
||||
log stats info
|
||||
parameters:
|
||||
mpool: the mpool pointer
|
||||
return none
|
||||
*/
|
||||
void fast_mpool_log_stats(struct fast_mpool_man *mpool);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ static UniqSkiplist *sl = NULL;
|
|||
static UniqSkiplistIterator iterator;
|
||||
static int instance_count = 0;
|
||||
|
||||
static void free_test_func(void *ptr)
|
||||
static void free_test_func(void *ptr, const int delay_seconds)
|
||||
{
|
||||
instance_count--;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ int uniq_skiplist_init_ex(UniqSkiplistFactory *factory,
|
|||
uniq_skiplist_free_func free_func, const int alloc_skiplist_once,
|
||||
const int min_alloc_elements_once, const int delay_free_seconds)
|
||||
{
|
||||
char name[64];
|
||||
int bytes;
|
||||
int element_size;
|
||||
int i;
|
||||
|
|
@ -91,10 +92,11 @@ int uniq_skiplist_init_ex(UniqSkiplistFactory *factory,
|
|||
}
|
||||
|
||||
for (i=max_level_count-1; i>=0; i--) {
|
||||
sprintf(name, "sl-level%02d", i);
|
||||
element_size = sizeof(UniqSkiplistNode) +
|
||||
sizeof(UniqSkiplistNode *) * (i + 1);
|
||||
if ((result=fast_mblock_init_ex(factory->node_allocators + i,
|
||||
element_size, alloc_elements_once, NULL, NULL, false)) != 0)
|
||||
if ((result=fast_mblock_init_ex1(factory->node_allocators + i,
|
||||
name, element_size, alloc_elements_once, NULL, NULL, false)) != 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
|
@ -103,10 +105,10 @@ int uniq_skiplist_init_ex(UniqSkiplistFactory *factory,
|
|||
}
|
||||
}
|
||||
|
||||
if ((result=fast_mblock_init_ex(&factory->skiplist_allocator,
|
||||
sizeof(UniqSkiplist), alloc_skiplist_once > 0 ?
|
||||
alloc_skiplist_once : 16 * 1024,
|
||||
NULL, NULL, false)) != 0)
|
||||
if ((result=fast_mblock_init_ex1(&factory->skiplist_allocator,
|
||||
"skiplist", sizeof(UniqSkiplist),
|
||||
alloc_skiplist_once > 0 ? alloc_skiplist_once :
|
||||
16 * 1024, NULL, NULL, false)) != 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue