Revert "Jemalloc updated to 4.4.0."

This reverts commit 36c1acc222.
This commit is contained in:
antirez
2017-04-22 13:12:42 +02:00
parent 238cebdd5e
commit e3b8492e83
150 changed files with 6355 additions and 17238 deletions

View File

@ -11,8 +11,6 @@ mtx_init(mtx_t *mtx)
#ifdef _WIN32
if (!InitializeCriticalSectionAndSpinCount(&mtx->lock, _CRT_SPINCOUNT))
return (true);
#elif (defined(JEMALLOC_OS_UNFAIR_LOCK))
mtx->lock = OS_UNFAIR_LOCK_INIT;
#elif (defined(JEMALLOC_OSSPIN))
mtx->lock = 0;
#else
@ -35,7 +33,6 @@ mtx_fini(mtx_t *mtx)
{
#ifdef _WIN32
#elif (defined(JEMALLOC_OS_UNFAIR_LOCK))
#elif (defined(JEMALLOC_OSSPIN))
#else
pthread_mutex_destroy(&mtx->lock);
@ -48,8 +45,6 @@ mtx_lock(mtx_t *mtx)
#ifdef _WIN32
EnterCriticalSection(&mtx->lock);
#elif (defined(JEMALLOC_OS_UNFAIR_LOCK))
os_unfair_lock_lock(&mtx->lock);
#elif (defined(JEMALLOC_OSSPIN))
OSSpinLockLock(&mtx->lock);
#else
@ -63,8 +58,6 @@ mtx_unlock(mtx_t *mtx)
#ifdef _WIN32
LeaveCriticalSection(&mtx->lock);
#elif (defined(JEMALLOC_OS_UNFAIR_LOCK))
os_unfair_lock_unlock(&mtx->lock);
#elif (defined(JEMALLOC_OSSPIN))
OSSpinLockUnlock(&mtx->lock);
#else

View File

@ -60,30 +60,32 @@ p_test_fini(void)
malloc_printf("%s: %s\n", test_name, test_status_string(test_status));
}
static test_status_t
p_test_impl(bool do_malloc_init, test_t *t, va_list ap)
test_status_t
p_test(test_t *t, ...)
{
test_status_t ret;
va_list ap;
if (do_malloc_init) {
/*
* Make sure initialization occurs prior to running tests.
* Tests are special because they may use internal facilities
* prior to triggering initialization as a side effect of
* calling into the public API.
*/
if (nallocx(1, 0) == 0) {
malloc_printf("Initialization error");
return (test_status_fail);
}
/*
* Make sure initialization occurs prior to running tests. Tests are
* special because they may use internal facilities prior to triggering
* initialization as a side effect of calling into the public API. This
* is a final safety that works even if jemalloc_constructor() doesn't
* run, as for MSVC builds.
*/
if (nallocx(1, 0) == 0) {
malloc_printf("Initialization error");
return (test_status_fail);
}
ret = test_status_pass;
va_start(ap, t);
for (; t != NULL; t = va_arg(ap, test_t *)) {
t();
if (test_status > ret)
ret = test_status;
}
va_end(ap);
malloc_printf("--- %s: %u/%u, %s: %u/%u, %s: %u/%u ---\n",
test_status_string(test_status_pass),
@ -96,34 +98,6 @@ p_test_impl(bool do_malloc_init, test_t *t, va_list ap)
return (ret);
}
test_status_t
p_test(test_t *t, ...)
{
test_status_t ret;
va_list ap;
ret = test_status_pass;
va_start(ap, t);
ret = p_test_impl(true, t, ap);
va_end(ap);
return (ret);
}
test_status_t
p_test_no_malloc_init(test_t *t, ...)
{
test_status_t ret;
va_list ap;
ret = test_status_pass;
va_start(ap, t);
ret = p_test_impl(false, t, ap);
va_end(ap);
return (ret);
}
void
p_test_fail(const char *prefix, const char *message)
{

View File

@ -4,26 +4,50 @@ void
timer_start(timedelta_t *timer)
{
nstime_init(&timer->t0, 0);
nstime_update(&timer->t0);
#ifdef _WIN32
GetSystemTimeAsFileTime(&timer->ft0);
#elif JEMALLOC_CLOCK_GETTIME
if (sysconf(_SC_MONOTONIC_CLOCK) <= 0)
timer->clock_id = CLOCK_REALTIME;
else
timer->clock_id = CLOCK_MONOTONIC;
clock_gettime(timer->clock_id, &timer->ts0);
#else
gettimeofday(&timer->tv0, NULL);
#endif
}
void
timer_stop(timedelta_t *timer)
{
nstime_copy(&timer->t1, &timer->t0);
nstime_update(&timer->t1);
#ifdef _WIN32
GetSystemTimeAsFileTime(&timer->ft0);
#elif JEMALLOC_CLOCK_GETTIME
clock_gettime(timer->clock_id, &timer->ts1);
#else
gettimeofday(&timer->tv1, NULL);
#endif
}
uint64_t
timer_usec(const timedelta_t *timer)
{
nstime_t delta;
nstime_copy(&delta, &timer->t1);
nstime_subtract(&delta, &timer->t0);
return (nstime_ns(&delta) / 1000);
#ifdef _WIN32
uint64_t t0, t1;
t0 = (((uint64_t)timer->ft0.dwHighDateTime) << 32) |
timer->ft0.dwLowDateTime;
t1 = (((uint64_t)timer->ft1.dwHighDateTime) << 32) |
timer->ft1.dwLowDateTime;
return ((t1 - t0) / 10);
#elif JEMALLOC_CLOCK_GETTIME
return (((timer->ts1.tv_sec - timer->ts0.tv_sec) * 1000000) +
(timer->ts1.tv_nsec - timer->ts0.tv_nsec) / 1000);
#else
return (((timer->tv1.tv_sec - timer->tv0.tv_sec) * 1000000) +
timer->tv1.tv_usec - timer->tv0.tv_usec);
#endif
}
void
@ -32,8 +56,9 @@ timer_ratio(timedelta_t *a, timedelta_t *b, char *buf, size_t buflen)
uint64_t t0 = timer_usec(a);
uint64_t t1 = timer_usec(b);
uint64_t mult;
size_t i = 0;
size_t j, n;
unsigned i = 0;
unsigned j;
int n;
/* Whole. */
n = malloc_snprintf(&buf[i], buflen-i, "%"FMTu64, t0 / t1);