mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-04-14 22:51:50 +03:00
Edata cache: atomic fetch-add -> load-store.
The modifications to count are protected by a mutex; there's no need to use the more costly version.
This commit is contained in:
parent
99b1291d17
commit
0dcd576600
1 changed files with 4 additions and 2 deletions
|
|
@ -27,7 +27,8 @@ edata_cache_get(tsdn_t *tsdn, edata_cache_t *edata_cache) {
|
|||
return base_alloc_edata(tsdn, edata_cache->base);
|
||||
}
|
||||
edata_avail_remove(&edata_cache->avail, edata);
|
||||
atomic_fetch_sub_zu(&edata_cache->count, 1, ATOMIC_RELAXED);
|
||||
size_t count = atomic_load_zu(&edata_cache->count, ATOMIC_RELAXED);
|
||||
atomic_store_zu(&edata_cache->count, count - 1, ATOMIC_RELAXED);
|
||||
malloc_mutex_unlock(tsdn, &edata_cache->mtx);
|
||||
return edata;
|
||||
}
|
||||
|
|
@ -36,7 +37,8 @@ void
|
|||
edata_cache_put(tsdn_t *tsdn, edata_cache_t *edata_cache, edata_t *edata) {
|
||||
malloc_mutex_lock(tsdn, &edata_cache->mtx);
|
||||
edata_avail_insert(&edata_cache->avail, edata);
|
||||
atomic_fetch_add_zu(&edata_cache->count, 1, ATOMIC_RELAXED);
|
||||
size_t count = atomic_load_zu(&edata_cache->count, ATOMIC_RELAXED);
|
||||
atomic_store_zu(&edata_cache->count, count + 1, ATOMIC_RELAXED);
|
||||
malloc_mutex_unlock(tsdn, &edata_cache->mtx);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue