From: Peter Meerwald <p.meerwald@xxxxxxxxxxxxxxxxxx> to turn off keeping statistics, values reported will be zero Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net> --- configure.ac | 13 ++++++++++++- src/pulsecore/memblock.c | 15 +++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 26ebd8c..5ecee1f 100644 --- a/configure.ac +++ b/configure.ac @@ -369,7 +369,6 @@ AC_SUBST(NEON_CFLAGS) AM_CONDITIONAL([HAVE_NEON], [test "x$HAVE_NEON" = x1]) AS_IF([test "x$HAVE_NEON" = "x1"], AC_DEFINE([HAVE_NEON], 1, [Have NEON support?])) - #### libtool stuff #### LT_PREREQ(2.4) @@ -1362,6 +1361,16 @@ AS_IF([test "x$enable_adrian_aec" != "xno"], [HAVE_ADRIAN_EC=1]) AM_CONDITIONAL([HAVE_ADRIAN_EC], [test "x$HAVE_ADRIAN_EC" = "x1"]) +#### Statistics ##### + +AC_ARG_ENABLE([statistics], + AS_HELP_STRING([--disable-statistics], [Disable performance statistics])) +AS_IF([test "x$enable_statistics" != "xno"], + [HAVE_STATISTICS=1], [HAVE_STATISTICS=0]) +#//AM_CONDITIONAL([HAVE_STATISTICS], [test "x$HAVE_STATISTICS" = "x1"]) + +AC_SUBST(HAVE_STATISTICS) +AM_CONDITIONAL([HAVE_STATISTICS], [test "x$HAVE_STATISTICS" = "x1"]) ################################### @@ -1525,6 +1534,7 @@ AS_IF([test "x$HAVE_SIMPLEDB" = "x1"], ENABLE_SIMPLEDB=yes, ENABLE_SIMPLEDB=no) AS_IF([test "x$HAVE_ESOUND" = "x1"], ENABLE_ESOUND=yes, ENABLE_ESOUND=no) AS_IF([test "x$HAVE_ESOUND" = "x1" -a "x$USE_PER_USER_ESOUND_SOCKET" = "x1"], ENABLE_PER_USER_ESOUND_SOCKET=yes, ENABLE_PER_USER_ESOUND_SOCKET=no) AS_IF([test "x$HAVE_GCOV" = "x1"], ENABLE_GCOV=yes, ENABLE_GCOV=no) +AS_IF([test "x$HAVE_STATISTICS" = "x1"], ENABLE_STATISTICS=yes, ENABLE_STATISTICS=no) AS_IF([test "x$HAVE_LIBCHECK" = "x1"], ENABLE_TESTS=yes, ENABLE_TESTS=no) AS_IF([test "x$enable_legacy_database_entry_format" != "xno"], ENABLE_LEGACY_DATABASE_ENTRY_FORMAT=yes, ENABLE_LEGACY_DATABASE_ENTRY_FORMAT=no) @@ -1581,6 +1591,7 @@ echo " Enable WebRTC echo canceller: ${ENABLE_WEBRTC} Enable gcov coverage: ${ENABLE_GCOV} Enable unit tests: ${ENABLE_TESTS} + Enable statistics: ${ENABLE_STATISTICS} Database tdb: ${ENABLE_TDB} gdbm: ${ENABLE_GDBM} diff --git a/src/pulsecore/memblock.c b/src/pulsecore/memblock.c index f8b008f..180f446 100644 --- a/src/pulsecore/memblock.c +++ b/src/pulsecore/memblock.c @@ -167,6 +167,7 @@ static void segment_detach(pa_memimport_segment *seg); PA_STATIC_FLIST_DECLARE(unused_memblocks, 0, pa_xfree); /* No lock necessary */ +#ifdef HAVE_STATISTICS static void stat_add(pa_memblock*b) { pa_assert(b); pa_assert(b->pool); @@ -207,6 +208,10 @@ static void stat_remove(pa_memblock *b) { pa_atomic_dec(&b->pool->stat.n_allocated_by_type[b->type]); } +#else +#define stat_add(b) +#define stat_remove(b) +#endif static pa_memblock *memblock_new_appended(pa_mempool *p, size_t length); @@ -685,8 +690,10 @@ static void memblock_make_local(pa_memblock *b) { b->read_only = false; finish: +#ifdef HAVE_STATISTICS pa_atomic_inc(&b->pool->stat.n_allocated_by_type[b->type]); pa_atomic_inc(&b->pool->stat.n_accumulated_by_type[b->type]); +#endif memblock_wait(b); } @@ -724,10 +731,12 @@ static void memblock_replace_import(pa_memblock *b) { pa_assert(b); pa_assert(b->type == PA_MEMBLOCK_IMPORTED); +#ifdef HAVE_STATISTICS pa_assert(pa_atomic_load(&b->pool->stat.n_imported) > 0); pa_assert(pa_atomic_load(&b->pool->stat.imported_size) >= (int) b->length); pa_atomic_dec(&b->pool->stat.n_imported); pa_atomic_sub(&b->pool->stat.imported_size, (int) b->length); +#endif pa_assert_se(segment = b->per_type.imported.segment); pa_assert_se(import = segment->import); @@ -805,6 +814,7 @@ void pa_mempool_free(pa_mempool *p) { pa_flist_free(p->free_slots, NULL); +#ifdef HAVE_STATISTICS if (pa_atomic_load(&p->stat.n_allocated) > 0) { /* Ouch, somebody is retaining a memory block reference! */ @@ -848,6 +858,7 @@ void pa_mempool_free(pa_mempool *p) { /* PA_DEBUG_TRAP; */ } +#endif pa_shm_free(&p->memory); @@ -1148,11 +1159,13 @@ int pa_memexport_process_release(pa_memexport *e, uint32_t id) { /* pa_log("Processing release for %u", id); */ +#ifdef HAVE_STATISTICS pa_assert(pa_atomic_load(&e->pool->stat.n_exported) > 0); pa_assert(pa_atomic_load(&e->pool->stat.exported_size) >= (int) b->length); pa_atomic_dec(&e->pool->stat.n_exported); pa_atomic_sub(&e->pool->stat.exported_size, (int) b->length); +#endif pa_memblock_unref(b); @@ -1266,8 +1279,10 @@ int pa_memexport_put(pa_memexport *e, pa_memblock *b, uint32_t *block_id, uint32 pa_memblock_release(b); +#ifdef HAVE_STATISTICS pa_atomic_inc(&e->pool->stat.n_exported); pa_atomic_add(&e->pool->stat.exported_size, (int) b->length); +#endif return 0; } -- 1.9.1