Issue #1307 - Part 5: Remove allocation tracing.

Pointless for debugging and a major performance sink.
This commit is contained in:
wolfbeast 2019-11-30 17:32:36 +01:00 committed by Roy Tam
commit 8cd5f01ad5
2 changed files with 1 additions and 99 deletions

View file

@ -167,11 +167,6 @@
*/
# define MALLOC_DEBUG
/* Allocation tracing. */
# ifndef MOZ_MEMORY_WINDOWS
# define MALLOC_UTRACE
# endif
/* Support optional abort() on OOM. */
# define MALLOC_XMALLOC
@ -1142,9 +1137,6 @@ static size_t opt_quantum_2pow = QUANTUM_2POW_MIN;
static size_t opt_small_max_2pow = SMALL_MAX_2POW_DEFAULT;
static size_t opt_chunk_2pow = CHUNK_2POW_DEFAULT;
#endif
#ifdef MALLOC_UTRACE
static bool opt_utrace = false;
#endif
#ifdef MALLOC_SYSV
static bool opt_sysv = false;
#endif
@ -1153,25 +1145,6 @@ static bool opt_xmalloc = false;
#endif
static int opt_narenas_lshift = 0;
#ifdef MALLOC_UTRACE
typedef struct {
void *p;
size_t s;
void *r;
} malloc_utrace_t;
#define UTRACE(a, b, c) \
if (opt_utrace) { \
malloc_utrace_t ut; \
ut.p = (a); \
ut.s = (b); \
ut.r = (c); \
utrace(&ut, sizeof(ut)); \
}
#else
#define UTRACE(a, b, c)
#endif
/******************************************************************************/
/*
* Begin function prototypes for non-inline static functions.
@ -1600,52 +1573,6 @@ pow2_ceil(size_t x)
return (x);
}
#ifdef MALLOC_UTRACE
static int
utrace(const void *addr, size_t len)
{
malloc_utrace_t *ut = (malloc_utrace_t *)addr;
char buf_a[UMAX2S_BUFSIZE];
char buf_b[UMAX2S_BUFSIZE];
assert(len == sizeof(malloc_utrace_t));
if (ut->p == NULL && ut->s == 0 && ut->r == NULL) {
_malloc_message(
umax2s(getpid(), 10, buf_a),
" x USER malloc_init()\n", "", "");
} else if (ut->p == NULL && ut->r != NULL) {
_malloc_message(
umax2s(getpid(), 10, buf_a),
" x USER 0x",
umax2s((uintptr_t)ut->r, 16, buf_b),
" = malloc(");
_malloc_message(
umax2s(ut->s, 10, buf_a),
")\n", "", "");
} else if (ut->p != NULL && ut->r != NULL) {
_malloc_message(
umax2s(getpid(), 10, buf_a),
" x USER 0x",
umax2s((uintptr_t)ut->r, 16, buf_b),
" = realloc(0x");
_malloc_message(
umax2s((uintptr_t)ut->p, 16, buf_a),
", ",
umax2s(ut->s, 10, buf_b),
")\n");
} else {
_malloc_message(
umax2s(getpid(), 10, buf_a),
" x USER free(0x",
umax2s((uintptr_t)ut->p, 16, buf_b),
")\n");
}
return (0);
}
#endif
static inline const char *
_getprogname(void)
{
@ -4974,9 +4901,6 @@ malloc_print_stats(void)
_malloc_message(opt_junk ? "J" : "j", "", "", "");
#endif
_malloc_message("P", "", "", "");
#ifdef MALLOC_UTRACE
_malloc_message(opt_utrace ? "U" : "u", "", "", "");
#endif
#ifdef MALLOC_SYSV
_malloc_message(opt_sysv ? "V" : "v", "", "", "");
#endif
@ -5328,14 +5252,6 @@ MALLOC_OUT:
opt_small_max_2pow++;
break;
#endif
#ifdef MALLOC_UTRACE
case 'u':
opt_utrace = false;
break;
case 'U':
opt_utrace = true;
break;
#endif
#ifdef MALLOC_SYSV
case 'v':
opt_sysv = false;
@ -5430,8 +5346,6 @@ MALLOC_OUT:
assert((1 << (ffs(chunksize / pagesize) - 1)) == (chunksize/pagesize));
#endif
UTRACE(0, 0, 0);
/* Various sanity checks that regard configuration. */
assert(quantum >= sizeof(void *));
assert(quantum <= pagesize);
@ -5705,7 +5619,6 @@ RETURN:
errno = ENOMEM;
}
UTRACE(0, size, ret);
return (ret);
}
@ -5783,7 +5696,6 @@ RETURN:
abort();
}
#endif
UTRACE(0, size, ret);
return (ret);
}
@ -5897,7 +5809,6 @@ RETURN:
errno = ENOMEM;
}
UTRACE(0, num_size, ret);
return (ret);
}
@ -5961,7 +5872,6 @@ realloc_impl(void *ptr, size_t size)
#ifdef MALLOC_SYSV
RETURN:
#endif
UTRACE(ptr, size, ret);
return (ret);
}
@ -5972,8 +5882,6 @@ free_impl(void *ptr)
DARWIN_ONLY((szone->free)(szone, ptr); return);
UTRACE(ptr, 0, 0);
/*
* A version of idalloc that checks for NULL pointer but only for
* huge allocations assuming that CHUNK_ADDR2OFFSET(NULL) == 0.
@ -6066,11 +5974,6 @@ jemalloc_stats_impl(jemalloc_stats_t *stats)
stats->opt_poison =
#ifdef MALLOC_FILL
opt_poison ? true :
#endif
false;
stats->opt_utrace =
#ifdef MALLOC_UTRACE
opt_utrace ? true :
#endif
false;
stats->opt_sysv =

View file

@ -2,7 +2,7 @@
/* vim:set softtabstop=8 shiftwidth=8: */
/*-
* Copyright (C) 2006-2008 Jason Evans <jasone@FreeBSD.org>.
* Copyright (C) 2015-2018 Mark Straver <moonchild@palemoon.org>
* Copyright (C) 2015-2019 Mark Straver <moonchild@palemoon.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -57,7 +57,6 @@ typedef struct {
jemalloc_bool opt_abort; /* abort(3) on error? */
jemalloc_bool opt_junk; /* Fill allocated memory with 0xe4? */
jemalloc_bool opt_poison; /* Fill free memory with 0xe5? */
jemalloc_bool opt_utrace; /* Trace all allocation events? */
jemalloc_bool opt_sysv; /* SysV semantics? */
jemalloc_bool opt_xmalloc; /* abort(3) on OOM? */
jemalloc_bool opt_zero; /* Fill allocated memory with 0x0? */