Skip to content
Snippets Groups Projects
Commit 7135910e authored by Georgiy Lebedev's avatar Georgiy Lebedev Committed by Vladimir Davydov
Browse files

core: use `malloc` instead of `region` allocator in procedure name cache

The procedure name cache uses a region for hash table entry allocation, but
the cache is a thread local variable, while the `region` uses a `slab`
allocator the lifetime of which is bounded by `main`, while thread locals
are destroyed after `main`: use the `malloc` allocator instead.

Benchmark from #7207 shows that this change does not effect performance.

Closes #8777

NO_CHANGELOG=<leak does not affect users>
NO_DOC=bugfix
NO_TEST=<detected by ASAN>
parent d63a4bf2
No related branches found
No related tags found
No related merge requests found
......@@ -40,18 +40,17 @@ struct ProcNameCache final {
}
mh_i64ptr_t *proc_name_cache;
region proc_name_cache_entry_region;
private:
ProcNameCache() noexcept : proc_name_cache{mh_i64ptr_new()},
proc_name_cache_entry_region{}
ProcNameCache() noexcept : proc_name_cache{mh_i64ptr_new()}
{
region_create(&proc_name_cache_entry_region, &cord()->slabc);
}
~ProcNameCache()
{
region_destroy(&proc_name_cache_entry_region);
mh_int_t i;
mh_foreach(proc_name_cache, i)
free(mh_i64ptr_node(proc_name_cache, i)->val);
mh_i64ptr_delete(proc_name_cache);
}
};
......@@ -73,14 +72,8 @@ proc_name_cache_find(void *ip, uintptr_t *offs)
void
proc_name_cache_insert(void *ip, const char *name, uintptr_t offs)
{
region *proc_name_cache_entry_region =
&ProcNameCache::instance().proc_name_cache_entry_region;
size_t sz;
proc_name_cache_entry *entry =
region_alloc_object(proc_name_cache_entry_region,
typeof(*entry), &sz);
if (unlikely(entry == nullptr))
return;
auto entry = static_cast<proc_name_cache_entry *>(xmalloc(
sizeof(proc_name_cache_entry)));
entry->offset = offs;
strlcpy(entry->name, name, PROC_NAME_MAX);
mh_i64ptr_node_t node = {(uintptr_t)ip, entry};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment