mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-05-18 02:46:21 +03:00
Remove all vestiges of chunks.
Remove mallctls: - opt.lg_chunk - stats.cactive This resolves #464.
This commit is contained in:
parent
63b5657aa5
commit
9acd5cf178
23 changed files with 26 additions and 270 deletions
13
src/arena.c
13
src/arena.c
|
|
@ -229,13 +229,6 @@ static void
|
|||
arena_nactive_add(arena_t *arena, size_t add_pages)
|
||||
{
|
||||
|
||||
if (config_stats) {
|
||||
size_t cactive_add = CHUNK_CEILING((arena->nactive +
|
||||
add_pages) << LG_PAGE) - CHUNK_CEILING(arena->nactive <<
|
||||
LG_PAGE);
|
||||
if (cactive_add != 0)
|
||||
stats_cactive_add(cactive_add);
|
||||
}
|
||||
arena->nactive += add_pages;
|
||||
}
|
||||
|
||||
|
|
@ -244,12 +237,6 @@ arena_nactive_sub(arena_t *arena, size_t sub_pages)
|
|||
{
|
||||
|
||||
assert(arena->nactive >= sub_pages);
|
||||
if (config_stats) {
|
||||
size_t cactive_sub = CHUNK_CEILING(arena->nactive << LG_PAGE) -
|
||||
CHUNK_CEILING((arena->nactive - sub_pages) << LG_PAGE);
|
||||
if (cactive_sub != 0)
|
||||
stats_cactive_sub(cactive_sub);
|
||||
}
|
||||
arena->nactive -= sub_pages;
|
||||
}
|
||||
|
||||
|
|
|
|||
12
src/base.c
12
src/base.c
|
|
@ -41,7 +41,7 @@ static extent_t *
|
|||
base_extent_alloc(tsdn_t *tsdn, size_t minsize)
|
||||
{
|
||||
extent_t *extent;
|
||||
size_t csize, nsize;
|
||||
size_t esize, nsize;
|
||||
void *addr;
|
||||
|
||||
malloc_mutex_assert_owner(tsdn, &base_mtx);
|
||||
|
|
@ -49,7 +49,7 @@ base_extent_alloc(tsdn_t *tsdn, size_t minsize)
|
|||
extent = base_extent_try_alloc(tsdn);
|
||||
/* Allocate enough space to also carve an extent out if necessary. */
|
||||
nsize = (extent == NULL) ? CACHELINE_CEILING(sizeof(extent_t)) : 0;
|
||||
csize = CHUNK_CEILING(minsize + nsize);
|
||||
esize = PAGE_CEILING(minsize + nsize);
|
||||
/*
|
||||
* Directly call extent_alloc_mmap() because it's critical to allocate
|
||||
* untouched demand-zeroed virtual memory.
|
||||
|
|
@ -57,24 +57,24 @@ base_extent_alloc(tsdn_t *tsdn, size_t minsize)
|
|||
{
|
||||
bool zero = true;
|
||||
bool commit = true;
|
||||
addr = extent_alloc_mmap(NULL, csize, PAGE, &zero, &commit);
|
||||
addr = extent_alloc_mmap(NULL, esize, PAGE, &zero, &commit);
|
||||
}
|
||||
if (addr == NULL) {
|
||||
if (extent != NULL)
|
||||
base_extent_dalloc(tsdn, extent);
|
||||
return (NULL);
|
||||
}
|
||||
base_mapped += csize;
|
||||
base_mapped += esize;
|
||||
if (extent == NULL) {
|
||||
extent = (extent_t *)addr;
|
||||
addr = (void *)((uintptr_t)addr + nsize);
|
||||
csize -= nsize;
|
||||
esize -= nsize;
|
||||
if (config_stats) {
|
||||
base_allocated += nsize;
|
||||
base_resident += PAGE_CEILING(nsize);
|
||||
}
|
||||
}
|
||||
extent_init(extent, NULL, addr, csize, 0, true, true, true, false);
|
||||
extent_init(extent, NULL, addr, esize, 0, true, true, true, false);
|
||||
return (extent);
|
||||
}
|
||||
|
||||
|
|
|
|||
51
src/chunk.c
51
src/chunk.c
|
|
@ -1,51 +0,0 @@
|
|||
#define JEMALLOC_CHUNK_C_
|
||||
#include "jemalloc/internal/jemalloc_internal.h"
|
||||
|
||||
/******************************************************************************/
|
||||
/* Data. */
|
||||
|
||||
const char *opt_dss = DSS_DEFAULT;
|
||||
size_t opt_lg_chunk = 0;
|
||||
|
||||
/* Various chunk-related settings. */
|
||||
size_t chunksize;
|
||||
size_t chunksize_mask; /* (chunksize - 1). */
|
||||
size_t chunk_npages;
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
bool
|
||||
chunk_boot(void)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
SYSTEM_INFO info;
|
||||
GetSystemInfo(&info);
|
||||
|
||||
/*
|
||||
* Verify actual page size is equal to or an integral multiple of
|
||||
* configured page size.
|
||||
*/
|
||||
if (info.dwPageSize & ((1U << LG_PAGE) - 1))
|
||||
return (true);
|
||||
|
||||
/*
|
||||
* Configure chunksize (if not set) to match granularity (usually 64K),
|
||||
* so pages_map will always take fast path.
|
||||
*/
|
||||
if (!opt_lg_chunk) {
|
||||
opt_lg_chunk = ffs_u((unsigned)info.dwAllocationGranularity)
|
||||
- 1;
|
||||
}
|
||||
#else
|
||||
if (!opt_lg_chunk)
|
||||
opt_lg_chunk = LG_CHUNK_DEFAULT;
|
||||
#endif
|
||||
|
||||
/* Set variables according to the value of opt_lg_chunk. */
|
||||
chunksize = (ZU(1) << opt_lg_chunk);
|
||||
assert(chunksize >= PAGE);
|
||||
chunksize_mask = chunksize - 1;
|
||||
chunk_npages = (chunksize >> LG_PAGE);
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
|
@ -88,7 +88,6 @@ CTL_PROTO(config_utrace)
|
|||
CTL_PROTO(config_xmalloc)
|
||||
CTL_PROTO(opt_abort)
|
||||
CTL_PROTO(opt_dss)
|
||||
CTL_PROTO(opt_lg_chunk)
|
||||
CTL_PROTO(opt_narenas)
|
||||
CTL_PROTO(opt_decay_time)
|
||||
CTL_PROTO(opt_stats_print)
|
||||
|
|
@ -177,7 +176,6 @@ CTL_PROTO(stats_arenas_i_nmadvise)
|
|||
CTL_PROTO(stats_arenas_i_purged)
|
||||
CTL_PROTO(stats_arenas_i_metadata)
|
||||
INDEX_PROTO(stats_arenas_i)
|
||||
CTL_PROTO(stats_cactive)
|
||||
CTL_PROTO(stats_allocated)
|
||||
CTL_PROTO(stats_active)
|
||||
CTL_PROTO(stats_metadata)
|
||||
|
|
@ -244,7 +242,6 @@ static const ctl_named_node_t config_node[] = {
|
|||
static const ctl_named_node_t opt_node[] = {
|
||||
{NAME("abort"), CTL(opt_abort)},
|
||||
{NAME("dss"), CTL(opt_dss)},
|
||||
{NAME("lg_chunk"), CTL(opt_lg_chunk)},
|
||||
{NAME("narenas"), CTL(opt_narenas)},
|
||||
{NAME("decay_time"), CTL(opt_decay_time)},
|
||||
{NAME("stats_print"), CTL(opt_stats_print)},
|
||||
|
|
@ -410,7 +407,6 @@ static const ctl_indexed_node_t stats_arenas_node[] = {
|
|||
};
|
||||
|
||||
static const ctl_named_node_t stats_node[] = {
|
||||
{NAME("cactive"), CTL(stats_cactive)},
|
||||
{NAME("allocated"), CTL(stats_allocated)},
|
||||
{NAME("active"), CTL(stats_active)},
|
||||
{NAME("metadata"), CTL(stats_metadata)},
|
||||
|
|
@ -1136,7 +1132,6 @@ CTL_RO_CONFIG_GEN(config_xmalloc, bool)
|
|||
|
||||
CTL_RO_NL_GEN(opt_abort, opt_abort, bool)
|
||||
CTL_RO_NL_GEN(opt_dss, opt_dss, const char *)
|
||||
CTL_RO_NL_GEN(opt_lg_chunk, opt_lg_chunk, size_t)
|
||||
CTL_RO_NL_GEN(opt_narenas, opt_narenas, unsigned)
|
||||
CTL_RO_NL_GEN(opt_decay_time, opt_decay_time, ssize_t)
|
||||
CTL_RO_NL_GEN(opt_stats_print, opt_stats_print, bool)
|
||||
|
|
@ -1888,7 +1883,6 @@ CTL_RO_NL_CGEN(config_prof, lg_prof_sample, lg_prof_sample, size_t)
|
|||
|
||||
/******************************************************************************/
|
||||
|
||||
CTL_RO_CGEN(config_stats, stats_cactive, &stats_cactive, size_t *)
|
||||
CTL_RO_CGEN(config_stats, stats_allocated, ctl_stats.allocated, size_t)
|
||||
CTL_RO_CGEN(config_stats, stats_active, ctl_stats.active, size_t)
|
||||
CTL_RO_CGEN(config_stats, stats_metadata, ctl_stats.metadata, size_t)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
/******************************************************************************/
|
||||
/* Data. */
|
||||
|
||||
const char *opt_dss = DSS_DEFAULT;
|
||||
|
||||
const char *dss_prec_names[] = {
|
||||
"disabled",
|
||||
"primary",
|
||||
|
|
|
|||
|
|
@ -1024,8 +1024,6 @@ malloc_conf_init(void)
|
|||
}
|
||||
|
||||
CONF_HANDLE_BOOL(opt_abort, "abort", true)
|
||||
CONF_HANDLE_SIZE_T(opt_lg_chunk, "lg_chunk", LG_PAGE,
|
||||
(sizeof(size_t) << 3) - 1, true)
|
||||
if (strncmp("dss", k, klen) == 0) {
|
||||
int i;
|
||||
bool match = false;
|
||||
|
|
@ -1176,8 +1174,6 @@ malloc_init_hard_a0_locked()
|
|||
pages_boot();
|
||||
if (base_boot())
|
||||
return (true);
|
||||
if (chunk_boot())
|
||||
return (true);
|
||||
if (extent_boot())
|
||||
return (true);
|
||||
if (ctl_boot())
|
||||
|
|
|
|||
11
src/stats.c
11
src/stats.c
|
|
@ -30,8 +30,6 @@
|
|||
|
||||
bool opt_stats_print = false;
|
||||
|
||||
size_t stats_cactive = 0;
|
||||
|
||||
/******************************************************************************/
|
||||
/* Function prototypes for non-inline static functions. */
|
||||
|
||||
|
|
@ -416,7 +414,6 @@ stats_print(void (*write_cb)(void *, const char *), void *cbopaque,
|
|||
malloc_cprintf(write_cb, cbopaque,
|
||||
"Run-time option settings:\n");
|
||||
OPT_WRITE_BOOL(abort)
|
||||
OPT_WRITE_SIZE_T(lg_chunk)
|
||||
OPT_WRITE_CHAR_P(dss)
|
||||
OPT_WRITE_UNSIGNED(narenas)
|
||||
OPT_WRITE_CHAR_P(purge)
|
||||
|
|
@ -486,16 +483,11 @@ stats_print(void (*write_cb)(void *, const char *), void *cbopaque,
|
|||
"Average profile dump interval: N/A\n");
|
||||
}
|
||||
}
|
||||
CTL_GET("opt.lg_chunk", &sv, size_t);
|
||||
malloc_cprintf(write_cb, cbopaque,
|
||||
"Chunk size: %zu (2^%zu)\n", (ZU(1) << sv), sv);
|
||||
}
|
||||
|
||||
if (config_stats) {
|
||||
size_t *cactive;
|
||||
size_t allocated, active, metadata, resident, mapped, retained;
|
||||
|
||||
CTL_GET("stats.cactive", &cactive, size_t *);
|
||||
CTL_GET("stats.allocated", &allocated, size_t);
|
||||
CTL_GET("stats.active", &active, size_t);
|
||||
CTL_GET("stats.metadata", &metadata, size_t);
|
||||
|
|
@ -506,9 +498,6 @@ stats_print(void (*write_cb)(void *, const char *), void *cbopaque,
|
|||
"Allocated: %zu, active: %zu, metadata: %zu,"
|
||||
" resident: %zu, mapped: %zu, retained: %zu\n",
|
||||
allocated, active, metadata, resident, mapped, retained);
|
||||
malloc_cprintf(write_cb, cbopaque,
|
||||
"Current active ceiling: %zu\n",
|
||||
atomic_read_z(cactive));
|
||||
|
||||
if (merged) {
|
||||
unsigned narenas;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue