This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PING][RFC 3/*] Remove THREAD_STATS
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: libc-alpha at sourceware dot org
- Date: Mon, 30 Dec 2013 16:20:49 +0100
- Subject: [PING][RFC 3/*] Remove THREAD_STATS
- Authentication-results: sourceware.org; auth=none
- References: <20131211102701 dot GA25483 at domone dot podge> <20131211121905 dot GA26961 at domone dot podge>
On Wed, Dec 11, 2013 at 01:19:05PM +0100, OndÅej BÃlka wrote:
> Another macro in malloc is THREAD_STATS to print statistic about locking
> which duplicates malloc probes.
>
> As this looks undocumented could it be removed?
>
Could somebody comment these?
>
> * malloc/arena.c (grow_heap, get_free_list, reused_arena,
> arena_get2): Remove THREAD_STATS conditionals.
> * malloc/malloc.c (__malloc_assert, __libc_realloc, _int_free,
> __malloc_stats, int): Likewise.
>
> ---
> malloc/arena.c | 20 --------------------
> malloc/malloc.c | 39 ---------------------------------------
> 2 files changed, 59 deletions(-)
>
> diff --git a/malloc/arena.c b/malloc/arena.c
> index 9d49f93..1d4677f 100644
> --- a/malloc/arena.c
> +++ b/malloc/arena.c
> @@ -37,14 +37,6 @@
> mmap threshold, so that requests with a size just below that
> threshold can be fulfilled without creating too many heaps. */
>
> -
> -#ifndef THREAD_STATS
> -#define THREAD_STATS 0
> -#endif
> -
> -/* If THREAD_STATS is non-zero, some statistics on mutex locking are
> - computed. */
> -
> /***************************************************************************/
>
> #define top(ar_ptr) ((ar_ptr)->top)
> @@ -78,13 +70,6 @@ static mutex_t list_lock = MUTEX_INITIALIZER;
> static size_t narenas = 1;
> static mstate free_list;
>
> -#if THREAD_STATS
> -static int stat_n_heaps;
> -#define THREAD_STAT(x) x
> -#else
> -#define THREAD_STAT(x) do ; while(0)
> -#endif
> -
> /* Mapped memory in non-main arenas (reliable only for NO_THREADS). */
> static unsigned long arena_mem;
>
> @@ -561,7 +546,6 @@ new_heap(size_t size, size_t top_pad)
> h = (heap_info *)p2;
> h->size = size;
> h->mprotect_size = size;
> - THREAD_STAT(stat_n_heaps++);
> LIBC_PROBE (memory_heap_new, 2, h, h->size);
> return h;
> }
> @@ -735,8 +719,6 @@ _int_new_arena(size_t size)
>
> (void)mutex_unlock(&list_lock);
>
> - THREAD_STAT(++(a->stat_lock_loop));
> -
> return a;
> }
>
> @@ -758,7 +740,6 @@ get_free_list (void)
> LIBC_PROBE (memory_arena_reuse_free_list, 1, result);
> (void)mutex_lock(&result->mutex);
> tsd_setspecific(arena_key, (void *)result);
> - THREAD_STAT(++(result->stat_lock_loop));
> }
> }
>
> @@ -798,7 +779,6 @@ reused_arena (mstate avoid_arena)
> out:
> LIBC_PROBE (memory_arena_reuse, 2, result, avoid_arena);
> tsd_setspecific(arena_key, (void *)result);
> - THREAD_STAT(++(result->stat_lock_loop));
> next_to_use = result->next;
>
> return result;
> diff --git a/malloc/malloc.c b/malloc/malloc.c
> index b1668b5..db1c034 100644
> --- a/malloc/malloc.c
> +++ b/malloc/malloc.c
> @@ -1671,11 +1671,6 @@ struct malloc_state {
> /* Flags (formerly in max_fast). */
> int flags;
>
> -#if THREAD_STATS
> - /* Statistics for locking. Only used if THREAD_STATS is defined. */
> - long stat_lock_direct, stat_lock_loop, stat_lock_wait;
> -#endif
> -
> /* Fastbins */
> mfastbinptr fastbinsY[NFASTBINS];
>
> @@ -2949,16 +2944,7 @@ __libc_realloc(void* oldmem, size_t bytes)
> }
>
> ar_ptr = arena_for_chunk(oldp);
> -#if THREAD_STATS
> - if(!mutex_trylock(&ar_ptr->mutex))
> - ++(ar_ptr->stat_lock_direct);
> - else {
> - (void)mutex_lock(&ar_ptr->mutex);
> - ++(ar_ptr->stat_lock_wait);
> - }
> -#else
> (void)mutex_lock(&ar_ptr->mutex);
> -#endif
>
>
> newp = _int_realloc(ar_ptr, oldp, oldsize, nb);
> @@ -3814,16 +3800,7 @@ _int_free(mstate av, mchunkptr p, int have_lock)
>
> else if (!chunk_is_mmapped(p)) {
> if (! have_lock) {
> -#if THREAD_STATS
> - if(!mutex_trylock(&av->mutex))
> - ++(av->stat_lock_direct);
> - else {
> - (void)mutex_lock(&av->mutex);
> - ++(av->stat_lock_wait);
> - }
> -#else
> (void)mutex_lock(&av->mutex);
> -#endif
> locked = 1;
> }
>
> @@ -4538,9 +4515,6 @@ __malloc_stats (void)
> int i;
> mstate ar_ptr;
> unsigned int in_use_b = mp_.mmapped_mem, system_b = in_use_b;
> -#if THREAD_STATS
> - long stat_lock_direct = 0, stat_lock_loop = 0, stat_lock_wait = 0;
> -#endif
>
> if(__malloc_initialized < 0)
> ptmalloc_init ();
> @@ -4562,11 +4536,6 @@ __malloc_stats (void)
> #endif
> system_b += mi.arena;
> in_use_b += mi.uordblks;
> -#if THREAD_STATS
> - stat_lock_direct += ar_ptr->stat_lock_direct;
> - stat_lock_loop += ar_ptr->stat_lock_loop;
> - stat_lock_wait += ar_ptr->stat_lock_wait;
> -#endif
> (void)mutex_unlock(&ar_ptr->mutex);
> ar_ptr = ar_ptr->next;
> if(ar_ptr == &main_arena) break;
> @@ -4577,14 +4546,6 @@ __malloc_stats (void)
> fprintf(stderr, "max mmap regions = %10u\n", (unsigned int)mp_.max_n_mmaps);
> fprintf(stderr, "max mmap bytes = %10lu\n",
> (unsigned long)mp_.max_mmapped_mem);
> -#if THREAD_STATS
> - fprintf(stderr, "heaps created = %10d\n", stat_n_heaps);
> - fprintf(stderr, "locked directly = %10ld\n", stat_lock_direct);
> - fprintf(stderr, "locked in loop = %10ld\n", stat_lock_loop);
> - fprintf(stderr, "locked waiting = %10ld\n", stat_lock_wait);
> - fprintf(stderr, "locked total = %10ld\n",
> - stat_lock_direct + stat_lock_loop + stat_lock_wait);
> -#endif
> ((_IO_FILE *) stderr)->_flags2 |= old_flags2;
> _IO_funlockfile (stderr);
> }
> --
> 1.8.4.rc3
--
Smell from unhygienic janitorial staff wrecked the tape heads