mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-06-20 10:55:39 +03:00
Use rtree-based chunk lookups rather than pointer bit twiddling.
Look up chunk metadata via the radix tree, rather than using CHUNK_ADDR2BASE(). Propagate pointer's containing extent. Minimize extent lookups by doing a single lookup (e.g. in free()) and propagating the pointer's extent into nearly all the functions that may need it.
This commit is contained in:
parent
2d2b4e98c9
commit
db72272bef
14 changed files with 548 additions and 504 deletions
32
src/prof.c
32
src/prof.c
|
|
@ -223,11 +223,11 @@ prof_alloc_rollback(tsd_t *tsd, prof_tctx_t *tctx, bool updated)
|
|||
}
|
||||
|
||||
void
|
||||
prof_malloc_sample_object(tsdn_t *tsdn, const void *ptr, size_t usize,
|
||||
prof_tctx_t *tctx)
|
||||
prof_malloc_sample_object(tsdn_t *tsdn, extent_t *extent, const void *ptr,
|
||||
size_t usize, prof_tctx_t *tctx)
|
||||
{
|
||||
|
||||
prof_tctx_set(tsdn, ptr, usize, tctx);
|
||||
prof_tctx_set(tsdn, extent, ptr, usize, tctx);
|
||||
|
||||
malloc_mutex_lock(tsdn, tctx->tdata->lock);
|
||||
tctx->cnts.curobjs++;
|
||||
|
|
@ -596,7 +596,7 @@ prof_gctx_try_destroy(tsd_t *tsd, prof_tdata_t *tdata_self, prof_gctx_t *gctx,
|
|||
prof_leave(tsd, tdata_self);
|
||||
/* Destroy gctx. */
|
||||
malloc_mutex_unlock(tsd_tsdn(tsd), gctx->lock);
|
||||
idalloctm(tsd_tsdn(tsd), gctx, NULL, true, true);
|
||||
idalloctm(tsd_tsdn(tsd), iealloc(gctx), gctx, NULL, true, true);
|
||||
} else {
|
||||
/*
|
||||
* Compensate for increment in prof_tctx_destroy() or
|
||||
|
|
@ -707,7 +707,7 @@ prof_tctx_destroy(tsd_t *tsd, prof_tctx_t *tctx)
|
|||
prof_tdata_destroy(tsd_tsdn(tsd), tdata, false);
|
||||
|
||||
if (destroy_tctx)
|
||||
idalloctm(tsd_tsdn(tsd), tctx, NULL, true, true);
|
||||
idalloctm(tsd_tsdn(tsd), iealloc(tctx), tctx, NULL, true, true);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
|
@ -736,7 +736,8 @@ prof_lookup_global(tsd_t *tsd, prof_bt_t *bt, prof_tdata_t *tdata,
|
|||
if (ckh_insert(tsd_tsdn(tsd), &bt2gctx, btkey.v, gctx.v)) {
|
||||
/* OOM. */
|
||||
prof_leave(tsd, tdata);
|
||||
idalloctm(tsd_tsdn(tsd), gctx.v, NULL, true, true);
|
||||
idalloctm(tsd_tsdn(tsd), iealloc(gctx.v), gctx.v, NULL,
|
||||
true, true);
|
||||
return (true);
|
||||
}
|
||||
new_gctx = true;
|
||||
|
|
@ -816,7 +817,8 @@ prof_lookup(tsd_t *tsd, prof_bt_t *bt)
|
|||
if (error) {
|
||||
if (new_gctx)
|
||||
prof_gctx_try_destroy(tsd, tdata, gctx, tdata);
|
||||
idalloctm(tsd_tsdn(tsd), ret.v, NULL, true, true);
|
||||
idalloctm(tsd_tsdn(tsd), iealloc(ret.v), ret.v, NULL,
|
||||
true, true);
|
||||
return (NULL);
|
||||
}
|
||||
malloc_mutex_lock(tsd_tsdn(tsd), gctx->lock);
|
||||
|
|
@ -1238,7 +1240,8 @@ prof_gctx_finish(tsd_t *tsd, prof_gctx_tree_t *gctxs)
|
|||
to_destroy);
|
||||
tctx_tree_remove(&gctx->tctxs,
|
||||
to_destroy);
|
||||
idalloctm(tsd_tsdn(tsd), to_destroy,
|
||||
idalloctm(tsd_tsdn(tsd),
|
||||
iealloc(to_destroy), to_destroy,
|
||||
NULL, true, true);
|
||||
} else
|
||||
next = NULL;
|
||||
|
|
@ -1815,7 +1818,7 @@ prof_tdata_init_impl(tsdn_t *tsdn, uint64_t thr_uid, uint64_t thr_discrim,
|
|||
|
||||
if (ckh_new(tsdn, &tdata->bt2tctx, PROF_CKH_MINITEMS,
|
||||
prof_bt_hash, prof_bt_keycomp)) {
|
||||
idalloctm(tsdn, tdata, NULL, true, true);
|
||||
idalloctm(tsdn, iealloc(tdata), tdata, NULL, true, true);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
|
@ -1878,10 +1881,12 @@ prof_tdata_destroy_locked(tsdn_t *tsdn, prof_tdata_t *tdata,
|
|||
|
||||
assert(prof_tdata_should_destroy_unlocked(tdata, even_if_attached));
|
||||
|
||||
if (tdata->thread_name != NULL)
|
||||
idalloctm(tsdn, tdata->thread_name, NULL, true, true);
|
||||
if (tdata->thread_name != NULL) {
|
||||
idalloctm(tsdn, iealloc(tdata->thread_name), tdata->thread_name,
|
||||
NULL, true, true);
|
||||
}
|
||||
ckh_delete(tsdn, &tdata->bt2tctx);
|
||||
idalloctm(tsdn, tdata, NULL, true, true);
|
||||
idalloctm(tsdn, iealloc(tdata), tdata, NULL, true, true);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -2075,7 +2080,8 @@ prof_thread_name_set(tsd_t *tsd, const char *thread_name)
|
|||
return (EAGAIN);
|
||||
|
||||
if (tdata->thread_name != NULL) {
|
||||
idalloctm(tsd_tsdn(tsd), tdata->thread_name, NULL, true, true);
|
||||
idalloctm(tsd_tsdn(tsd), iealloc(tdata->thread_name),
|
||||
tdata->thread_name, NULL, true, true);
|
||||
tdata->thread_name = NULL;
|
||||
}
|
||||
if (strlen(s) > 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue