diff options
author | Nick Mathewson <nickm@torproject.org> | 2008-02-08 21:13:08 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2008-02-08 21:13:08 +0000 |
commit | 809227a121136d4c48ea09ad96aef5ecb9eb15eb (patch) | |
tree | 9268a8c4b54c49c1c376a92dbfc9544503761616 /src/common/mempool.h | |
parent | 5d250d3e1b8eab09b438516f790082204441b6e3 (diff) | |
download | tor-809227a121136d4c48ea09ad96aef5ecb9eb15eb.tar.gz tor-809227a121136d4c48ea09ad96aef5ecb9eb15eb.zip |
r14061@tombo: nickm | 2008-02-08 14:30:42 -0500
Add a couple of (currently disabled) strategies for trying to avoid using too much ram in memory pools: prefer putting new cells in almost-full chunks, and be willing to free the last empty chunk if we have not needed it for a while. Also add better output to mp_pool_log_status to track how many mallocs a given memory pool strategy is saving us, so we can tune the mempool parameters.
svn:r13428
Diffstat (limited to 'src/common/mempool.h')
-rw-r--r-- | src/common/mempool.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/common/mempool.h b/src/common/mempool.h index 577f5cc653..2c5c925f77 100644 --- a/src/common/mempool.h +++ b/src/common/mempool.h @@ -18,11 +18,13 @@ typedef struct mp_pool_t mp_pool_t; void *mp_pool_get(mp_pool_t *pool); void mp_pool_release(void *item); mp_pool_t *mp_pool_new(size_t item_size, size_t chunk_capacity); -void mp_pool_clean(mp_pool_t *pool, int n); +void mp_pool_clean(mp_pool_t *pool, int n_to_keep, int keep_recently_used); void mp_pool_destroy(mp_pool_t *pool); void mp_pool_assert_ok(mp_pool_t *pool); void mp_pool_log_status(mp_pool_t *pool, int severity); +#define MEMPOOL_STATS + #ifdef MEMPOOL_PRIVATE /* These declarations are only used by mempool.c and test.c */ @@ -47,6 +49,14 @@ struct mp_pool_t { /** Size to allocate for each item, including overhead and alignment * padding. */ size_t item_alloc_size; +#ifdef MEMPOOL_STATS + /** Total number of items allocated ever */ + uint64_t total_items_allocated; + /** Total number of chunks allocated ever */ + uint64_t total_chunks_allocated; + /** Total number of chunks freed ever */ + uint64_t total_chunks_freed; +#endif }; #endif |