mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-25 06:13:13 +00:00
Remove prof lookahead surplus API
This commit is contained in:
committed by
Guangli Dai
parent
44c2ffaff6
commit
136d342aa0
@@ -114,50 +114,17 @@ uint64_t tsd_prof_sample_event_wait_get(tsd_t *tsd);
|
|||||||
*
|
*
|
||||||
* Currently only the profiling sampling event needs the lookahead
|
* Currently only the profiling sampling event needs the lookahead
|
||||||
* functionality, so we don't yet define general purpose lookahead functions.
|
* functionality, so we don't yet define general purpose lookahead functions.
|
||||||
*
|
|
||||||
* Surplus is a terminology referring to the amount of bytes beyond what's
|
|
||||||
* needed for triggering an event, which can be a useful quantity to have in
|
|
||||||
* general when lookahead is being called.
|
|
||||||
*
|
|
||||||
* This function returns true if allocation of usize would go above the next
|
|
||||||
* trigger for prof event, and false otherwise.
|
|
||||||
* If function returns true surplus will contain number of bytes beyond that
|
|
||||||
* trigger.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
JEMALLOC_ALWAYS_INLINE bool
|
JEMALLOC_ALWAYS_INLINE bool
|
||||||
te_prof_sample_event_lookahead_surplus(
|
te_prof_sample_event_lookahead(tsd_t *tsd, size_t usize) {
|
||||||
tsd_t *tsd, size_t usize, size_t *surplus) {
|
|
||||||
if (surplus != NULL) {
|
|
||||||
/*
|
|
||||||
* This is a dead store: the surplus will be overwritten before
|
|
||||||
* any read. The initialization suppresses compiler warnings.
|
|
||||||
* Meanwhile, using SIZE_MAX to initialize is good for
|
|
||||||
* debugging purpose, because a valid surplus value is strictly
|
|
||||||
* less than usize, which is at most SIZE_MAX.
|
|
||||||
*/
|
|
||||||
*surplus = SIZE_MAX;
|
|
||||||
}
|
|
||||||
if (unlikely(!tsd_nominal(tsd) || tsd_reentrancy_level_get(tsd) > 0)) {
|
if (unlikely(!tsd_nominal(tsd) || tsd_reentrancy_level_get(tsd) > 0)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/* The subtraction is intentionally susceptible to underflow. */
|
/* The subtraction is intentionally susceptible to underflow. */
|
||||||
uint64_t accumbytes = tsd_thread_allocated_get(tsd) + usize
|
uint64_t accumbytes = tsd_thread_allocated_get(tsd) + usize
|
||||||
- tsd_thread_allocated_last_event_get(tsd);
|
- tsd_thread_allocated_last_event_get(tsd);
|
||||||
uint64_t sample_wait = tsd_prof_sample_event_wait_get(tsd);
|
return accumbytes >= tsd_prof_sample_event_wait_get(tsd);
|
||||||
if (accumbytes < sample_wait) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
assert(accumbytes - sample_wait < (uint64_t)usize);
|
|
||||||
if (surplus != NULL) {
|
|
||||||
*surplus = (size_t)(accumbytes - sample_wait);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
JEMALLOC_ALWAYS_INLINE bool
|
|
||||||
te_prof_sample_event_lookahead(tsd_t *tsd, size_t usize) {
|
|
||||||
return te_prof_sample_event_lookahead_surplus(tsd, usize, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern te_base_cb_t prof_sample_te_handler;
|
extern te_base_cb_t prof_sample_te_handler;
|
||||||
|
|||||||
Reference in New Issue
Block a user