Move thread event wait time update to local

This commit is contained in:
Yinan Zhang 2020-03-24 08:31:34 -07:00
parent 733ae918f0
commit 6de77799de
2 changed files with 25 additions and 24 deletions

View File

@ -33,7 +33,6 @@ typedef struct te_ctx_s {
void te_assert_invariants_debug(tsd_t *tsd);
void te_event_trigger(tsd_t *tsd, te_ctx_t *ctx, bool delay_event);
void te_event_update(tsd_t *tsd, bool alloc_event);
void te_recompute_fast_threshold(tsd_t *tsd);
void tsd_te_init(tsd_t *tsd);
@ -251,27 +250,4 @@ thread_alloc_event(tsd_t *tsd, size_t usize) {
te_event_advance(tsd, usize, true);
}
#define E(event, condition, is_alloc) \
JEMALLOC_ALWAYS_INLINE void \
te_##event##_event_update(tsd_t *tsd, uint64_t event_wait) { \
te_assert_invariants(tsd); \
assert(condition); \
assert(tsd_nominal(tsd)); \
assert(tsd_reentrancy_level_get(tsd) == 0); \
assert(event_wait > 0U); \
if (TE_MIN_START_WAIT > 1U && \
unlikely(event_wait < TE_MIN_START_WAIT)) { \
event_wait = TE_MIN_START_WAIT; \
} \
if (TE_MAX_START_WAIT < UINT64_MAX && \
unlikely(event_wait > TE_MAX_START_WAIT)) { \
event_wait = TE_MAX_START_WAIT; \
} \
event##_event_wait_set(tsd, event_wait); \
te_event_update(tsd, is_alloc); \
}
ITERATE_OVER_ALL_EVENTS
#undef E
#endif /* JEMALLOC_INTERNAL_THREAD_EVENT_H */

View File

@ -4,6 +4,31 @@
#include "jemalloc/internal/thread_event.h"
static void te_event_update(tsd_t *tsd, bool alloc_event);
#define E(event, condition, is_alloc) \
static void \
te_##event##_event_update(tsd_t *tsd, uint64_t event_wait) { \
te_assert_invariants(tsd); \
assert(condition); \
assert(tsd_nominal(tsd)); \
assert(tsd_reentrancy_level_get(tsd) == 0); \
assert(event_wait > 0U); \
if (TE_MIN_START_WAIT > 1U && \
unlikely(event_wait < TE_MIN_START_WAIT)) { \
event_wait = TE_MIN_START_WAIT; \
} \
if (TE_MAX_START_WAIT < UINT64_MAX && \
unlikely(event_wait > TE_MAX_START_WAIT)) { \
event_wait = TE_MAX_START_WAIT; \
} \
event##_event_wait_set(tsd, event_wait); \
te_event_update(tsd, is_alloc); \
}
ITERATE_OVER_ALL_EVENTS
#undef E
/*
* Signatures for functions computing new event wait time. The functions
* should be defined by the modules owning each event. The signatures here are