mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-08-24 16:13:38 +03:00
Add thread.peak.[read|reset] mallctls.
These can be used to track net allocator activity on a per-thread basis.
This commit is contained in:
parent
fe7108305a
commit
d82a164d0d
13 changed files with 269 additions and 5 deletions
67
src/peak_event.c
Normal file
67
src/peak_event.c
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
#include "jemalloc/internal/jemalloc_preamble.h"
|
||||
#include "jemalloc/internal/jemalloc_internal_includes.h"
|
||||
|
||||
#include "jemalloc/internal/peak.h"
|
||||
#include "jemalloc/internal/peak_event.h"
|
||||
|
||||
/*
|
||||
* Update every 100k by default. We're not exposing this as a configuration
|
||||
* option for now; we don't want to bind ourselves too tightly to any particular
|
||||
* performance requirements for small values, or guarantee that we'll even be
|
||||
* able to provide fine-grained accuracy.
|
||||
*/
|
||||
#define PEAK_EVENT_WAIT (100 * 1024)
|
||||
|
||||
/* Update the peak with current tsd state. */
|
||||
void
|
||||
peak_event_update(tsd_t *tsd) {
|
||||
uint64_t alloc = tsd_thread_allocated_get(tsd);
|
||||
uint64_t dalloc = tsd_thread_deallocated_get(tsd);
|
||||
peak_t *peak = tsd_peakp_get(tsd);
|
||||
peak_update(peak, alloc, dalloc);
|
||||
}
|
||||
|
||||
/* Set current state to zero. */
|
||||
void
|
||||
peak_event_zero(tsd_t *tsd) {
|
||||
uint64_t alloc = tsd_thread_allocated_get(tsd);
|
||||
uint64_t dalloc = tsd_thread_deallocated_get(tsd);
|
||||
peak_t *peak = tsd_peakp_get(tsd);
|
||||
peak_set_zero(peak, alloc, dalloc);
|
||||
}
|
||||
|
||||
uint64_t
|
||||
peak_event_max(tsd_t *tsd) {
|
||||
peak_t *peak = tsd_peakp_get(tsd);
|
||||
return peak_max(peak);
|
||||
}
|
||||
|
||||
uint64_t
|
||||
peak_alloc_new_event_wait(tsd_t *tsd) {
|
||||
return PEAK_EVENT_WAIT;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
peak_alloc_postponed_event_wait(tsd_t *tsd) {
|
||||
return TE_MIN_START_WAIT;
|
||||
}
|
||||
|
||||
void
|
||||
peak_alloc_event_handler(tsd_t *tsd, uint64_t elapsed) {
|
||||
peak_event_update(tsd);
|
||||
}
|
||||
|
||||
uint64_t
|
||||
peak_dalloc_new_event_wait(tsd_t *tsd) {
|
||||
return PEAK_EVENT_WAIT;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
peak_dalloc_postponed_event_wait(tsd_t *tsd) {
|
||||
return TE_MIN_START_WAIT;
|
||||
}
|
||||
|
||||
void
|
||||
peak_dalloc_event_handler(tsd_t *tsd, uint64_t elapsed) {
|
||||
peak_event_update(tsd);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue