add experimental.arenas_create_ext mallctl
This mallctl accepts an arena_config_t structure which can be used to customize the behavior of the arena. Right now it contains extent_hooks and a new option, metadata_use_hooks, which controls whether the extent hooks are also used for metadata allocation. The medata_use_hooks option has two main use cases: 1. In heterogeneous memory systems, to avoid metadata being placed on potentially slower memory. 2. Avoiding virtual memory from being leaked as a result of metadata allocation failure originating in an extent hook.
This commit is contained in:
@@ -32,7 +32,8 @@ TEST_BEGIN(test_base_hooks_default) {
|
||||
|
||||
tsdn_t *tsdn = tsd_tsdn(tsd_fetch());
|
||||
base = base_new(tsdn, 0,
|
||||
(extent_hooks_t *)&ehooks_default_extent_hooks);
|
||||
(extent_hooks_t *)&ehooks_default_extent_hooks,
|
||||
/* metadata_use_hooks */ true);
|
||||
|
||||
if (config_stats) {
|
||||
base_stats_get(tsdn, base, &allocated0, &resident, &mapped,
|
||||
@@ -74,7 +75,7 @@ TEST_BEGIN(test_base_hooks_null) {
|
||||
memcpy(&hooks, &hooks_null, sizeof(extent_hooks_t));
|
||||
|
||||
tsdn_t *tsdn = tsd_tsdn(tsd_fetch());
|
||||
base = base_new(tsdn, 0, &hooks);
|
||||
base = base_new(tsdn, 0, &hooks, /* metadata_use_hooks */ true);
|
||||
expect_ptr_not_null(base, "Unexpected base_new() failure");
|
||||
|
||||
if (config_stats) {
|
||||
@@ -120,7 +121,7 @@ TEST_BEGIN(test_base_hooks_not_null) {
|
||||
|
||||
tsdn_t *tsdn = tsd_tsdn(tsd_fetch());
|
||||
did_alloc = false;
|
||||
base = base_new(tsdn, 0, &hooks);
|
||||
base = base_new(tsdn, 0, &hooks, /* metadata_use_hooks */ true);
|
||||
expect_ptr_not_null(base, "Unexpected base_new() failure");
|
||||
expect_true(did_alloc, "Expected alloc");
|
||||
|
||||
|
@@ -5,7 +5,7 @@
|
||||
static void
|
||||
test_edata_cache_init(edata_cache_t *edata_cache) {
|
||||
base_t *base = base_new(TSDN_NULL, /* ind */ 1,
|
||||
&ehooks_default_extent_hooks);
|
||||
&ehooks_default_extent_hooks, /* metadata_use_hooks */ true);
|
||||
assert_ptr_not_null(base, "");
|
||||
bool err = edata_cache_init(edata_cache, base);
|
||||
assert_false(err, "");
|
||||
|
@@ -37,7 +37,7 @@ static hpa_shard_t *
|
||||
create_test_data(hpa_hooks_t *hooks, hpa_shard_opts_t *opts) {
|
||||
bool err;
|
||||
base_t *base = base_new(TSDN_NULL, /* ind */ SHARD_IND,
|
||||
&ehooks_default_extent_hooks);
|
||||
&ehooks_default_extent_hooks, /* metadata_use_hooks */ true);
|
||||
assert_ptr_not_null(base, "");
|
||||
|
||||
test_data_t *test_data = malloc(sizeof(test_data_t));
|
||||
|
@@ -53,7 +53,8 @@ test_data_t *init_test_data(ssize_t dirty_decay_ms, ssize_t muzzy_decay_ms) {
|
||||
assert_ptr_not_null(test_data, "");
|
||||
init_test_extent_hooks(&test_data->hooks);
|
||||
|
||||
base_t *base = base_new(TSDN_NULL, /* ind */ 1, &test_data->hooks);
|
||||
base_t *base = base_new(TSDN_NULL, /* ind */ 1,
|
||||
&test_data->hooks, /* metadata_use_hooks */ true);
|
||||
assert_ptr_not_null(base, "");
|
||||
|
||||
test_data->base = base;
|
||||
|
@@ -12,7 +12,8 @@ TEST_BEGIN(test_rtree_read_empty) {
|
||||
|
||||
tsdn = tsdn_fetch();
|
||||
|
||||
base_t *base = base_new(tsdn, 0, &ehooks_default_extent_hooks);
|
||||
base_t *base = base_new(tsdn, 0,
|
||||
&ehooks_default_extent_hooks, /* metadata_use_hooks */ true);
|
||||
expect_ptr_not_null(base, "Unexpected base_new failure");
|
||||
|
||||
rtree_t *rtree = &test_rtree;
|
||||
@@ -52,7 +53,8 @@ TEST_BEGIN(test_rtree_extrema) {
|
||||
|
||||
tsdn_t *tsdn = tsdn_fetch();
|
||||
|
||||
base_t *base = base_new(tsdn, 0, &ehooks_default_extent_hooks);
|
||||
base_t *base = base_new(tsdn, 0,
|
||||
&ehooks_default_extent_hooks, /* metadata_use_hooks */ true);
|
||||
expect_ptr_not_null(base, "Unexpected base_new failure");
|
||||
|
||||
rtree_t *rtree = &test_rtree;
|
||||
@@ -103,7 +105,8 @@ TEST_END
|
||||
|
||||
TEST_BEGIN(test_rtree_bits) {
|
||||
tsdn_t *tsdn = tsdn_fetch();
|
||||
base_t *base = base_new(tsdn, 0, &ehooks_default_extent_hooks);
|
||||
base_t *base = base_new(tsdn, 0,
|
||||
&ehooks_default_extent_hooks, /* metadata_use_hooks */ true);
|
||||
expect_ptr_not_null(base, "Unexpected base_new failure");
|
||||
|
||||
uintptr_t keys[] = {PAGE, PAGE + 1,
|
||||
@@ -152,7 +155,8 @@ TEST_BEGIN(test_rtree_random) {
|
||||
sfmt_t *sfmt = init_gen_rand(SEED);
|
||||
tsdn_t *tsdn = tsdn_fetch();
|
||||
|
||||
base_t *base = base_new(tsdn, 0, &ehooks_default_extent_hooks);
|
||||
base_t *base = base_new(tsdn, 0,
|
||||
&ehooks_default_extent_hooks, /* metadata_use_hooks */ true);
|
||||
expect_ptr_not_null(base, "Unexpected base_new failure");
|
||||
|
||||
uintptr_t keys[NSET];
|
||||
@@ -250,7 +254,8 @@ test_rtree_range_write(tsdn_t *tsdn, rtree_t *rtree, uintptr_t start,
|
||||
|
||||
TEST_BEGIN(test_rtree_range) {
|
||||
tsdn_t *tsdn = tsdn_fetch();
|
||||
base_t *base = base_new(tsdn, 0, &ehooks_default_extent_hooks);
|
||||
base_t *base = base_new(tsdn, 0,
|
||||
&ehooks_default_extent_hooks, /* metadata_use_hooks */ true);
|
||||
expect_ptr_not_null(base, "Unexpected base_new failure");
|
||||
|
||||
rtree_t *rtree = &test_rtree;
|
||||
|
@@ -42,7 +42,7 @@ test_sec_init(sec_t *sec, pai_t *fallback, size_t nshards, size_t max_alloc,
|
||||
* short-running, and SECs are arena-scoped in reality.
|
||||
*/
|
||||
base_t *base = base_new(TSDN_NULL, /* ind */ 123,
|
||||
&ehooks_default_extent_hooks);
|
||||
&ehooks_default_extent_hooks, /* metadata_use_hooks */ true);
|
||||
|
||||
bool err = sec_init(TSDN_NULL, sec, base, fallback, &opts);
|
||||
assert_false(err, "Unexpected initialization failure");
|
||||
@@ -442,7 +442,7 @@ TEST_BEGIN(test_nshards_0) {
|
||||
/* See the note above -- we can't use the real tsd. */
|
||||
tsdn_t *tsdn = TSDN_NULL;
|
||||
base_t *base = base_new(TSDN_NULL, /* ind */ 123,
|
||||
&ehooks_default_extent_hooks);
|
||||
&ehooks_default_extent_hooks, /* metadata_use_hooks */ true);
|
||||
|
||||
sec_opts_t opts = SEC_OPTS_DEFAULT;
|
||||
opts.nshards = 0;
|
||||
|
Reference in New Issue
Block a user