From fae47566c017830cc964b38e52140a20df49a78a Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Thu, 6 Aug 2015 13:55:07 +0100 Subject: [PATCH 01/11] Branching master to branch/2015-08-06/config. Copied from Perforce Change: 188083 ServerID: perforce.ravenbrook.com From 703c1ee5f56f4687d626d02f780355c6612fdb43 Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Thu, 6 Aug 2015 17:02:51 +0100 Subject: [PATCH 02/11] New function mps_arena_configure provides keyword argument interface to changing the properties of an arena. New keyword arguments MPS_KEY_ARENA_COMMIT_LIMIT and MPS_KEY_SPARE_ARENA_COMMIT_LIMIT can be passed to mps_arena_create_k or mps_arena_configure. Deprecate mps_arena_commit_limit_set and mps_arena_spare_commit_limit_set. Copied from Perforce Change: 188085 ServerID: perforce.ravenbrook.com --- mps/code/amcss.c | 2 +- mps/code/amcsshe.c | 2 +- mps/code/amcssth.c | 4 +- mps/code/amsss.c | 2 +- mps/code/apss.c | 31 +++-- mps/code/arena.c | 39 +++++- mps/code/arenacl.c | 11 ++ mps/code/arenavm.c | 11 ++ mps/code/config.h | 12 +- mps/code/locusss.c | 4 +- mps/code/mpm.h | 1 + mps/code/mpmst.h | 1 + mps/code/mpmtypes.h | 1 + mps/code/mps.h | 13 +- mps/code/mpsi.c | 14 +++ mps/code/mpsicv.c | 6 +- mps/manual/source/glossary/c.rst | 3 +- mps/manual/source/glossary/s.rst | 3 +- mps/manual/source/release.rst | 18 +++ mps/manual/source/topic/arena.rst | 163 ++++++++++++++----------- mps/manual/source/topic/deprecated.rst | 35 ++++++ mps/manual/source/topic/keyword.rst | 76 ++++++------ mps/test/function/165.c | 32 +++-- 23 files changed, 324 insertions(+), 160 deletions(-) diff --git a/mps/code/amcss.c b/mps/code/amcss.c index 3b15f7fb967..83d67dcba58 100644 --- a/mps/code/amcss.c +++ b/mps/code/amcss.c @@ -312,11 +312,11 @@ int main(int argc, char *argv[]) MPS_ARGS_BEGIN(args) { MPS_ARGS_ADD(args, MPS_KEY_ARENA_SIZE, scale * testArenaSIZE); MPS_ARGS_ADD(args, MPS_KEY_ARENA_GRAIN_SIZE, grainSize); + MPS_ARGS_ADD(args, MPS_KEY_ARENA_COMMIT_LIMIT, scale * testArenaSIZE); die(mps_arena_create_k(&arena, mps_arena_class_vm(), args), "arena_create"); } MPS_ARGS_END(args); mps_message_type_enable(arena, mps_message_type_gc()); mps_message_type_enable(arena, mps_message_type_gc_start()); - die(mps_arena_commit_limit_set(arena, scale * testArenaSIZE), "set limit"); die(mps_thread_reg(&thread, arena), "thread_reg"); test(arena, mps_class_amc(), exactRootsCOUNT); test(arena, mps_class_amcz(), 0); diff --git a/mps/code/amcsshe.c b/mps/code/amcsshe.c index fec9fb3a677..adfad3729e5 100644 --- a/mps/code/amcsshe.c +++ b/mps/code/amcsshe.c @@ -251,10 +251,10 @@ int main(int argc, char *argv[]) MPS_ARGS_BEGIN(args) { MPS_ARGS_ADD(args, MPS_KEY_ARENA_SIZE, testArenaSIZE); MPS_ARGS_ADD(args, MPS_KEY_ARENA_GRAIN_SIZE, rnd_grain(testArenaSIZE)); + MPS_ARGS_ADD(args, MPS_KEY_ARENA_COMMIT_LIMIT, testArenaSIZE); die(mps_arena_create_k(&arena, mps_arena_class_vm(), args), "arena_create"); } MPS_ARGS_END(args); mps_message_type_enable(arena, mps_message_type_gc()); - die(mps_arena_commit_limit_set(arena, testArenaSIZE), "set limit"); die(mps_thread_reg(&thread, arena), "thread_reg"); test(arena, mps_class_amc(), exactRootsCOUNT); test(arena, mps_class_amcz(), 0); diff --git a/mps/code/amcssth.c b/mps/code/amcssth.c index c6e2d214b5d..043330ebb74 100644 --- a/mps/code/amcssth.c +++ b/mps/code/amcssth.c @@ -291,10 +291,10 @@ static void test_arena(int mode) MPS_ARGS_BEGIN(args) { MPS_ARGS_ADD(args, MPS_KEY_ARENA_SIZE, testArenaSIZE); MPS_ARGS_ADD(args, MPS_KEY_ARENA_GRAIN_SIZE, rnd_grain(testArenaSIZE)); + if (mode == ModeCOMMIT) + MPS_ARGS_ADD(args, MPS_KEY_ARENA_COMMIT_LIMIT, 2 * testArenaSIZE); die(mps_arena_create_k(&arena, mps_arena_class_vm(), args), "arena_create"); } MPS_ARGS_END(args); - if (mode == ModeCOMMIT) - die(mps_arena_commit_limit_set(arena, 2 * testArenaSIZE), "set limit"); mps_message_type_enable(arena, mps_message_type_gc()); mps_message_type_enable(arena, mps_message_type_gc_start()); diff --git a/mps/code/amsss.c b/mps/code/amsss.c index 4e1e15814f7..15686e5d15d 100644 --- a/mps/code/amsss.c +++ b/mps/code/amsss.c @@ -209,9 +209,9 @@ int main(int argc, char *argv[]) MPS_ARGS_BEGIN(args) { MPS_ARGS_ADD(args, MPS_KEY_ARENA_SIZE, testArenaSIZE); MPS_ARGS_ADD(args, MPS_KEY_ARENA_GRAIN_SIZE, rnd_grain(testArenaSIZE)); + MPS_ARGS_ADD(args, MPS_KEY_ARENA_COMMIT_LIMIT, 2 * testArenaSIZE); die(mps_arena_create_k(&arena, mps_arena_class_vm(), args), "arena_create"); } MPS_ARGS_END(args); - die(mps_arena_commit_limit_set(arena, 2 * testArenaSIZE), "commit_limit_set"); mps_message_type_enable(arena, mps_message_type_gc_start()); mps_message_type_enable(arena, mps_message_type_gc()); diff --git a/mps/code/apss.c b/mps/code/apss.c index 48a21e1d3fd..e1317b3fb73 100644 --- a/mps/code/apss.c +++ b/mps/code/apss.c @@ -156,10 +156,16 @@ static mps_pool_debug_option_s fenceOptions = { }; -/* testInArena -- test all the pool classes in the given arena */ +/* test -- create arena using given class and arguments; test all the + * pool classes in this arena + */ -static void testInArena(mps_arena_t arena, mps_pool_debug_option_s *options) +static void test(mps_arena_class_t arena_class, mps_arg_s arena_args[], + mps_pool_debug_option_s *options) { + mps_arena_t arena; + die(mps_arena_create_k(&arena, arena_class, arena_args), "mps_arena_create"); + MPS_ARGS_BEGIN(args) { mps_align_t align = sizeof(void *) << (rnd() % 4); MPS_ARGS_ADD(args, MPS_KEY_ALIGN, align); @@ -195,45 +201,36 @@ static void testInArena(mps_arena_t arena, mps_pool_debug_option_s *options) die(stress(arena, NULL, align, randomSizeAligned, "MVT", mps_class_mvt(), args), "stress MVT"); } MPS_ARGS_END(args); + + mps_arena_destroy(arena); } int main(int argc, char *argv[]) { - mps_arena_t arena; - testlib_init(argc, argv); MPS_ARGS_BEGIN(args) { MPS_ARGS_ADD(args, MPS_KEY_ARENA_SIZE, 2 * testArenaSIZE); MPS_ARGS_ADD(args, MPS_KEY_ARENA_GRAIN_SIZE, rnd_grain(2*testArenaSIZE)); - die(mps_arena_create_k(&arena, mps_arena_class_vm(), args), - "mps_arena_create"); + MPS_ARGS_ADD(args, MPS_KEY_ARENA_COMMIT_LIMIT, testArenaSIZE); + test(mps_arena_class_vm(), args, &fenceOptions); } MPS_ARGS_END(args); - die(mps_arena_commit_limit_set(arena, testArenaSIZE), "commit limit"); - testInArena(arena, &fenceOptions); - mps_arena_destroy(arena); MPS_ARGS_BEGIN(args) { MPS_ARGS_ADD(args, MPS_KEY_ARENA_SIZE, 2 * testArenaSIZE); MPS_ARGS_ADD(args, MPS_KEY_ARENA_ZONED, FALSE); MPS_ARGS_ADD(args, MPS_KEY_ARENA_GRAIN_SIZE, rnd_grain(2*testArenaSIZE)); - die(mps_arena_create_k(&arena, mps_arena_class_vm(), args), - "mps_arena_create"); + test(mps_arena_class_vm(), args, &bothOptions); } MPS_ARGS_END(args); - testInArena(arena, &bothOptions); - mps_arena_destroy(arena); MPS_ARGS_BEGIN(args) { MPS_ARGS_ADD(args, MPS_KEY_ARENA_SIZE, testArenaSIZE); MPS_ARGS_ADD(args, MPS_KEY_ARENA_ZONED, FALSE); MPS_ARGS_ADD(args, MPS_KEY_ARENA_CL_BASE, malloc(testArenaSIZE)); MPS_ARGS_ADD(args, MPS_KEY_ARENA_GRAIN_SIZE, rnd_grain(testArenaSIZE)); - die(mps_arena_create_k(&arena, mps_arena_class_cl(), args), - "mps_arena_create"); + test(mps_arena_class_cl(), args, &bothOptions); } MPS_ARGS_END(args); - testInArena(arena, &bothOptions); - mps_arena_destroy(arena); printf("%s: Conclusion: Failed to find any defects.\n", argv[0]); return 0; diff --git a/mps/code/arena.c b/mps/code/arena.c index 6c6b5220229..042fc6e01c9 100644 --- a/mps/code/arena.c +++ b/mps/code/arena.c @@ -209,9 +209,9 @@ Res ArenaInit(Arena arena, ArenaClass class, Size grainSize, ArgList args) arena->committed = (Size)0; /* commitLimit may be overridden by init (but probably not */ /* as there's not much point) */ - arena->commitLimit = (Size)-1; + arena->commitLimit = ARENA_DEFAULT_COMMIT_LIMIT; arena->spareCommitted = (Size)0; - arena->spareCommitLimit = ARENA_INIT_SPARE_COMMIT_LIMIT; + arena->spareCommitLimit = ARENA_DEFAULT_SPARE_COMMIT_LIMIT; arena->grainSize = grainSize; /* zoneShift is usually overridden by init */ arena->zoneShift = ARENA_ZONESHIFT; @@ -295,8 +295,10 @@ ARG_DEFINE_KEY(VMW3_TOP_DOWN, Bool); /* ArenaCreate -- create the arena and call initializers */ -ARG_DEFINE_KEY(ARENA_SIZE, Size); +ARG_DEFINE_KEY(ARENA_COMMIT_LIMIT, Size); ARG_DEFINE_KEY(ARENA_GRAIN_SIZE, Size); +ARG_DEFINE_KEY(ARENA_SIZE, Size); +ARG_DEFINE_KEY(ARENA_SPARE_COMMIT_LIMIT, Size); ARG_DEFINE_KEY(ARENA_ZONED, Bool); Res ArenaCreate(Arena *arenaReturn, ArenaClass class, ArgList args) @@ -343,9 +345,15 @@ Res ArenaCreate(Arena *arenaReturn, ArenaClass class, ArgList args) goto failGlobalsCompleteCreate; AVERT(Arena, arena); + + res = ArenaConfigure(arena, args); + if (res != ResOK) + goto failConfigure; + *arenaReturn = arena; return ResOK; +failConfigure: failGlobalsCompleteCreate: ControlFinish(arena); failControlInit: @@ -357,6 +365,31 @@ failInit: } +/* ArenaConfigure -- configure an arena */ + +Res ArenaConfigure(Arena arena, ArgList args) +{ + Res res; + mps_arg_s arg; + + AVERT(Arena, arena); + AVERT(ArgList, args); + + if (ArgPick(&arg, args, MPS_KEY_ARENA_COMMIT_LIMIT)) { + Size limit = arg.val.size; + res = ArenaSetCommitLimit(arena, limit); + if (res != ResOK) + return res; + } + if (ArgPick(&arg, args, MPS_KEY_ARENA_SPARE_COMMIT_LIMIT)) { + Size limit = arg.val.size; + (void)ArenaSetSpareCommitLimit(arena, limit); + } + + return (*arena->class->configure)(arena, args); +} + + /* ArenaFinish -- finish the generic part of the arena * * .finish.caller: Unlike PoolFinish, this is called by the class finish diff --git a/mps/code/arenacl.c b/mps/code/arenacl.c index 857c4608e11..0f118422dfb 100644 --- a/mps/code/arenacl.c +++ b/mps/code/arenacl.c @@ -307,6 +307,16 @@ failChunkCreate: } +/* ClientArenaConfigure -- configure the arena */ + +static Res ClientArenaConfigure(Arena arena, ArgList args) +{ + UNUSED(arena); + UNUSED(args); + return ResOK; +} + + /* ClientArenaFinish -- finish the arena */ static void ClientArenaFinish(Arena arena) @@ -450,6 +460,7 @@ DEFINE_ARENA_CLASS(ClientArenaClass, this) this->offset = offsetof(ClientArenaStruct, arenaStruct); this->varargs = ClientArenaVarargs; this->init = ClientArenaInit; + this->configure = ClientArenaConfigure; this->finish = ClientArenaFinish; this->reserved = ClientArenaReserved; this->extend = ClientArenaExtend; diff --git a/mps/code/arenavm.c b/mps/code/arenavm.c index 77abf295e0b..fa57cfdfa5c 100644 --- a/mps/code/arenavm.c +++ b/mps/code/arenavm.c @@ -617,6 +617,16 @@ failVMInit: } +/* VMArenaConfigure -- configure the arena */ + +static Res VMArenaConfigure(Arena arena, ArgList args) +{ + UNUSED(arena); + UNUSED(args); + return ResOK; +} + + /* VMArenaFinish -- finish the arena */ static void VMArenaFinish(Arena arena) @@ -1203,6 +1213,7 @@ DEFINE_ARENA_CLASS(VMArenaClass, this) this->offset = offsetof(VMArenaStruct, arenaStruct); this->varargs = VMArenaVarargs; this->init = VMArenaInit; + this->configure = VMArenaConfigure; this->finish = VMArenaFinish; this->reserved = VMArenaReserved; this->purgeSpare = VMPurgeSpare; diff --git a/mps/code/config.h b/mps/code/config.h index 8fbd251a220..0fded6a291d 100644 --- a/mps/code/config.h +++ b/mps/code/config.h @@ -405,6 +405,13 @@ #define ARENA_CLIENT_GRAIN_SIZE ((Size)8192) +#define ARENA_DEFAULT_COMMIT_LIMIT ((Size)-1) + +/* TODO: This should be proportional to the memory usage of the MPS, not + * a constant. That will require design, and then some interface and + * documenation changes. */ +#define ARENA_DEFAULT_SPARE_COMMIT_LIMIT ((Size)10uL*1024uL*1024uL) + #define ARENA_DEFAULT_ZONED TRUE #define ArenaDefaultZONESET (ZoneSetUNIV << (MPS_WORD_WIDTH / 2)) @@ -611,11 +618,6 @@ #define MPS_PROD_STRING "mps" #define MPS_PROD_MPS -/* TODO: This should be proportional to the memory usage of the MPS, not - a constant. That will require design, and then some interface and - documenation changes. */ -#define ARENA_INIT_SPARE_COMMIT_LIMIT ((Size)10uL*1024uL*1024uL) - /* Default chain for GC pools * diff --git a/mps/code/locusss.c b/mps/code/locusss.c index 70cf313ed45..742e5ee779b 100644 --- a/mps/code/locusss.c +++ b/mps/code/locusss.c @@ -219,13 +219,11 @@ static void runArenaTest(size_t size, MPS_ARGS_BEGIN(args) { MPS_ARGS_ADD(args, MPS_KEY_ARENA_SIZE, size); MPS_ARGS_ADD(args, MPS_KEY_ARENA_ZONED, FALSE); + MPS_ARGS_ADD(args, MPS_KEY_ARENA_COMMIT_LIMIT, size - chunkSize); die(mps_arena_create_k(&arena, mps_arena_class_vm(), args), "mps_arena_create"); } MPS_ARGS_END(args); - die(mps_arena_commit_limit_set(arena, size - chunkSize), - "mps_arena_commit_limit_set"); - testInArena(arena, failcase, usefulFailcase); mps_arena_destroy(arena); diff --git a/mps/code/mpm.h b/mps/code/mpm.h index 30c1089e0ce..458f8be6658 100644 --- a/mps/code/mpm.h +++ b/mps/code/mpm.h @@ -497,6 +497,7 @@ extern Bool ArenaClassCheck(ArenaClass class); extern Bool ArenaCheck(Arena arena); extern Res ArenaCreate(Arena *arenaReturn, ArenaClass class, ArgList args); +extern Res ArenaConfigure(Arena arena, ArgList args); extern void ArenaDestroy(Arena arena); extern Res ArenaInit(Arena arena, ArenaClass class, Size grainSize, ArgList args); diff --git a/mps/code/mpmst.h b/mps/code/mpmst.h index a7749aa738d..44a641018eb 100644 --- a/mps/code/mpmst.h +++ b/mps/code/mpmst.h @@ -525,6 +525,7 @@ typedef struct mps_arena_class_s { size_t offset; /* offset of generic struct in outer struct */ ArenaVarargsMethod varargs; ArenaInitMethod init; + ArenaConfigureMethod configure; ArenaFinishMethod finish; ArenaReservedMethod reserved; ArenaPurgeSpareMethod purgeSpare; diff --git a/mps/code/mpmtypes.h b/mps/code/mpmtypes.h index a69b2b79ebe..b52c8e7dfd4 100644 --- a/mps/code/mpmtypes.h +++ b/mps/code/mpmtypes.h @@ -119,6 +119,7 @@ typedef unsigned FindDelete; /* */ typedef void (*ArenaVarargsMethod)(ArgStruct args[], va_list varargs); typedef Res (*ArenaInitMethod)(Arena *arenaReturn, ArenaClass class, ArgList args); +typedef Res (*ArenaConfigureMethod)(Arena arena, ArgList args); typedef void (*ArenaFinishMethod)(Arena arena); typedef Size (*ArenaReservedMethod)(Arena arena); typedef Size (*ArenaPurgeSpareMethod)(Arena arena, Size size); diff --git a/mps/code/mps.h b/mps/code/mps.h index 4e75d49b73a..b8882335581 100644 --- a/mps/code/mps.h +++ b/mps/code/mps.h @@ -155,12 +155,18 @@ extern const struct mps_key_s _mps_key_ARGS_END; #define MPS_KEY_ARGS_END (&_mps_key_ARGS_END) extern mps_arg_s mps_args_none[]; -extern const struct mps_key_s _mps_key_ARENA_SIZE; -#define MPS_KEY_ARENA_SIZE (&_mps_key_ARENA_SIZE) -#define MPS_KEY_ARENA_SIZE_FIELD size +extern const struct mps_key_s _mps_key_ARENA_COMMIT_LIMIT; +#define MPS_KEY_ARENA_COMMIT_LIMIT (&_mps_key_ARENA_COMMIT_LIMIT) +#define MPS_KEY_ARENA_COMMIT_LIMIT_FIELD size extern const struct mps_key_s _mps_key_ARENA_GRAIN_SIZE; #define MPS_KEY_ARENA_GRAIN_SIZE (&_mps_key_ARENA_GRAIN_SIZE) #define MPS_KEY_ARENA_GRAIN_SIZE_FIELD size +extern const struct mps_key_s _mps_key_ARENA_SIZE; +#define MPS_KEY_ARENA_SIZE (&_mps_key_ARENA_SIZE) +#define MPS_KEY_ARENA_SIZE_FIELD size +extern const struct mps_key_s _mps_key_ARENA_SPARE_COMMIT_LIMIT; +#define MPS_KEY_ARENA_SPARE_COMMIT_LIMIT (&_mps_key_ARENA_SPARE_COMMIT_LIMIT) +#define MPS_KEY_ARENA_SPARE_COMMIT_LIMIT_FIELD size extern const struct mps_key_s _mps_key_ARENA_ZONED; #define MPS_KEY_ARENA_ZONED (&_mps_key_ARENA_ZONED) #define MPS_KEY_ARENA_ZONED_FIELD b @@ -433,6 +439,7 @@ extern mps_res_t mps_arena_create(mps_arena_t *, mps_arena_class_t, ...); extern mps_res_t mps_arena_create_v(mps_arena_t *, mps_arena_class_t, va_list); extern mps_res_t mps_arena_create_k(mps_arena_t *, mps_arena_class_t, mps_arg_s []); +extern mps_res_t mps_arena_configure(mps_arena_t, mps_arg_s []); extern void mps_arena_destroy(mps_arena_t); extern size_t mps_arena_reserved(mps_arena_t); diff --git a/mps/code/mpsi.c b/mps/code/mpsi.c index a7dec7495c1..8ee89ac3923 100644 --- a/mps/code/mpsi.c +++ b/mps/code/mpsi.c @@ -350,6 +350,20 @@ mps_res_t mps_arena_create_k(mps_arena_t *mps_arena_o, } +/* mps_arena_configure -- configure an arena object */ + +mps_res_t mps_arena_configure(mps_arena_t arena, mps_arg_s args[]) +{ + Res res; + + ArenaEnter(arena); + res = ArenaConfigure(arena, args); + ArenaLeave(arena); + + return (mps_res_t)res; +} + + /* mps_arena_destroy -- destroy an arena object */ void mps_arena_destroy(mps_arena_t arena) diff --git a/mps/code/mpsicv.c b/mps/code/mpsicv.c index a6b23f00578..9f546c8678c 100644 --- a/mps/code/mpsicv.c +++ b/mps/code/mpsicv.c @@ -320,6 +320,7 @@ static mps_res_t root_single(mps_ss_t ss, void *p, size_t s) * mps_arena_reserved * incidentally tests: * mps_alloc + * mps_arena_configure * mps_class_mv * mps_pool_create * mps_pool_destroy @@ -346,7 +347,10 @@ static void arena_commit_test(mps_arena_t arena) res = mps_alloc(&p, pool, FILLER_OBJECT_SIZE); } while (res == MPS_RES_OK); die_expect(res, MPS_RES_COMMIT_LIMIT, "Commit limit allocation"); - die(mps_arena_commit_limit_set(arena, limit), "commit_limit_set after"); + MPS_ARGS_BEGIN(args) { + MPS_ARGS_ADD(args, MPS_KEY_ARENA_COMMIT_LIMIT, limit); + die(mps_arena_configure(arena, args), "commit_limit_set after"); + } MPS_ARGS_END(args); res = mps_alloc(&p, pool, FILLER_OBJECT_SIZE); die_expect(res, MPS_RES_OK, "Allocation failed after raising commit_limit"); mps_pool_destroy(pool); diff --git a/mps/manual/source/glossary/c.rst b/mps/manual/source/glossary/c.rst index ffdf1899243..23b2d960048 100644 --- a/mps/manual/source/glossary/c.rst +++ b/mps/manual/source/glossary/c.rst @@ -354,7 +354,8 @@ Memory Management Glossary: C The commit limit is a limit on the :term:`committed ` :term:`memory (2)` that the :term:`arena` will obtain from the operating system. It can be changed by - calling :c:func:`mps_arena_commit_limit_set`. + passing the :c:macro:`MPS_KEY_ARENA_COMMIT_LIMIT` + :term:`keyword argument` to :c:func:`mps_arena_configure`. committed (1) diff --git a/mps/manual/source/glossary/s.rst b/mps/manual/source/glossary/s.rst index dc9355f2a0f..b18c186fd23 100644 --- a/mps/manual/source/glossary/s.rst +++ b/mps/manual/source/glossary/s.rst @@ -467,7 +467,8 @@ Memory Management Glossary: S committed memory` that the MPS will obtain from the operating system. It can be retrieved by calling :c:func:`mps_arena_spare_commit_limit` and changed by - calling :c:func:`mps_arena_spare_commit_limit_set`. + passing the :c:macro:`MPS_KEY_ARENA_SPARE_COMMIT_LIMIT` + :term:`keyword argument` to :c:func:`mps_arena_configure`. spare committed memory diff --git a/mps/manual/source/release.rst b/mps/manual/source/release.rst index 1c1a3ef01f6..1d4e1e3405c 100644 --- a/mps/manual/source/release.rst +++ b/mps/manual/source/release.rst @@ -9,6 +9,20 @@ Release notes Release 1.115.0 --------------- +New features +............ + +#. The function :c:func:`mps_arena_create_k` accepts two new + :term:`keyword arguments`. :c:macro:`MPS_KEY_ARENA_COMMIT_LIMIT` + sets the :term:`commit limit` for the arena, and + :c:macro:`MPS_KEY_ARENA_SPARE_COMMIT_LIMIT` sets the :term:`spare + commit limit` for the arena. + +#. The new function :c:func:`mps_arena_configure` provides a + :term:`keyword argument` interface for changing the properties of + an arena. + + Interface changes ................. @@ -22,6 +36,10 @@ Interface changes deprecated in favour of the generic functions :c:func:`mps_pool_free_size` and :c:func:`mps_pool_total_size`. +#. The functions :c:func:`mps_arena_commit_limit_set` and + :c:func:`mps_arena_spare_commit_limit_set` are deprecated in favour + of :c:func:`mps_arena_configure`. + .. _release-notes-1.114: diff --git a/mps/manual/source/topic/arena.rst b/mps/manual/source/topic/arena.rst index 3ab5ad8c7bd..dc612c9f2a0 100644 --- a/mps/manual/source/topic/arena.rst +++ b/mps/manual/source/topic/arena.rst @@ -92,6 +92,19 @@ the way that they acquire the memory to be managed. :c:func:`mps_arena_destroy`. +.. c:function:: mps_res_t mps_arena_configure(mps_arena_t arena, mps_arg_s args[]) + + Configure an :term:`arena`. + + ``arena`` is the arena to configure. + + ``args`` are :term:`keyword arguments` specifying configuration + parameters. See the documentation for the arena class. + + Returns :c:macro:`MPS_RES_OK` if the arena was configured + successfully, or another :term:`result code` otherwise. + + .. c:function:: void mps_arena_destroy(mps_arena_t arena) Destroy an :term:`arena`. @@ -139,7 +152,12 @@ Client arenas * :c:macro:`MPS_KEY_ARENA_SIZE` (type :c:type:`size_t`) is its size. - It also accepts one optional keyword argument: + It also accepts two optional keyword arguments: + + * :c:macro:`MPS_KEY_ARENA_COMMIT_LIMIT` (type :c:type:`size_t`) is + the commit limit in :term:`bytes (1)`. See + :c:func:`mps_arena_commit_limit` for details. The default commit + limit is the maximum value of the :c:type:`size_t` type. * :c:macro:`MPS_KEY_ARENA_GRAIN_SIZE` (type :c:type:`size_t`, default 8192) is the granularity with which the arena will @@ -166,6 +184,10 @@ Client arenas Client arenas have no mechanism for returning unused memory. + When configuring a client arena, :c:func:`mps_arena_configure` + accepts the :term:`keyword argument` + :c:macro:`MPS_KEY_ARENA_COMMIT_LIMIT` as described above. + .. c:function:: mps_res_t mps_arena_extend(mps_arena_t arena, mps_addr_t base, size_t size) @@ -206,7 +228,7 @@ Virtual memory arenas more efficient. When creating a virtual memory arena, :c:func:`mps_arena_create_k` - accepts two optional :term:`keyword arguments` on all platforms: + accepts four optional :term:`keyword arguments` on all platforms: * :c:macro:`MPS_KEY_ARENA_SIZE` (type :c:type:`size_t`, default 256 :term:`megabytes`) is the initial amount of virtual address @@ -233,6 +255,11 @@ Virtual memory arenas more times it has to extend its address space, the less efficient garbage collection will become. + * :c:macro:`MPS_KEY_ARENA_COMMIT_LIMIT` (type :c:type:`size_t`) is + the commit limit in :term:`bytes (1)`. See + :c:func:`mps_arena_commit_limit` for details. The default commit + limit is the maximum value of the :c:type:`size_t` type. + * :c:macro:`MPS_KEY_ARENA_GRAIN_SIZE` (type :c:type:`size_t`) is the granularity with which the arena will manage memory internally. It must be a power of 2. If not provided, the @@ -244,12 +271,18 @@ Virtual memory arenas that's smaller than the operating system page size, the MPS rounds it up to the page size and continues. - A third optional :term:`keyword argument` may be passed, but it + * :c:macro:`MPS_KEY_ARENA_SPARE_COMMIT_LIMIT` (type + :c:type:`size_t`, default 0) is the spare commit limit in + :term:`bytes (1)`. See :c:func:`mps_arena_spare_commit_limit` + for details. + + A fifth optional :term:`keyword argument` may be passed, but it only has any effect on the Windows operating system: - * :c:macro:`MPS_KEY_VMW3_TOP_DOWN` (type :c:type:`mps_bool_t`). If - true, the arena will allocate address space starting at the - highest possible address and working downwards through memory. + * :c:macro:`MPS_KEY_VMW3_TOP_DOWN` (type :c:type:`mps_bool_t`, + default false). If true, the arena will allocate address space + starting at the highest possible address and working downwards + through memory. .. note:: @@ -276,6 +309,11 @@ Virtual memory arenas res = mps_arena_create_k(&arena, mps_arena_class_vm(), args); } MPS_ARGS_END(args); + When configuring a virtual memory arena, + :c:func:`mps_arena_configure` accepts the :term:`keyword + arguments` :c:macro:`MPS_KEY_ARENA_COMMIT_LIMIT` and + :c:macro:`MPS_KEY_ARENA_SPARE_COMMIT_LIMIT` as described above. + .. index:: single: arena; properties @@ -299,45 +337,36 @@ Arena properties ``arena`` is the arena to return the commit limit for. Returns the commit limit in :term:`bytes (1)`. The commit limit - controls how much memory the MPS can obtain from the operating - system, and can be changed by calling - :c:func:`mps_arena_commit_limit_set`. + controls how much main memory the MPS will obtain from the + operating system. The function :c:func:`mps_arena_committed` + returns the current committed memory; this never exceeds the + commit limit. - -.. c:function:: mps_res_t mps_arena_commit_limit_set(mps_arena_t arena, size_t limit) - - Change the :term:`commit limit` for an :term:`arena`. - - ``arena`` is the arena to change the commit limit for. - - ``limit`` is the new commit limit in :term:`bytes (1)`. - - Returns :c:macro:`MPS_RES_OK` if successful, or another - :term:`result code` if not. - - If successful, the commit limit for ``arena`` is set to ``limit``. The - commit limit controls how much memory the MPS will obtain from the - operating system. The commit limit cannot be set to a value that - is lower than the number of bytes that the MPS is using. If an - attempt is made to set the commit limit to a value greater than or - equal to that returned by :c:func:`mps_arena_committed` then it - will succeed. If an attempt is made to set the commit limit to a - value less than that returned by :c:func:`mps_arena_committed` - then it will succeed only if the amount committed by the MPS can - be reduced by reducing the amount of spare committed memory; in - such a case the spare committed memory will be reduced - appropriately and the attempt will succeed. + The commit limit can be changed by passing the + :c:macro:`MPS_KEY_ARENA_COMMIT_LIMIT` :term:`keyword argument` to + :c:func:`mps_arena_create_k` or :c:func:`mps_arena_configure`. The + commit limit cannot be set to a value that is lower than the + number of bytes that the MPS is using. If an attempt is made to + set the commit limit to a value greater than or equal to that + returned by :c:func:`mps_arena_committed` then it will succeed. If + an attempt is made to set the commit limit to a value less than + that returned by :c:func:`mps_arena_committed` then it will + succeed only if the amount committed by the MPS can be reduced by + reducing the amount of spare committed memory; in such a case the + spare committed memory will be reduced appropriately and the + attempt will succeed. .. note:: - :c:func:`mps_arena_commit_limit_set` puts a limit on all - memory committed by the MPS. The :term:`spare committed - memory` can be limited separately with - :c:func:`mps_arena_spare_commit_limit_set`. Note that "spare - committed" memory is subject to both limits; there cannot be - more spare committed memory than the spare commit limit, and - there can't be so much spare committed memory that there is - more committed memory than the commit limit. + The commit limit puts a limit on all memory committed by the + MPS. The :term:`spare committed memory` (that is, memory + committed by the MPS but not currently in use, neither by the + :term:`client program`, or by the MPS itself) can be limited + separately; see :c:func:`mps_arena_spare_committed`. Note that + "spare committed" memory is subject to both limits; there + cannot be more spare committed memory than the spare commit + limit, and there can't be so much spare committed memory that + there is more committed memory than the commit limit. .. c:function:: size_t mps_arena_committed(mps_arena_t arena) @@ -379,7 +408,7 @@ Arena properties estimate the size of the heap. If you want to know how much memory the MPS is using then you're - probably interested in the value :c:func:`mps_arena_committed()` − + probably interested in the value :c:func:`mps_arena_committed` − :c:func:`mps_arena_spare_committed`. The amount of committed memory can be limited with the function @@ -419,32 +448,19 @@ Arena properties ``arena`` is the arena to return the spare commit limit for. Returns the spare commit limit in :term:`bytes (1)`. The spare - commit limit can be changed by calling - :c:func:`mps_arena_spare_commit_limit_set`. + commit limit is the maximum amount of :term:`spare committed + memory` (that is, memory committed by the MPS but not currently in + use, neither by the :term:`client program`, or by the MPS itself) + the MPS is allowed to have. - -.. c:function:: void mps_arena_spare_commit_limit_set(mps_arena_t arena, size_t limit) - - Change the :term:`spare commit limit` for an :term:`arena`. - - ``arena`` is the arena to change the spare commit limit for. - - ``limit`` is the new spare commit limit in :term:`bytes (1)`. - - The spare commit limit is the maximum amount of :term:`spare - committed memory` the MPS is allowed to have. Setting it to a - value lower than the current amount of spare committed memory - causes spare committed memory to be uncommitted so as to bring the - value under the limit. In particular, setting it to 0 will mean - that the MPS will have no spare committed memory. - - Non-virtual-memory arena classes (for example, a :term:`client - arena`) do not have spare committed memory. For these arenas, this - function sets a value but has no other effect. - - Initially the spare commit limit is a configuration-dependent - value. The value of the limit can be retrieved by the function - :c:func:`mps_arena_spare_commit_limit`. + The spare commit limit can be changed by passing the + :c:macro:`MPS_KEY_ARENA_SPARE_COMMIT_LIMIT` :term:`keyword + argument` to :c:func:`mps_arena_create_k` or + :c:func:`mps_arena_configure`. Setting it to a value lower than + the current amount of spare committed memory causes spare + committed memory to be uncommitted so as to bring the value under + the limit. In particular, setting it to 0 will mean that the MPS + will have no spare committed memory. .. c:function:: size_t mps_arena_spare_committed(mps_arena_t arena) @@ -466,12 +482,13 @@ Arena properties memory by :c:func:`mps_arena_committed` and is restricted by :c:func:`mps_arena_commit_limit`. - The amount of "spare committed" memory can be limited by calling - :c:func:`mps_arena_spare_commit_limit_set`, and the value of that - limit can be retrieved with - :c:func:`mps_arena_spare_commit_limit`. This is analogous to the - functions for limiting the amount of :term:`committed ` - memory. + The amount of "spare committed" memory can be limited passing the + :c:macro:`MPS_KEY_ARENA_SPARE_COMMIT_LIMIT` :term:`keyword + argument` to :c:func:`mps_arena_create_k` or + :c:func:`mps_arena_configure`. The value of the limit can be + retrieved with :c:func:`mps_arena_spare_commit_limit`. This is + analogous to the functions for limiting the amount of + :term:`committed ` memory. .. index:: diff --git a/mps/manual/source/topic/deprecated.rst b/mps/manual/source/topic/deprecated.rst index dfd4d8d74cb..329f90d48dc 100644 --- a/mps/manual/source/topic/deprecated.rst +++ b/mps/manual/source/topic/deprecated.rst @@ -25,6 +25,41 @@ supported interface. Deprecated in version 1.115 ........................... +.. c:function:: mps_res_t mps_arena_commit_limit_set(mps_arena_t arena, size_t limit) + + .. deprecated:: + + Pass the :c:macro:`MPS_KEY_ARENA_COMMIT_LIMIT` :term:`keyword + argument` to :c:func:`mps_arena_create_k` or + :c:func:`mps_arena_configure`. + + Change the :term:`commit limit` for an :term:`arena`. + + ``arena`` is the arena to change the commit limit for. + + ``limit`` is the new commit limit in :term:`bytes (1)`. + + Returns :c:macro:`MPS_RES_OK` if successful, or another + :term:`result code` if not. + + +.. c:function:: void mps_arena_spare_commit_limit_set(mps_arena_t arena, size_t limit) + + Change the :term:`spare commit limit` for an :term:`arena`. + + ``arena`` is the arena to change the spare commit limit for. + + ``limit`` is the new spare commit limit in :term:`bytes (1)`. + + Non-virtual-memory arena classes (for example, a :term:`client + arena`) do not have spare committed memory. For these arenas, this + function sets a value but has no other effect. + + Initially the spare commit limit is a configuration-dependent + value. The value of the limit can be retrieved by the function + :c:func:`mps_arena_spare_commit_limit`. + + .. c:type:: typedef mps_pool_class_t mps_class_t .. deprecated:: diff --git a/mps/manual/source/topic/keyword.rst b/mps/manual/source/topic/keyword.rst index ac80333ba36..6d321eab491 100644 --- a/mps/manual/source/topic/keyword.rst +++ b/mps/manual/source/topic/keyword.rst @@ -82,43 +82,45 @@ now :c:macro:`MPS_KEY_ARGS_END`. The type of :term:`keyword argument` keys. Must take one of the following values: - ======================================== ========================================================= ========================================================== - Keyword Type & field in ``arg.val`` See - ======================================== ========================================================= ========================================================== - :c:macro:`MPS_KEY_ARGS_END` *none* *see above* - :c:macro:`MPS_KEY_ALIGN` :c:type:`mps_align_t` ``align`` :c:func:`mps_class_mv`, :c:func:`mps_class_mvff`, :c:func:`mps_class_mvt` - :c:macro:`MPS_KEY_AMS_SUPPORT_AMBIGUOUS` :c:type:`mps_bool_t` ``b`` :c:func:`mps_class_ams` - :c:macro:`MPS_KEY_ARENA_CL_BASE` :c:type:`mps_addr_t` ``addr`` :c:func:`mps_arena_class_cl` - :c:macro:`MPS_KEY_ARENA_SIZE` :c:type:`size_t` ``size`` :c:func:`mps_arena_class_vm`, :c:func:`mps_arena_class_cl` - :c:macro:`MPS_KEY_ARENA_GRAIN_SIZE` :c:type:`size_t` ``size`` :c:func:`mps_arena_class_vm`, :c:func:`mps_arena_class_cl` - :c:macro:`MPS_KEY_AWL_FIND_DEPENDENT` ``void *(*)(void *)`` ``addr_method`` :c:func:`mps_class_awl` - :c:macro:`MPS_KEY_CHAIN` :c:type:`mps_chain_t` ``chain`` :c:func:`mps_class_amc`, :c:func:`mps_class_amcz`, :c:func:`mps_class_ams`, :c:func:`mps_class_awl`, :c:func:`mps_class_lo` - :c:macro:`MPS_KEY_EXTEND_BY` :c:type:`size_t` ``size`` :c:func:`mps_class_amc`, :c:func:`mps_class_amcz`, :c:func:`mps_class_mfs`, :c:func:`mps_class_mv`, :c:func:`mps_class_mvff` - :c:macro:`MPS_KEY_FMT_ALIGN` :c:type:`mps_align_t` ``align`` :c:func:`mps_fmt_create_k` - :c:macro:`MPS_KEY_FMT_CLASS` :c:type:`mps_fmt_class_t` ``fmt_class`` :c:func:`mps_fmt_create_k` - :c:macro:`MPS_KEY_FMT_FWD` :c:type:`mps_fmt_fwd_t` ``fmt_fwd`` :c:func:`mps_fmt_create_k` - :c:macro:`MPS_KEY_FMT_HEADER_SIZE` :c:type:`size_t` ``size`` :c:func:`mps_fmt_create_k` - :c:macro:`MPS_KEY_FMT_ISFWD` :c:type:`mps_fmt_isfwd_t` ``fmt_isfwd`` :c:func:`mps_fmt_create_k` - :c:macro:`MPS_KEY_FMT_PAD` :c:type:`mps_fmt_pad_t` ``fmt_pad`` :c:func:`mps_fmt_create_k` - :c:macro:`MPS_KEY_FMT_SCAN` :c:type:`mps_fmt_scan_t` ``fmt_scan`` :c:func:`mps_fmt_create_k` - :c:macro:`MPS_KEY_FMT_SKIP` :c:type:`mps_fmt_skip_t` ``fmt_skip`` :c:func:`mps_fmt_create_k` - :c:macro:`MPS_KEY_FORMAT` :c:type:`mps_fmt_t` ``format`` :c:func:`mps_class_amc`, :c:func:`mps_class_amcz`, :c:func:`mps_class_ams`, :c:func:`mps_class_awl`, :c:func:`mps_class_lo` , :c:func:`mps_class_snc` - :c:macro:`MPS_KEY_GEN` :c:type:`unsigned` ``u`` :c:func:`mps_class_ams`, :c:func:`mps_class_awl`, :c:func:`mps_class_lo` - :c:macro:`MPS_KEY_INTERIOR` :c:type:`mps_bool_t` ``b`` :c:func:`mps_class_amc`, :c:func:`mps_class_amcz` - :c:macro:`MPS_KEY_MAX_SIZE` :c:type:`size_t` ``size`` :c:func:`mps_class_mv` - :c:macro:`MPS_KEY_MEAN_SIZE` :c:type:`size_t` ``size`` :c:func:`mps_class_mv`, :c:func:`mps_class_mvt`, :c:func:`mps_class_mvff` - :c:macro:`MPS_KEY_MFS_UNIT_SIZE` :c:type:`size_t` ``size`` :c:func:`mps_class_mfs` - :c:macro:`MPS_KEY_MIN_SIZE` :c:type:`size_t` ``size`` :c:func:`mps_class_mvt` - :c:macro:`MPS_KEY_MVFF_ARENA_HIGH` :c:type:`mps_bool_t` ``b`` :c:func:`mps_class_mvff` - :c:macro:`MPS_KEY_MVFF_FIRST_FIT` :c:type:`mps_bool_t` ``b`` :c:func:`mps_class_mvff` - :c:macro:`MPS_KEY_MVFF_SLOT_HIGH` :c:type:`mps_bool_t` ``b`` :c:func:`mps_class_mvff` - :c:macro:`MPS_KEY_MVT_FRAG_LIMIT` :c:type:`mps_word_t` ``count`` :c:func:`mps_class_mvt` - :c:macro:`MPS_KEY_MVT_RESERVE_DEPTH` :c:type:`mps_word_t` ``count`` :c:func:`mps_class_mvt` - :c:macro:`MPS_KEY_POOL_DEBUG_OPTIONS` :c:type:`mps_pool_debug_option_s` ``*pool_debug_options`` :c:func:`mps_class_ams_debug`, :c:func:`mps_class_mv_debug`, :c:func:`mps_class_mvff_debug` - :c:macro:`MPS_KEY_RANK` :c:type:`mps_rank_t` ``rank`` :c:func:`mps_class_ams`, :c:func:`mps_class_awl`, :c:func:`mps_class_snc` - :c:macro:`MPS_KEY_SPARE` :c:type:`double` ``d`` :c:func:`mps_class_mvff` - :c:macro:`MPS_KEY_VMW3_TOP_DOWN` :c:type:`mps_bool_t` ``b`` :c:func:`mps_arena_class_vm` - ======================================== ========================================================= ========================================================== + =========================================== ========================================================= ========================================================== + Keyword Type & field in ``arg.val`` See + =========================================== ========================================================= ========================================================== + :c:macro:`MPS_KEY_ARGS_END` *none* *see above* + :c:macro:`MPS_KEY_ALIGN` :c:type:`mps_align_t` ``align`` :c:func:`mps_class_mv`, :c:func:`mps_class_mvff`, :c:func:`mps_class_mvt` + :c:macro:`MPS_KEY_AMS_SUPPORT_AMBIGUOUS` :c:type:`mps_bool_t` ``b`` :c:func:`mps_class_ams` + :c:macro:`MPS_KEY_ARENA_CL_BASE` :c:type:`mps_addr_t` ``addr`` :c:func:`mps_arena_class_cl` + :c:macro:`MPS_KEY_ARENA_COMMIT_LIMIT` :c:type:`size_t` ``size`` :c:func:`mps_arena_class_vm`, :c:func:`mps_arena_class_cl` + :c:macro:`MPS_KEY_ARENA_GRAIN_SIZE` :c:type:`size_t` ``size`` :c:func:`mps_arena_class_vm`, :c:func:`mps_arena_class_cl` + :c:macro:`MPS_KEY_ARENA_SIZE` :c:type:`size_t` ``size`` :c:func:`mps_arena_class_vm`, :c:func:`mps_arena_class_cl` + :c:macro:`MPS_KEY_ARENA_SPARE_COMMIT_LIMIT` :c:type:`size_t` ``size`` :c:func:`mps_arena_class_vm`, :c:func:`mps_arena_class_cl` + :c:macro:`MPS_KEY_AWL_FIND_DEPENDENT` ``void *(*)(void *)`` ``addr_method`` :c:func:`mps_class_awl` + :c:macro:`MPS_KEY_CHAIN` :c:type:`mps_chain_t` ``chain`` :c:func:`mps_class_amc`, :c:func:`mps_class_amcz`, :c:func:`mps_class_ams`, :c:func:`mps_class_awl`, :c:func:`mps_class_lo` + :c:macro:`MPS_KEY_EXTEND_BY` :c:type:`size_t` ``size`` :c:func:`mps_class_amc`, :c:func:`mps_class_amcz`, :c:func:`mps_class_mfs`, :c:func:`mps_class_mv`, :c:func:`mps_class_mvff` + :c:macro:`MPS_KEY_FMT_ALIGN` :c:type:`mps_align_t` ``align`` :c:func:`mps_fmt_create_k` + :c:macro:`MPS_KEY_FMT_CLASS` :c:type:`mps_fmt_class_t` ``fmt_class`` :c:func:`mps_fmt_create_k` + :c:macro:`MPS_KEY_FMT_FWD` :c:type:`mps_fmt_fwd_t` ``fmt_fwd`` :c:func:`mps_fmt_create_k` + :c:macro:`MPS_KEY_FMT_HEADER_SIZE` :c:type:`size_t` ``size`` :c:func:`mps_fmt_create_k` + :c:macro:`MPS_KEY_FMT_ISFWD` :c:type:`mps_fmt_isfwd_t` ``fmt_isfwd`` :c:func:`mps_fmt_create_k` + :c:macro:`MPS_KEY_FMT_PAD` :c:type:`mps_fmt_pad_t` ``fmt_pad`` :c:func:`mps_fmt_create_k` + :c:macro:`MPS_KEY_FMT_SCAN` :c:type:`mps_fmt_scan_t` ``fmt_scan`` :c:func:`mps_fmt_create_k` + :c:macro:`MPS_KEY_FMT_SKIP` :c:type:`mps_fmt_skip_t` ``fmt_skip`` :c:func:`mps_fmt_create_k` + :c:macro:`MPS_KEY_FORMAT` :c:type:`mps_fmt_t` ``format`` :c:func:`mps_class_amc`, :c:func:`mps_class_amcz`, :c:func:`mps_class_ams`, :c:func:`mps_class_awl`, :c:func:`mps_class_lo` , :c:func:`mps_class_snc` + :c:macro:`MPS_KEY_GEN` :c:type:`unsigned` ``u`` :c:func:`mps_class_ams`, :c:func:`mps_class_awl`, :c:func:`mps_class_lo` + :c:macro:`MPS_KEY_INTERIOR` :c:type:`mps_bool_t` ``b`` :c:func:`mps_class_amc`, :c:func:`mps_class_amcz` + :c:macro:`MPS_KEY_MAX_SIZE` :c:type:`size_t` ``size`` :c:func:`mps_class_mv` + :c:macro:`MPS_KEY_MEAN_SIZE` :c:type:`size_t` ``size`` :c:func:`mps_class_mv`, :c:func:`mps_class_mvt`, :c:func:`mps_class_mvff` + :c:macro:`MPS_KEY_MFS_UNIT_SIZE` :c:type:`size_t` ``size`` :c:func:`mps_class_mfs` + :c:macro:`MPS_KEY_MIN_SIZE` :c:type:`size_t` ``size`` :c:func:`mps_class_mvt` + :c:macro:`MPS_KEY_MVFF_ARENA_HIGH` :c:type:`mps_bool_t` ``b`` :c:func:`mps_class_mvff` + :c:macro:`MPS_KEY_MVFF_FIRST_FIT` :c:type:`mps_bool_t` ``b`` :c:func:`mps_class_mvff` + :c:macro:`MPS_KEY_MVFF_SLOT_HIGH` :c:type:`mps_bool_t` ``b`` :c:func:`mps_class_mvff` + :c:macro:`MPS_KEY_MVT_FRAG_LIMIT` :c:type:`mps_word_t` ``count`` :c:func:`mps_class_mvt` + :c:macro:`MPS_KEY_MVT_RESERVE_DEPTH` :c:type:`mps_word_t` ``count`` :c:func:`mps_class_mvt` + :c:macro:`MPS_KEY_POOL_DEBUG_OPTIONS` :c:type:`mps_pool_debug_option_s` ``*pool_debug_options`` :c:func:`mps_class_ams_debug`, :c:func:`mps_class_mv_debug`, :c:func:`mps_class_mvff_debug` + :c:macro:`MPS_KEY_RANK` :c:type:`mps_rank_t` ``rank`` :c:func:`mps_class_ams`, :c:func:`mps_class_awl`, :c:func:`mps_class_snc` + :c:macro:`MPS_KEY_SPARE` :c:type:`double` ``d`` :c:func:`mps_class_mvff` + :c:macro:`MPS_KEY_VMW3_TOP_DOWN` :c:type:`mps_bool_t` ``b`` :c:func:`mps_arena_class_vm` + =========================================== ========================================================= ========================================================== .. c:function:: MPS_ARGS_BEGIN(args) diff --git a/mps/test/function/165.c b/mps/test/function/165.c index 087d5e08f8d..e542cc111a7 100644 --- a/mps/test/function/165.c +++ b/mps/test/function/165.c @@ -1,7 +1,7 @@ /* TEST_HEADER id = $Id$ - summary = simple spare_commit_limit test + summary = simple spare commit limit test language = c link = testlib.o rankfmt.o harness = 2.0 @@ -32,14 +32,15 @@ static void test(void) unsigned long com0, com1, com2; -/* create a VM arena of 40MB */ +/* create a VM arena of 40MB with commit limit of 100MB, i.e. let the + arena do the limiting. */ - cdie(mps_arena_create(&arena, mps_arena_class_vm(), (size_t)(1024*1024*40)), - "create arena"); - -/* set the commit limit to 100MB, i.e. let the arena do the limiting */ - - mps_arena_commit_limit_set(arena, (size_t) (1024ul*1024ul*100ul)); + MPS_ARGS_BEGIN(args) { + MPS_ARGS_ADD(args, MPS_KEY_ARENA_SIZE, 1024*1024*40); + MPS_ARGS_ADD(args, MPS_KEY_ARENA_COMMIT_LIMIT, 1024ul*1024ul*100ul); + cdie(mps_arena_create_k(&arena, mps_arena_class_vm(), args), + "create arena"); + } MPS_ARGS_END(args); cdie(mps_thread_reg(&thread, arena), "register thread"); @@ -58,7 +59,10 @@ static void test(void) /* Set the spare commit limit to 0MB */ - mps_arena_spare_commit_limit_set(arena, (size_t) 0); + MPS_ARGS_BEGIN(args) { + MPS_ARGS_ADD(args, MPS_KEY_ARENA_SPARE_COMMIT_LIMIT, 0); + cdie(mps_arena_configure(arena, args), "mps_arena_configure"); + } MPS_ARGS_END(args); die(mps_alloc(&objs[0], pool, BIGSIZE), "alloc"); com0 = mps_arena_committed(arena); mps_free(pool, objs[0], BIGSIZE); @@ -70,7 +74,10 @@ static void test(void) /* Try again but with arena hysteresis */ /* nb. size_t unsigned, therefore (size_t)-1 is the maximum limit */ - mps_arena_spare_commit_limit_set(arena, (size_t)-1); + MPS_ARGS_BEGIN(args) { + MPS_ARGS_ADD(args, MPS_KEY_ARENA_SPARE_COMMIT_LIMIT, -1); + cdie(mps_arena_configure(arena, args), "mps_arena_configure"); + } MPS_ARGS_END(args); die(mps_alloc(&objs[0], pool, BIGSIZE), "alloc"); com0 = mps_arena_committed(arena); mps_free(pool, objs[0], BIGSIZE); @@ -80,7 +87,10 @@ static void test(void) report("reduce2", "%ld", com0-com1); /* Reducing the spare committed limit should return most of the spare */ - mps_arena_spare_commit_limit_set(arena, (size_t)(1024*1024)); + MPS_ARGS_BEGIN(args) { + MPS_ARGS_ADD(args, MPS_KEY_ARENA_SPARE_COMMIT_LIMIT, 1024*1024); + cdie(mps_arena_configure(arena, args), "mps_arena_configure"); + } MPS_ARGS_END(args); com2 = mps_arena_committed(arena); report("reduce3", "%ld", com0-com2); From 8d2ed2290895d2872f275a2db957ae61a4638884 Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Mon, 10 Aug 2015 15:27:26 +0100 Subject: [PATCH 03/11] Apply commit limit (and spare commit limit) during arena creation, to avoid exceeding the limit and then discovering that we've done so. Add test case for arena hitting commit limit during creation. Copied from Perforce Change: 188106 ServerID: perforce.ravenbrook.com --- mps/code/arena.c | 18 ++++++++---------- mps/test/function/120.c | 11 ++++++++++- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/mps/code/arena.c b/mps/code/arena.c index 9d359808c50..3d843cc7bde 100644 --- a/mps/code/arena.c +++ b/mps/code/arena.c @@ -197,6 +197,8 @@ Res ArenaInit(Arena arena, ArenaClass class, Size grainSize, ArgList args) { Res res; Bool zoned = ARENA_DEFAULT_ZONED; + Size commitLimit = ARENA_DEFAULT_COMMIT_LIMIT; + Size spareCommitLimit = ARENA_DEFAULT_SPARE_COMMIT_LIMIT; mps_arg_s arg; AVER(arena != NULL); @@ -205,16 +207,18 @@ Res ArenaInit(Arena arena, ArenaClass class, Size grainSize, ArgList args) if (ArgPick(&arg, args, MPS_KEY_ARENA_ZONED)) zoned = arg.val.b; + if (ArgPick(&arg, args, MPS_KEY_ARENA_COMMIT_LIMIT)) + commitLimit = arg.val.size; + if (ArgPick(&arg, args, MPS_KEY_ARENA_SPARE_COMMIT_LIMIT)) + spareCommitLimit = arg.val.size; arena->class = class; arena->reserved = (Size)0; arena->committed = (Size)0; - /* commitLimit may be overridden by init (but probably not */ - /* as there's not much point) */ - arena->commitLimit = ARENA_DEFAULT_COMMIT_LIMIT; + arena->commitLimit = commitLimit; arena->spareCommitted = (Size)0; - arena->spareCommitLimit = ARENA_DEFAULT_SPARE_COMMIT_LIMIT; + arena->spareCommitLimit = spareCommitLimit; arena->grainSize = grainSize; /* zoneShift is usually overridden by init */ arena->zoneShift = ARENA_ZONESHIFT; @@ -362,15 +366,9 @@ Res ArenaCreate(Arena *arenaReturn, ArenaClass class, ArgList args) goto failGlobalsCompleteCreate; AVERT(Arena, arena); - - res = ArenaConfigure(arena, args); - if (res != ResOK) - goto failConfigure; - *arenaReturn = arena; return ResOK; -failConfigure: failGlobalsCompleteCreate: ControlFinish(arena); failControlInit: diff --git a/mps/test/function/120.c b/mps/test/function/120.c index 4bd55205998..77609e3e37f 100644 --- a/mps/test/function/120.c +++ b/mps/test/function/120.c @@ -5,6 +5,7 @@ TEST_HEADER language = c link = testlib.o OUTPUT_SPEC + create = COMMIT_LIMIT commit0 = FAIL commit10 = OK com_less = FAIL @@ -33,8 +34,16 @@ static void test(void) { int i; mps_addr_t a; mps_res_t res; + size_t committed; + + /* Create an arena with a commit limit that's too small for the + * essential MPS internal data structures -- this must fail with + * RES_COMMIT_LIMIT. */ -/* create an arena that can't grow beyond 20 M */ + MPS_ARGS_BEGIN(args) { + MPS_ARGS_ADD(args, MPS_KEY_ARENA_COMMIT_LIMIT, 16 * 1024); + report_res("create", mps_arena_create_k(&arena, mps_arena_class_vm(), args)); + } MPS_ARGS_END(args); cdie(mps_arena_create(&arena, mps_arena_class_vm(), (size_t) (1024*1024*20)), "create arena"); From 7dee7f10ea097837203429bf916e1ee4abefd514 Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Mon, 10 Aug 2015 20:29:21 +0100 Subject: [PATCH 04/11] New test case 231: create/configure arena with too-small commit limit. Copied from Perforce Change: 188118 ServerID: perforce.ravenbrook.com --- mps/test/function/231.c | 43 +++++++++++++++++++++++++++++++++++++++ mps/test/testsets/passing | 3 ++- 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 mps/test/function/231.c diff --git a/mps/test/function/231.c b/mps/test/function/231.c new file mode 100644 index 00000000000..e0620fd09b3 --- /dev/null +++ b/mps/test/function/231.c @@ -0,0 +1,43 @@ +/* +TEST_HEADER + id = $Id$ + summary = create/configure arena with too-small commit limit + language = c + link = testlib.o +OUTPUT_SPEC + create1 = COMMIT_LIMIT + create2 = OK + configure = FAIL +END_HEADER +*/ + +#include "testlib.h" +#include "newfmt.h" + +static void test(void) +{ + mps_arena_t arena; + + MPS_ARGS_BEGIN(args) { + MPS_ARGS_ADD(args, MPS_KEY_ARENA_COMMIT_LIMIT, 16 * 1024); + report_res("create1", + mps_arena_create_k(&arena, mps_arena_class_vm(), args)); + } MPS_ARGS_END(args); + + report_res("create2", + mps_arena_create_k(&arena, mps_arena_class_vm(), mps_args_none)); + + MPS_ARGS_BEGIN(args) { + MPS_ARGS_ADD(args, MPS_KEY_ARENA_COMMIT_LIMIT, 16 * 1024); + report_res("configure", mps_arena_configure(arena, args)); + } MPS_ARGS_END(args); + + mps_arena_destroy(arena); +} + +int main(void) +{ + easy_tramp(test); + pass(); + return 0; +} diff --git a/mps/test/testsets/passing b/mps/test/testsets/passing index fde2ca5de8d..d19cce41070 100644 --- a/mps/test/testsets/passing +++ b/mps/test/testsets/passing @@ -168,4 +168,5 @@ function/224.c % 225 -- no such test function/226.c function/227.c -function/229.c \ No newline at end of file +function/229.c +function/231.c From 000df4fd79e46e365b57cfb2c9e6d5c874c6d883 Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Tue, 8 Sep 2015 16:13:29 +0100 Subject: [PATCH 05/11] Improve documentation of commit limit for a client arena. Copied from Perforce Change: 188285 ServerID: perforce.ravenbrook.com --- mps/manual/source/topic/arena.rst | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/mps/manual/source/topic/arena.rst b/mps/manual/source/topic/arena.rst index 106a1a40de2..29d942a29f2 100644 --- a/mps/manual/source/topic/arena.rst +++ b/mps/manual/source/topic/arena.rst @@ -155,9 +155,11 @@ Client arenas It also accepts two optional keyword arguments: * :c:macro:`MPS_KEY_ARENA_COMMIT_LIMIT` (type :c:type:`size_t`) is - the commit limit in :term:`bytes (1)`. See - :c:func:`mps_arena_commit_limit` for details. The default commit - limit is the maximum value of the :c:type:`size_t` type. + the maximum amount of memory, in :term:`bytes (1)`, that the MPS + will use out of the provided chunk (or chunks, if the arena is + extended). See :c:func:`mps_arena_commit_limit` for details. The + default commit limit is the maximum value of the + :c:type:`size_t` type. * :c:macro:`MPS_KEY_ARENA_GRAIN_SIZE` (type :c:type:`size_t`, default 8192) is the granularity with which the arena will @@ -256,7 +258,8 @@ Virtual memory arenas efficient garbage collection will become. * :c:macro:`MPS_KEY_ARENA_COMMIT_LIMIT` (type :c:type:`size_t`) is - the commit limit in :term:`bytes (1)`. See + the maximum amount of main memory, in :term:`bytes (1)`, that + the MPS will obtain from the operating system. See :c:func:`mps_arena_commit_limit` for details. The default commit limit is the maximum value of the :c:type:`size_t` type. @@ -336,11 +339,15 @@ Arena properties ``arena`` is the arena to return the commit limit for. - Returns the commit limit in :term:`bytes (1)`. The commit limit - controls how much main memory the MPS will obtain from the - operating system. The function :c:func:`mps_arena_committed` - returns the current committed memory; this never exceeds the - commit limit. + Returns the commit limit in :term:`bytes (1)`. + + For a :term:`client arena`, this this the maximum amount of + memory, in :term:`bytes (1)`, that the MPS will use out of the + chunks provided by the client to the arena. + + For a :term:`virtual memory arena`, this is the maximum amount of + memory that the MPS will map to RAM via the operating system's + virtual memory interface. The commit limit can be changed by passing the :c:macro:`MPS_KEY_ARENA_COMMIT_LIMIT` :term:`keyword argument` to From 537af4b0dcb4aeb87c90f7b7fec1ea90d07b62d9 Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Tue, 8 Sep 2015 16:21:27 +0100 Subject: [PATCH 06/11] Rename mps_key_arena_commit_limit and mps_key_arena_spare_commit_limit as mps_key_commit_limit and mps_key_spare_commit_limit respectively, as suggested by nb in review. Copied from Perforce Change: 188286 ServerID: perforce.ravenbrook.com --- mps/code/amcss.c | 2 +- mps/code/amcsshe.c | 2 +- mps/code/amcssth.c | 2 +- mps/code/amsss.c | 2 +- mps/code/apss.c | 2 +- mps/code/arena.c | 12 ++-- mps/code/locusss.c | 2 +- mps/code/mps.h | 12 ++-- mps/code/mpsicv.c | 2 +- mps/manual/source/release.rst | 4 +- mps/manual/source/topic/arena.rst | 18 +++--- mps/manual/source/topic/deprecated.rst | 2 +- mps/manual/source/topic/keyword.rst | 78 +++++++++++++------------- mps/test/function/120.c | 2 +- mps/test/function/165.c | 8 +-- mps/test/function/231.c | 4 +- 16 files changed, 77 insertions(+), 77 deletions(-) diff --git a/mps/code/amcss.c b/mps/code/amcss.c index 83d67dcba58..294ce224b15 100644 --- a/mps/code/amcss.c +++ b/mps/code/amcss.c @@ -312,7 +312,7 @@ int main(int argc, char *argv[]) MPS_ARGS_BEGIN(args) { MPS_ARGS_ADD(args, MPS_KEY_ARENA_SIZE, scale * testArenaSIZE); MPS_ARGS_ADD(args, MPS_KEY_ARENA_GRAIN_SIZE, grainSize); - MPS_ARGS_ADD(args, MPS_KEY_ARENA_COMMIT_LIMIT, scale * testArenaSIZE); + MPS_ARGS_ADD(args, MPS_KEY_COMMIT_LIMIT, scale * testArenaSIZE); die(mps_arena_create_k(&arena, mps_arena_class_vm(), args), "arena_create"); } MPS_ARGS_END(args); mps_message_type_enable(arena, mps_message_type_gc()); diff --git a/mps/code/amcsshe.c b/mps/code/amcsshe.c index adfad3729e5..bd3ea73d068 100644 --- a/mps/code/amcsshe.c +++ b/mps/code/amcsshe.c @@ -251,7 +251,7 @@ int main(int argc, char *argv[]) MPS_ARGS_BEGIN(args) { MPS_ARGS_ADD(args, MPS_KEY_ARENA_SIZE, testArenaSIZE); MPS_ARGS_ADD(args, MPS_KEY_ARENA_GRAIN_SIZE, rnd_grain(testArenaSIZE)); - MPS_ARGS_ADD(args, MPS_KEY_ARENA_COMMIT_LIMIT, testArenaSIZE); + MPS_ARGS_ADD(args, MPS_KEY_COMMIT_LIMIT, testArenaSIZE); die(mps_arena_create_k(&arena, mps_arena_class_vm(), args), "arena_create"); } MPS_ARGS_END(args); mps_message_type_enable(arena, mps_message_type_gc()); diff --git a/mps/code/amcssth.c b/mps/code/amcssth.c index 043330ebb74..3eea28df075 100644 --- a/mps/code/amcssth.c +++ b/mps/code/amcssth.c @@ -292,7 +292,7 @@ static void test_arena(int mode) MPS_ARGS_ADD(args, MPS_KEY_ARENA_SIZE, testArenaSIZE); MPS_ARGS_ADD(args, MPS_KEY_ARENA_GRAIN_SIZE, rnd_grain(testArenaSIZE)); if (mode == ModeCOMMIT) - MPS_ARGS_ADD(args, MPS_KEY_ARENA_COMMIT_LIMIT, 2 * testArenaSIZE); + MPS_ARGS_ADD(args, MPS_KEY_COMMIT_LIMIT, 2 * testArenaSIZE); die(mps_arena_create_k(&arena, mps_arena_class_vm(), args), "arena_create"); } MPS_ARGS_END(args); mps_message_type_enable(arena, mps_message_type_gc()); diff --git a/mps/code/amsss.c b/mps/code/amsss.c index 15686e5d15d..223bd205aea 100644 --- a/mps/code/amsss.c +++ b/mps/code/amsss.c @@ -209,7 +209,7 @@ int main(int argc, char *argv[]) MPS_ARGS_BEGIN(args) { MPS_ARGS_ADD(args, MPS_KEY_ARENA_SIZE, testArenaSIZE); MPS_ARGS_ADD(args, MPS_KEY_ARENA_GRAIN_SIZE, rnd_grain(testArenaSIZE)); - MPS_ARGS_ADD(args, MPS_KEY_ARENA_COMMIT_LIMIT, 2 * testArenaSIZE); + MPS_ARGS_ADD(args, MPS_KEY_COMMIT_LIMIT, 2 * testArenaSIZE); die(mps_arena_create_k(&arena, mps_arena_class_vm(), args), "arena_create"); } MPS_ARGS_END(args); diff --git a/mps/code/apss.c b/mps/code/apss.c index e1317b3fb73..1fe460df9ba 100644 --- a/mps/code/apss.c +++ b/mps/code/apss.c @@ -213,7 +213,7 @@ int main(int argc, char *argv[]) MPS_ARGS_BEGIN(args) { MPS_ARGS_ADD(args, MPS_KEY_ARENA_SIZE, 2 * testArenaSIZE); MPS_ARGS_ADD(args, MPS_KEY_ARENA_GRAIN_SIZE, rnd_grain(2*testArenaSIZE)); - MPS_ARGS_ADD(args, MPS_KEY_ARENA_COMMIT_LIMIT, testArenaSIZE); + MPS_ARGS_ADD(args, MPS_KEY_COMMIT_LIMIT, testArenaSIZE); test(mps_arena_class_vm(), args, &fenceOptions); } MPS_ARGS_END(args); diff --git a/mps/code/arena.c b/mps/code/arena.c index e5d2901683e..4206ec9ab72 100644 --- a/mps/code/arena.c +++ b/mps/code/arena.c @@ -207,9 +207,9 @@ Res ArenaInit(Arena arena, ArenaClass class, Size grainSize, ArgList args) if (ArgPick(&arg, args, MPS_KEY_ARENA_ZONED)) zoned = arg.val.b; - if (ArgPick(&arg, args, MPS_KEY_ARENA_COMMIT_LIMIT)) + if (ArgPick(&arg, args, MPS_KEY_COMMIT_LIMIT)) commitLimit = arg.val.size; - if (ArgPick(&arg, args, MPS_KEY_ARENA_SPARE_COMMIT_LIMIT)) + if (ArgPick(&arg, args, MPS_KEY_SPARE_COMMIT_LIMIT)) spareCommitLimit = arg.val.size; arena->class = class; @@ -289,11 +289,11 @@ ARG_DEFINE_KEY(VMW3_TOP_DOWN, Bool); /* ArenaCreate -- create the arena and call initializers */ -ARG_DEFINE_KEY(ARENA_COMMIT_LIMIT, Size); ARG_DEFINE_KEY(ARENA_GRAIN_SIZE, Size); ARG_DEFINE_KEY(ARENA_SIZE, Size); -ARG_DEFINE_KEY(ARENA_SPARE_COMMIT_LIMIT, Size); ARG_DEFINE_KEY(ARENA_ZONED, Bool); +ARG_DEFINE_KEY(COMMIT_LIMIT, Size); +ARG_DEFINE_KEY(SPARE_COMMIT_LIMIT, Size); static Res arenaFreeLandInit(Arena arena) { @@ -395,13 +395,13 @@ Res ArenaConfigure(Arena arena, ArgList args) AVERT(Arena, arena); AVERT(ArgList, args); - if (ArgPick(&arg, args, MPS_KEY_ARENA_COMMIT_LIMIT)) { + if (ArgPick(&arg, args, MPS_KEY_COMMIT_LIMIT)) { Size limit = arg.val.size; res = ArenaSetCommitLimit(arena, limit); if (res != ResOK) return res; } - if (ArgPick(&arg, args, MPS_KEY_ARENA_SPARE_COMMIT_LIMIT)) { + if (ArgPick(&arg, args, MPS_KEY_SPARE_COMMIT_LIMIT)) { Size limit = arg.val.size; (void)ArenaSetSpareCommitLimit(arena, limit); } diff --git a/mps/code/locusss.c b/mps/code/locusss.c index 742e5ee779b..b3769dd674a 100644 --- a/mps/code/locusss.c +++ b/mps/code/locusss.c @@ -219,7 +219,7 @@ static void runArenaTest(size_t size, MPS_ARGS_BEGIN(args) { MPS_ARGS_ADD(args, MPS_KEY_ARENA_SIZE, size); MPS_ARGS_ADD(args, MPS_KEY_ARENA_ZONED, FALSE); - MPS_ARGS_ADD(args, MPS_KEY_ARENA_COMMIT_LIMIT, size - chunkSize); + MPS_ARGS_ADD(args, MPS_KEY_COMMIT_LIMIT, size - chunkSize); die(mps_arena_create_k(&arena, mps_arena_class_vm(), args), "mps_arena_create"); } MPS_ARGS_END(args); diff --git a/mps/code/mps.h b/mps/code/mps.h index b8882335581..10207eb6e94 100644 --- a/mps/code/mps.h +++ b/mps/code/mps.h @@ -155,18 +155,12 @@ extern const struct mps_key_s _mps_key_ARGS_END; #define MPS_KEY_ARGS_END (&_mps_key_ARGS_END) extern mps_arg_s mps_args_none[]; -extern const struct mps_key_s _mps_key_ARENA_COMMIT_LIMIT; -#define MPS_KEY_ARENA_COMMIT_LIMIT (&_mps_key_ARENA_COMMIT_LIMIT) -#define MPS_KEY_ARENA_COMMIT_LIMIT_FIELD size extern const struct mps_key_s _mps_key_ARENA_GRAIN_SIZE; #define MPS_KEY_ARENA_GRAIN_SIZE (&_mps_key_ARENA_GRAIN_SIZE) #define MPS_KEY_ARENA_GRAIN_SIZE_FIELD size extern const struct mps_key_s _mps_key_ARENA_SIZE; #define MPS_KEY_ARENA_SIZE (&_mps_key_ARENA_SIZE) #define MPS_KEY_ARENA_SIZE_FIELD size -extern const struct mps_key_s _mps_key_ARENA_SPARE_COMMIT_LIMIT; -#define MPS_KEY_ARENA_SPARE_COMMIT_LIMIT (&_mps_key_ARENA_SPARE_COMMIT_LIMIT) -#define MPS_KEY_ARENA_SPARE_COMMIT_LIMIT_FIELD size extern const struct mps_key_s _mps_key_ARENA_ZONED; #define MPS_KEY_ARENA_ZONED (&_mps_key_ARENA_ZONED) #define MPS_KEY_ARENA_ZONED_FIELD b @@ -182,6 +176,12 @@ extern const struct mps_key_s _mps_key_GEN; extern const struct mps_key_s _mps_key_RANK; #define MPS_KEY_RANK (&_mps_key_RANK) #define MPS_KEY_RANK_FIELD rank +extern const struct mps_key_s _mps_key_COMMIT_LIMIT; +#define MPS_KEY_COMMIT_LIMIT (&_mps_key_COMMIT_LIMIT) +#define MPS_KEY_COMMIT_LIMIT_FIELD size +extern const struct mps_key_s _mps_key_SPARE_COMMIT_LIMIT; +#define MPS_KEY_SPARE_COMMIT_LIMIT (&_mps_key_SPARE_COMMIT_LIMIT) +#define MPS_KEY_SPARE_COMMIT_LIMIT_FIELD size extern const struct mps_key_s _mps_key_EXTEND_BY; #define MPS_KEY_EXTEND_BY (&_mps_key_EXTEND_BY) diff --git a/mps/code/mpsicv.c b/mps/code/mpsicv.c index 9f546c8678c..c1ea620c810 100644 --- a/mps/code/mpsicv.c +++ b/mps/code/mpsicv.c @@ -348,7 +348,7 @@ static void arena_commit_test(mps_arena_t arena) } while (res == MPS_RES_OK); die_expect(res, MPS_RES_COMMIT_LIMIT, "Commit limit allocation"); MPS_ARGS_BEGIN(args) { - MPS_ARGS_ADD(args, MPS_KEY_ARENA_COMMIT_LIMIT, limit); + MPS_ARGS_ADD(args, MPS_KEY_COMMIT_LIMIT, limit); die(mps_arena_configure(arena, args), "commit_limit_set after"); } MPS_ARGS_END(args); res = mps_alloc(&p, pool, FILLER_OBJECT_SIZE); diff --git a/mps/manual/source/release.rst b/mps/manual/source/release.rst index b7f580c7286..5a862a6bc47 100644 --- a/mps/manual/source/release.rst +++ b/mps/manual/source/release.rst @@ -18,9 +18,9 @@ New features requests from the :term:`arena`. #. The function :c:func:`mps_arena_create_k` accepts two new - :term:`keyword arguments`. :c:macro:`MPS_KEY_ARENA_COMMIT_LIMIT` + :term:`keyword arguments`. :c:macro:`MPS_KEY_COMMIT_LIMIT` sets the :term:`commit limit` for the arena, and - :c:macro:`MPS_KEY_ARENA_SPARE_COMMIT_LIMIT` sets the :term:`spare + :c:macro:`MPS_KEY_SPARE_COMMIT_LIMIT` sets the :term:`spare commit limit` for the arena. #. The new function :c:func:`mps_arena_configure` provides a diff --git a/mps/manual/source/topic/arena.rst b/mps/manual/source/topic/arena.rst index 29d942a29f2..7c9f580adde 100644 --- a/mps/manual/source/topic/arena.rst +++ b/mps/manual/source/topic/arena.rst @@ -154,7 +154,7 @@ Client arenas It also accepts two optional keyword arguments: - * :c:macro:`MPS_KEY_ARENA_COMMIT_LIMIT` (type :c:type:`size_t`) is + * :c:macro:`MPS_KEY_COMMIT_LIMIT` (type :c:type:`size_t`) is the maximum amount of memory, in :term:`bytes (1)`, that the MPS will use out of the provided chunk (or chunks, if the arena is extended). See :c:func:`mps_arena_commit_limit` for details. The @@ -188,7 +188,7 @@ Client arenas When configuring a client arena, :c:func:`mps_arena_configure` accepts the :term:`keyword argument` - :c:macro:`MPS_KEY_ARENA_COMMIT_LIMIT` as described above. + :c:macro:`MPS_KEY_COMMIT_LIMIT` as described above. .. c:function:: mps_res_t mps_arena_extend(mps_arena_t arena, mps_addr_t base, size_t size) @@ -257,7 +257,7 @@ Virtual memory arenas more times it has to extend its address space, the less efficient garbage collection will become. - * :c:macro:`MPS_KEY_ARENA_COMMIT_LIMIT` (type :c:type:`size_t`) is + * :c:macro:`MPS_KEY_COMMIT_LIMIT` (type :c:type:`size_t`) is the maximum amount of main memory, in :term:`bytes (1)`, that the MPS will obtain from the operating system. See :c:func:`mps_arena_commit_limit` for details. The default commit @@ -274,7 +274,7 @@ Virtual memory arenas that's smaller than the operating system page size, the MPS rounds it up to the page size and continues. - * :c:macro:`MPS_KEY_ARENA_SPARE_COMMIT_LIMIT` (type + * :c:macro:`MPS_KEY_SPARE_COMMIT_LIMIT` (type :c:type:`size_t`, default 0) is the spare commit limit in :term:`bytes (1)`. See :c:func:`mps_arena_spare_commit_limit` for details. @@ -314,8 +314,8 @@ Virtual memory arenas When configuring a virtual memory arena, :c:func:`mps_arena_configure` accepts the :term:`keyword - arguments` :c:macro:`MPS_KEY_ARENA_COMMIT_LIMIT` and - :c:macro:`MPS_KEY_ARENA_SPARE_COMMIT_LIMIT` as described above. + arguments` :c:macro:`MPS_KEY_COMMIT_LIMIT` and + :c:macro:`MPS_KEY_SPARE_COMMIT_LIMIT` as described above. .. index:: @@ -350,7 +350,7 @@ Arena properties virtual memory interface. The commit limit can be changed by passing the - :c:macro:`MPS_KEY_ARENA_COMMIT_LIMIT` :term:`keyword argument` to + :c:macro:`MPS_KEY_COMMIT_LIMIT` :term:`keyword argument` to :c:func:`mps_arena_create_k` or :c:func:`mps_arena_configure`. The commit limit cannot be set to a value that is lower than the number of bytes that the MPS is using. If an attempt is made to @@ -470,7 +470,7 @@ Arena properties the MPS is allowed to have. The spare commit limit can be changed by passing the - :c:macro:`MPS_KEY_ARENA_SPARE_COMMIT_LIMIT` :term:`keyword + :c:macro:`MPS_KEY_SPARE_COMMIT_LIMIT` :term:`keyword argument` to :c:func:`mps_arena_create_k` or :c:func:`mps_arena_configure`. Setting it to a value lower than the current amount of spare committed memory causes spare @@ -499,7 +499,7 @@ Arena properties :c:func:`mps_arena_commit_limit`. The amount of "spare committed" memory can be limited passing the - :c:macro:`MPS_KEY_ARENA_SPARE_COMMIT_LIMIT` :term:`keyword + :c:macro:`MPS_KEY_SPARE_COMMIT_LIMIT` :term:`keyword argument` to :c:func:`mps_arena_create_k` or :c:func:`mps_arena_configure`. The value of the limit can be retrieved with :c:func:`mps_arena_spare_commit_limit`. This is diff --git a/mps/manual/source/topic/deprecated.rst b/mps/manual/source/topic/deprecated.rst index 329f90d48dc..5a3f9900bf1 100644 --- a/mps/manual/source/topic/deprecated.rst +++ b/mps/manual/source/topic/deprecated.rst @@ -29,7 +29,7 @@ Deprecated in version 1.115 .. deprecated:: - Pass the :c:macro:`MPS_KEY_ARENA_COMMIT_LIMIT` :term:`keyword + Pass the :c:macro:`MPS_KEY_COMMIT_LIMIT` :term:`keyword argument` to :c:func:`mps_arena_create_k` or :c:func:`mps_arena_configure`. diff --git a/mps/manual/source/topic/keyword.rst b/mps/manual/source/topic/keyword.rst index 6d321eab491..a2d100d1672 100644 --- a/mps/manual/source/topic/keyword.rst +++ b/mps/manual/source/topic/keyword.rst @@ -82,45 +82,45 @@ now :c:macro:`MPS_KEY_ARGS_END`. The type of :term:`keyword argument` keys. Must take one of the following values: - =========================================== ========================================================= ========================================================== - Keyword Type & field in ``arg.val`` See - =========================================== ========================================================= ========================================================== - :c:macro:`MPS_KEY_ARGS_END` *none* *see above* - :c:macro:`MPS_KEY_ALIGN` :c:type:`mps_align_t` ``align`` :c:func:`mps_class_mv`, :c:func:`mps_class_mvff`, :c:func:`mps_class_mvt` - :c:macro:`MPS_KEY_AMS_SUPPORT_AMBIGUOUS` :c:type:`mps_bool_t` ``b`` :c:func:`mps_class_ams` - :c:macro:`MPS_KEY_ARENA_CL_BASE` :c:type:`mps_addr_t` ``addr`` :c:func:`mps_arena_class_cl` - :c:macro:`MPS_KEY_ARENA_COMMIT_LIMIT` :c:type:`size_t` ``size`` :c:func:`mps_arena_class_vm`, :c:func:`mps_arena_class_cl` - :c:macro:`MPS_KEY_ARENA_GRAIN_SIZE` :c:type:`size_t` ``size`` :c:func:`mps_arena_class_vm`, :c:func:`mps_arena_class_cl` - :c:macro:`MPS_KEY_ARENA_SIZE` :c:type:`size_t` ``size`` :c:func:`mps_arena_class_vm`, :c:func:`mps_arena_class_cl` - :c:macro:`MPS_KEY_ARENA_SPARE_COMMIT_LIMIT` :c:type:`size_t` ``size`` :c:func:`mps_arena_class_vm`, :c:func:`mps_arena_class_cl` - :c:macro:`MPS_KEY_AWL_FIND_DEPENDENT` ``void *(*)(void *)`` ``addr_method`` :c:func:`mps_class_awl` - :c:macro:`MPS_KEY_CHAIN` :c:type:`mps_chain_t` ``chain`` :c:func:`mps_class_amc`, :c:func:`mps_class_amcz`, :c:func:`mps_class_ams`, :c:func:`mps_class_awl`, :c:func:`mps_class_lo` - :c:macro:`MPS_KEY_EXTEND_BY` :c:type:`size_t` ``size`` :c:func:`mps_class_amc`, :c:func:`mps_class_amcz`, :c:func:`mps_class_mfs`, :c:func:`mps_class_mv`, :c:func:`mps_class_mvff` - :c:macro:`MPS_KEY_FMT_ALIGN` :c:type:`mps_align_t` ``align`` :c:func:`mps_fmt_create_k` - :c:macro:`MPS_KEY_FMT_CLASS` :c:type:`mps_fmt_class_t` ``fmt_class`` :c:func:`mps_fmt_create_k` - :c:macro:`MPS_KEY_FMT_FWD` :c:type:`mps_fmt_fwd_t` ``fmt_fwd`` :c:func:`mps_fmt_create_k` - :c:macro:`MPS_KEY_FMT_HEADER_SIZE` :c:type:`size_t` ``size`` :c:func:`mps_fmt_create_k` - :c:macro:`MPS_KEY_FMT_ISFWD` :c:type:`mps_fmt_isfwd_t` ``fmt_isfwd`` :c:func:`mps_fmt_create_k` - :c:macro:`MPS_KEY_FMT_PAD` :c:type:`mps_fmt_pad_t` ``fmt_pad`` :c:func:`mps_fmt_create_k` - :c:macro:`MPS_KEY_FMT_SCAN` :c:type:`mps_fmt_scan_t` ``fmt_scan`` :c:func:`mps_fmt_create_k` - :c:macro:`MPS_KEY_FMT_SKIP` :c:type:`mps_fmt_skip_t` ``fmt_skip`` :c:func:`mps_fmt_create_k` - :c:macro:`MPS_KEY_FORMAT` :c:type:`mps_fmt_t` ``format`` :c:func:`mps_class_amc`, :c:func:`mps_class_amcz`, :c:func:`mps_class_ams`, :c:func:`mps_class_awl`, :c:func:`mps_class_lo` , :c:func:`mps_class_snc` - :c:macro:`MPS_KEY_GEN` :c:type:`unsigned` ``u`` :c:func:`mps_class_ams`, :c:func:`mps_class_awl`, :c:func:`mps_class_lo` - :c:macro:`MPS_KEY_INTERIOR` :c:type:`mps_bool_t` ``b`` :c:func:`mps_class_amc`, :c:func:`mps_class_amcz` - :c:macro:`MPS_KEY_MAX_SIZE` :c:type:`size_t` ``size`` :c:func:`mps_class_mv` - :c:macro:`MPS_KEY_MEAN_SIZE` :c:type:`size_t` ``size`` :c:func:`mps_class_mv`, :c:func:`mps_class_mvt`, :c:func:`mps_class_mvff` - :c:macro:`MPS_KEY_MFS_UNIT_SIZE` :c:type:`size_t` ``size`` :c:func:`mps_class_mfs` - :c:macro:`MPS_KEY_MIN_SIZE` :c:type:`size_t` ``size`` :c:func:`mps_class_mvt` - :c:macro:`MPS_KEY_MVFF_ARENA_HIGH` :c:type:`mps_bool_t` ``b`` :c:func:`mps_class_mvff` - :c:macro:`MPS_KEY_MVFF_FIRST_FIT` :c:type:`mps_bool_t` ``b`` :c:func:`mps_class_mvff` - :c:macro:`MPS_KEY_MVFF_SLOT_HIGH` :c:type:`mps_bool_t` ``b`` :c:func:`mps_class_mvff` - :c:macro:`MPS_KEY_MVT_FRAG_LIMIT` :c:type:`mps_word_t` ``count`` :c:func:`mps_class_mvt` - :c:macro:`MPS_KEY_MVT_RESERVE_DEPTH` :c:type:`mps_word_t` ``count`` :c:func:`mps_class_mvt` - :c:macro:`MPS_KEY_POOL_DEBUG_OPTIONS` :c:type:`mps_pool_debug_option_s` ``*pool_debug_options`` :c:func:`mps_class_ams_debug`, :c:func:`mps_class_mv_debug`, :c:func:`mps_class_mvff_debug` - :c:macro:`MPS_KEY_RANK` :c:type:`mps_rank_t` ``rank`` :c:func:`mps_class_ams`, :c:func:`mps_class_awl`, :c:func:`mps_class_snc` - :c:macro:`MPS_KEY_SPARE` :c:type:`double` ``d`` :c:func:`mps_class_mvff` - :c:macro:`MPS_KEY_VMW3_TOP_DOWN` :c:type:`mps_bool_t` ``b`` :c:func:`mps_arena_class_vm` - =========================================== ========================================================= ========================================================== + ======================================== ========================================================= ========================================================== + Keyword Type & field in ``arg.val`` See + ======================================== ========================================================= ========================================================== + :c:macro:`MPS_KEY_ARGS_END` *none* *see above* + :c:macro:`MPS_KEY_ALIGN` :c:type:`mps_align_t` ``align`` :c:func:`mps_class_mv`, :c:func:`mps_class_mvff`, :c:func:`mps_class_mvt` + :c:macro:`MPS_KEY_AMS_SUPPORT_AMBIGUOUS` :c:type:`mps_bool_t` ``b`` :c:func:`mps_class_ams` + :c:macro:`MPS_KEY_ARENA_CL_BASE` :c:type:`mps_addr_t` ``addr`` :c:func:`mps_arena_class_cl` + :c:macro:`MPS_KEY_COMMIT_LIMIT` :c:type:`size_t` ``size`` :c:func:`mps_arena_class_vm`, :c:func:`mps_arena_class_cl` + :c:macro:`MPS_KEY_ARENA_GRAIN_SIZE` :c:type:`size_t` ``size`` :c:func:`mps_arena_class_vm`, :c:func:`mps_arena_class_cl` + :c:macro:`MPS_KEY_ARENA_SIZE` :c:type:`size_t` ``size`` :c:func:`mps_arena_class_vm`, :c:func:`mps_arena_class_cl` + :c:macro:`MPS_KEY_SPARE_COMMIT_LIMIT` :c:type:`size_t` ``size`` :c:func:`mps_arena_class_vm`, :c:func:`mps_arena_class_cl` + :c:macro:`MPS_KEY_AWL_FIND_DEPENDENT` ``void *(*)(void *)`` ``addr_method`` :c:func:`mps_class_awl` + :c:macro:`MPS_KEY_CHAIN` :c:type:`mps_chain_t` ``chain`` :c:func:`mps_class_amc`, :c:func:`mps_class_amcz`, :c:func:`mps_class_ams`, :c:func:`mps_class_awl`, :c:func:`mps_class_lo` + :c:macro:`MPS_KEY_EXTEND_BY` :c:type:`size_t` ``size`` :c:func:`mps_class_amc`, :c:func:`mps_class_amcz`, :c:func:`mps_class_mfs`, :c:func:`mps_class_mv`, :c:func:`mps_class_mvff` + :c:macro:`MPS_KEY_FMT_ALIGN` :c:type:`mps_align_t` ``align`` :c:func:`mps_fmt_create_k` + :c:macro:`MPS_KEY_FMT_CLASS` :c:type:`mps_fmt_class_t` ``fmt_class`` :c:func:`mps_fmt_create_k` + :c:macro:`MPS_KEY_FMT_FWD` :c:type:`mps_fmt_fwd_t` ``fmt_fwd`` :c:func:`mps_fmt_create_k` + :c:macro:`MPS_KEY_FMT_HEADER_SIZE` :c:type:`size_t` ``size`` :c:func:`mps_fmt_create_k` + :c:macro:`MPS_KEY_FMT_ISFWD` :c:type:`mps_fmt_isfwd_t` ``fmt_isfwd`` :c:func:`mps_fmt_create_k` + :c:macro:`MPS_KEY_FMT_PAD` :c:type:`mps_fmt_pad_t` ``fmt_pad`` :c:func:`mps_fmt_create_k` + :c:macro:`MPS_KEY_FMT_SCAN` :c:type:`mps_fmt_scan_t` ``fmt_scan`` :c:func:`mps_fmt_create_k` + :c:macro:`MPS_KEY_FMT_SKIP` :c:type:`mps_fmt_skip_t` ``fmt_skip`` :c:func:`mps_fmt_create_k` + :c:macro:`MPS_KEY_FORMAT` :c:type:`mps_fmt_t` ``format`` :c:func:`mps_class_amc`, :c:func:`mps_class_amcz`, :c:func:`mps_class_ams`, :c:func:`mps_class_awl`, :c:func:`mps_class_lo` , :c:func:`mps_class_snc` + :c:macro:`MPS_KEY_GEN` :c:type:`unsigned` ``u`` :c:func:`mps_class_ams`, :c:func:`mps_class_awl`, :c:func:`mps_class_lo` + :c:macro:`MPS_KEY_INTERIOR` :c:type:`mps_bool_t` ``b`` :c:func:`mps_class_amc`, :c:func:`mps_class_amcz` + :c:macro:`MPS_KEY_MAX_SIZE` :c:type:`size_t` ``size`` :c:func:`mps_class_mv` + :c:macro:`MPS_KEY_MEAN_SIZE` :c:type:`size_t` ``size`` :c:func:`mps_class_mv`, :c:func:`mps_class_mvt`, :c:func:`mps_class_mvff` + :c:macro:`MPS_KEY_MFS_UNIT_SIZE` :c:type:`size_t` ``size`` :c:func:`mps_class_mfs` + :c:macro:`MPS_KEY_MIN_SIZE` :c:type:`size_t` ``size`` :c:func:`mps_class_mvt` + :c:macro:`MPS_KEY_MVFF_ARENA_HIGH` :c:type:`mps_bool_t` ``b`` :c:func:`mps_class_mvff` + :c:macro:`MPS_KEY_MVFF_FIRST_FIT` :c:type:`mps_bool_t` ``b`` :c:func:`mps_class_mvff` + :c:macro:`MPS_KEY_MVFF_SLOT_HIGH` :c:type:`mps_bool_t` ``b`` :c:func:`mps_class_mvff` + :c:macro:`MPS_KEY_MVT_FRAG_LIMIT` :c:type:`mps_word_t` ``count`` :c:func:`mps_class_mvt` + :c:macro:`MPS_KEY_MVT_RESERVE_DEPTH` :c:type:`mps_word_t` ``count`` :c:func:`mps_class_mvt` + :c:macro:`MPS_KEY_POOL_DEBUG_OPTIONS` :c:type:`mps_pool_debug_option_s` ``*pool_debug_options`` :c:func:`mps_class_ams_debug`, :c:func:`mps_class_mv_debug`, :c:func:`mps_class_mvff_debug` + :c:macro:`MPS_KEY_RANK` :c:type:`mps_rank_t` ``rank`` :c:func:`mps_class_ams`, :c:func:`mps_class_awl`, :c:func:`mps_class_snc` + :c:macro:`MPS_KEY_SPARE` :c:type:`double` ``d`` :c:func:`mps_class_mvff` + :c:macro:`MPS_KEY_VMW3_TOP_DOWN` :c:type:`mps_bool_t` ``b`` :c:func:`mps_arena_class_vm` + ======================================== ========================================================= ========================================================== .. c:function:: MPS_ARGS_BEGIN(args) diff --git a/mps/test/function/120.c b/mps/test/function/120.c index 77609e3e37f..032fa722c3f 100644 --- a/mps/test/function/120.c +++ b/mps/test/function/120.c @@ -41,7 +41,7 @@ static void test(void) { * RES_COMMIT_LIMIT. */ MPS_ARGS_BEGIN(args) { - MPS_ARGS_ADD(args, MPS_KEY_ARENA_COMMIT_LIMIT, 16 * 1024); + MPS_ARGS_ADD(args, MPS_KEY_COMMIT_LIMIT, 16 * 1024); report_res("create", mps_arena_create_k(&arena, mps_arena_class_vm(), args)); } MPS_ARGS_END(args); diff --git a/mps/test/function/165.c b/mps/test/function/165.c index e542cc111a7..da0734ba279 100644 --- a/mps/test/function/165.c +++ b/mps/test/function/165.c @@ -37,7 +37,7 @@ static void test(void) MPS_ARGS_BEGIN(args) { MPS_ARGS_ADD(args, MPS_KEY_ARENA_SIZE, 1024*1024*40); - MPS_ARGS_ADD(args, MPS_KEY_ARENA_COMMIT_LIMIT, 1024ul*1024ul*100ul); + MPS_ARGS_ADD(args, MPS_KEY_COMMIT_LIMIT, 1024ul*1024ul*100ul); cdie(mps_arena_create_k(&arena, mps_arena_class_vm(), args), "create arena"); } MPS_ARGS_END(args); @@ -60,7 +60,7 @@ static void test(void) /* Set the spare commit limit to 0MB */ MPS_ARGS_BEGIN(args) { - MPS_ARGS_ADD(args, MPS_KEY_ARENA_SPARE_COMMIT_LIMIT, 0); + MPS_ARGS_ADD(args, MPS_KEY_SPARE_COMMIT_LIMIT, 0); cdie(mps_arena_configure(arena, args), "mps_arena_configure"); } MPS_ARGS_END(args); die(mps_alloc(&objs[0], pool, BIGSIZE), "alloc"); @@ -75,7 +75,7 @@ static void test(void) /* nb. size_t unsigned, therefore (size_t)-1 is the maximum limit */ MPS_ARGS_BEGIN(args) { - MPS_ARGS_ADD(args, MPS_KEY_ARENA_SPARE_COMMIT_LIMIT, -1); + MPS_ARGS_ADD(args, MPS_KEY_SPARE_COMMIT_LIMIT, -1); cdie(mps_arena_configure(arena, args), "mps_arena_configure"); } MPS_ARGS_END(args); die(mps_alloc(&objs[0], pool, BIGSIZE), "alloc"); @@ -88,7 +88,7 @@ static void test(void) /* Reducing the spare committed limit should return most of the spare */ MPS_ARGS_BEGIN(args) { - MPS_ARGS_ADD(args, MPS_KEY_ARENA_SPARE_COMMIT_LIMIT, 1024*1024); + MPS_ARGS_ADD(args, MPS_KEY_SPARE_COMMIT_LIMIT, 1024*1024); cdie(mps_arena_configure(arena, args), "mps_arena_configure"); } MPS_ARGS_END(args); com2 = mps_arena_committed(arena); diff --git a/mps/test/function/231.c b/mps/test/function/231.c index e0620fd09b3..ac13e02d4a1 100644 --- a/mps/test/function/231.c +++ b/mps/test/function/231.c @@ -19,7 +19,7 @@ static void test(void) mps_arena_t arena; MPS_ARGS_BEGIN(args) { - MPS_ARGS_ADD(args, MPS_KEY_ARENA_COMMIT_LIMIT, 16 * 1024); + MPS_ARGS_ADD(args, MPS_KEY_COMMIT_LIMIT, 16 * 1024); report_res("create1", mps_arena_create_k(&arena, mps_arena_class_vm(), args)); } MPS_ARGS_END(args); @@ -28,7 +28,7 @@ static void test(void) mps_arena_create_k(&arena, mps_arena_class_vm(), mps_args_none)); MPS_ARGS_BEGIN(args) { - MPS_ARGS_ADD(args, MPS_KEY_ARENA_COMMIT_LIMIT, 16 * 1024); + MPS_ARGS_ADD(args, MPS_KEY_COMMIT_LIMIT, 16 * 1024); report_res("configure", mps_arena_configure(arena, args)); } MPS_ARGS_END(args); From 5d3379f84c44cf7a723ac2fac9353766bda77553 Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Tue, 8 Sep 2015 16:36:48 +0100 Subject: [PATCH 07/11] Add a return value to arenasetsparecommitlimit, as suggested by nb in review. Copied from Perforce Change: 188287 ServerID: perforce.ravenbrook.com --- mps/code/arena.c | 8 +++++--- mps/code/mpm.h | 2 +- mps/code/mpsi.c | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/mps/code/arena.c b/mps/code/arena.c index 4206ec9ab72..a317f16343e 100644 --- a/mps/code/arena.c +++ b/mps/code/arena.c @@ -403,7 +403,9 @@ Res ArenaConfigure(Arena arena, ArgList args) } if (ArgPick(&arg, args, MPS_KEY_SPARE_COMMIT_LIMIT)) { Size limit = arg.val.size; - (void)ArenaSetSpareCommitLimit(arena, limit); + res = ArenaSetSpareCommitLimit(arena, limit); + if (res != ResOK) + return res; } return (*arena->class->configure)(arena, args); @@ -1339,7 +1341,7 @@ Size ArenaSpareCommitLimit(Arena arena) return arena->spareCommitLimit; } -void ArenaSetSpareCommitLimit(Arena arena, Size limit) +Res ArenaSetSpareCommitLimit(Arena arena, Size limit) { AVERT(Arena, arena); /* Can't check limit, as all possible values are allowed. */ @@ -1351,7 +1353,7 @@ void ArenaSetSpareCommitLimit(Arena arena, Size limit) } EVENT2(SpareCommitLimitSet, arena, limit); - return; + return ResOK; } /* Used by arenas which don't use spare committed memory */ diff --git a/mps/code/mpm.h b/mps/code/mpm.h index ae528e784d8..2a8482ad95e 100644 --- a/mps/code/mpm.h +++ b/mps/code/mpm.h @@ -620,7 +620,7 @@ extern Size ArenaSpareCommitted(Arena arena); extern Size ArenaCommitLimit(Arena arena); extern Res ArenaSetCommitLimit(Arena arena, Size limit); extern Size ArenaSpareCommitLimit(Arena arena); -extern void ArenaSetSpareCommitLimit(Arena arena, Size limit); +extern Res ArenaSetSpareCommitLimit(Arena arena, Size limit); extern Size ArenaNoPurgeSpare(Arena arena, Size size); extern Res ArenaNoGrow(Arena arena, LocusPref pref, Size size); diff --git a/mps/code/mpsi.c b/mps/code/mpsi.c index 8ee89ac3923..d9bdc80da8d 100644 --- a/mps/code/mpsi.c +++ b/mps/code/mpsi.c @@ -204,7 +204,7 @@ mps_res_t mps_arena_commit_limit_set(mps_arena_t arena, size_t limit) void mps_arena_spare_commit_limit_set(mps_arena_t arena, size_t limit) { ArenaEnter(arena); - ArenaSetSpareCommitLimit(arena, limit); + (void)ArenaSetSpareCommitLimit(arena, limit); ArenaLeave(arena); return; From 012de550deb8f277cf77080c8f6d4adbf14dfbe8 Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Tue, 8 Sep 2015 16:38:55 +0100 Subject: [PATCH 08/11] Alphabetize list of keywords; spare commit limit does not do anything for the client arena. Copied from Perforce Change: 188288 ServerID: perforce.ravenbrook.com --- mps/design/arena.txt | 14 +++++++------- mps/manual/source/topic/keyword.rst | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/mps/design/arena.txt b/mps/design/arena.txt index a72bfbcb09c..2a94bb05b39 100644 --- a/mps/design/arena.txt +++ b/mps/design/arena.txt @@ -432,13 +432,13 @@ bytes; ``spareCommitLimit`` records the limit (set by the user) on the amount of spare committed memory. ``spareCommitted`` is modified by the arena class but its value is used by the generic arena code. There are two uses: a getter function for this value is provided through the -MPS interface (``mps_arena_spare_commit_limit_set()``), and by the -``SetSpareCommitLimit()`` function to determine whether the amount of -spare committed memory needs to be reduced. ``spareCommitLimit`` is -manipulated by generic arena code, however the associated semantics -are the responsibility of the class. It is the class's responsibility -to ensure that it doesn't use more spare committed bytes than the -value in ``spareCommitLimit``. +MPS interface (``mps_arena_spare_commit_limit()``), and by the +``ArenaSetSpareCommitLimit()`` function to determine whether the +amount of spare committed memory needs to be reduced. +``spareCommitLimit`` is manipulated by generic arena code, however the +associated semantics are the responsibility of the class. It is the +class's responsibility to ensure that it doesn't use more spare +committed bytes than the value in ``spareCommitLimit``. _`.spare-commit-limit`: The function ``ArenaSetSpareCommitLimit()`` sets the ``spareCommitLimit`` field. If the limit is set to a value lower diff --git a/mps/manual/source/topic/keyword.rst b/mps/manual/source/topic/keyword.rst index a2d100d1672..ddbfbfd57ac 100644 --- a/mps/manual/source/topic/keyword.rst +++ b/mps/manual/source/topic/keyword.rst @@ -89,12 +89,11 @@ now :c:macro:`MPS_KEY_ARGS_END`. :c:macro:`MPS_KEY_ALIGN` :c:type:`mps_align_t` ``align`` :c:func:`mps_class_mv`, :c:func:`mps_class_mvff`, :c:func:`mps_class_mvt` :c:macro:`MPS_KEY_AMS_SUPPORT_AMBIGUOUS` :c:type:`mps_bool_t` ``b`` :c:func:`mps_class_ams` :c:macro:`MPS_KEY_ARENA_CL_BASE` :c:type:`mps_addr_t` ``addr`` :c:func:`mps_arena_class_cl` - :c:macro:`MPS_KEY_COMMIT_LIMIT` :c:type:`size_t` ``size`` :c:func:`mps_arena_class_vm`, :c:func:`mps_arena_class_cl` :c:macro:`MPS_KEY_ARENA_GRAIN_SIZE` :c:type:`size_t` ``size`` :c:func:`mps_arena_class_vm`, :c:func:`mps_arena_class_cl` :c:macro:`MPS_KEY_ARENA_SIZE` :c:type:`size_t` ``size`` :c:func:`mps_arena_class_vm`, :c:func:`mps_arena_class_cl` - :c:macro:`MPS_KEY_SPARE_COMMIT_LIMIT` :c:type:`size_t` ``size`` :c:func:`mps_arena_class_vm`, :c:func:`mps_arena_class_cl` :c:macro:`MPS_KEY_AWL_FIND_DEPENDENT` ``void *(*)(void *)`` ``addr_method`` :c:func:`mps_class_awl` :c:macro:`MPS_KEY_CHAIN` :c:type:`mps_chain_t` ``chain`` :c:func:`mps_class_amc`, :c:func:`mps_class_amcz`, :c:func:`mps_class_ams`, :c:func:`mps_class_awl`, :c:func:`mps_class_lo` + :c:macro:`MPS_KEY_COMMIT_LIMIT` :c:type:`size_t` ``size`` :c:func:`mps_arena_class_vm`, :c:func:`mps_arena_class_cl` :c:macro:`MPS_KEY_EXTEND_BY` :c:type:`size_t` ``size`` :c:func:`mps_class_amc`, :c:func:`mps_class_amcz`, :c:func:`mps_class_mfs`, :c:func:`mps_class_mv`, :c:func:`mps_class_mvff` :c:macro:`MPS_KEY_FMT_ALIGN` :c:type:`mps_align_t` ``align`` :c:func:`mps_fmt_create_k` :c:macro:`MPS_KEY_FMT_CLASS` :c:type:`mps_fmt_class_t` ``fmt_class`` :c:func:`mps_fmt_create_k` @@ -119,6 +118,7 @@ now :c:macro:`MPS_KEY_ARGS_END`. :c:macro:`MPS_KEY_POOL_DEBUG_OPTIONS` :c:type:`mps_pool_debug_option_s` ``*pool_debug_options`` :c:func:`mps_class_ams_debug`, :c:func:`mps_class_mv_debug`, :c:func:`mps_class_mvff_debug` :c:macro:`MPS_KEY_RANK` :c:type:`mps_rank_t` ``rank`` :c:func:`mps_class_ams`, :c:func:`mps_class_awl`, :c:func:`mps_class_snc` :c:macro:`MPS_KEY_SPARE` :c:type:`double` ``d`` :c:func:`mps_class_mvff` + :c:macro:`MPS_KEY_SPARE_COMMIT_LIMIT` :c:type:`size_t` ``size`` :c:func:`mps_arena_class_vm` :c:macro:`MPS_KEY_VMW3_TOP_DOWN` :c:type:`mps_bool_t` ``b`` :c:func:`mps_arena_class_vm` ======================================== ========================================================= ========================================================== From 1cd22e39b273906aa507235dda8680c97b7c5d2e Mon Sep 17 00:00:00 2001 From: Richard Brooksby Date: Sat, 30 Jan 2016 20:16:30 +0000 Subject: [PATCH 09/11] Removing arena configure method from arena classes. Copied from Perforce Change: 189080 ServerID: perforce.ravenbrook.com --- mps/code/arena.c | 2 +- mps/code/arenacl.c | 11 ----------- mps/code/arenavm.c | 11 ----------- mps/code/mpmst.h | 1 - mps/code/mpmtypes.h | 1 - 5 files changed, 1 insertion(+), 25 deletions(-) diff --git a/mps/code/arena.c b/mps/code/arena.c index a317f16343e..ed959d04ff7 100644 --- a/mps/code/arena.c +++ b/mps/code/arena.c @@ -408,7 +408,7 @@ Res ArenaConfigure(Arena arena, ArgList args) return res; } - return (*arena->class->configure)(arena, args); + return ResOK; } diff --git a/mps/code/arenacl.c b/mps/code/arenacl.c index b5837d0b3d9..cd5c24fe46a 100644 --- a/mps/code/arenacl.c +++ b/mps/code/arenacl.c @@ -324,16 +324,6 @@ failChunkCreate: } -/* ClientArenaConfigure -- configure the arena */ - -static Res ClientArenaConfigure(Arena arena, ArgList args) -{ - UNUSED(arena); - UNUSED(args); - return ResOK; -} - - /* ClientArenaFinish -- finish the arena */ static void ClientArenaFinish(Arena arena) @@ -467,7 +457,6 @@ DEFINE_ARENA_CLASS(ClientArenaClass, this) this->offset = offsetof(ClientArenaStruct, arenaStruct); this->varargs = ClientArenaVarargs; this->init = ClientArenaInit; - this->configure = ClientArenaConfigure; this->finish = ClientArenaFinish; this->extend = ClientArenaExtend; this->pagesMarkAllocated = ClientArenaPagesMarkAllocated; diff --git a/mps/code/arenavm.c b/mps/code/arenavm.c index 8dff04b463c..ba34a7c70ef 100644 --- a/mps/code/arenavm.c +++ b/mps/code/arenavm.c @@ -619,16 +619,6 @@ failVMInit: } -/* VMArenaConfigure -- configure the arena */ - -static Res VMArenaConfigure(Arena arena, ArgList args) -{ - UNUSED(arena); - UNUSED(args); - return ResOK; -} - - /* VMArenaFinish -- finish the arena */ static void VMArenaFinish(Arena arena) @@ -1204,7 +1194,6 @@ DEFINE_ARENA_CLASS(VMArenaClass, this) this->offset = offsetof(VMArenaStruct, arenaStruct); this->varargs = VMArenaVarargs; this->init = VMArenaInit; - this->configure = VMArenaConfigure; this->finish = VMArenaFinish; this->purgeSpare = VMPurgeSpare; this->grow = VMArenaGrow; diff --git a/mps/code/mpmst.h b/mps/code/mpmst.h index ac5c12c1498..d212e0e3307 100644 --- a/mps/code/mpmst.h +++ b/mps/code/mpmst.h @@ -525,7 +525,6 @@ typedef struct mps_arena_class_s { size_t offset; /* offset of generic struct in outer struct */ ArenaVarargsMethod varargs; ArenaInitMethod init; - ArenaConfigureMethod configure; ArenaFinishMethod finish; ArenaPurgeSpareMethod purgeSpare; ArenaExtendMethod extend; diff --git a/mps/code/mpmtypes.h b/mps/code/mpmtypes.h index 3a494760cb6..a6030e4c1e5 100644 --- a/mps/code/mpmtypes.h +++ b/mps/code/mpmtypes.h @@ -119,7 +119,6 @@ typedef unsigned FindDelete; /* */ typedef void (*ArenaVarargsMethod)(ArgStruct args[], va_list varargs); typedef Res (*ArenaInitMethod)(Arena *arenaReturn, ArenaClass class, ArgList args); -typedef Res (*ArenaConfigureMethod)(Arena arena, ArgList args); typedef void (*ArenaFinishMethod)(Arena arena); typedef Size (*ArenaPurgeSpareMethod)(Arena arena, Size size); typedef Res (*ArenaExtendMethod)(Arena arena, Addr base, Size size); From d4e54ba17ecf481d8b5307acef68ad655b16d977 Mon Sep 17 00:00:00 2001 From: Richard Brooksby Date: Wed, 3 Feb 2016 15:33:03 +0000 Subject: [PATCH 10/11] Backing out the introduction of mps_arena_configure. see . Copied from Perforce Change: 189081 ServerID: perforce.ravenbrook.com --- mps/code/arena.c | 27 ---------- mps/code/mpm.h | 1 - mps/code/mps.h | 1 - mps/code/mpsi.c | 14 ------ mps/code/mpsicv.c | 7 +-- mps/manual/source/glossary/c.rst | 3 +- mps/manual/source/glossary/s.rst | 3 +- mps/manual/source/release.rst | 8 --- mps/manual/source/topic/arena.rst | 69 +++++++++++++++----------- mps/manual/source/topic/deprecated.rst | 35 ------------- mps/test/function/165.c | 15 ++---- mps/test/function/231.c | 5 +- 12 files changed, 48 insertions(+), 140 deletions(-) diff --git a/mps/code/arena.c b/mps/code/arena.c index ed959d04ff7..94dd0044733 100644 --- a/mps/code/arena.c +++ b/mps/code/arena.c @@ -385,33 +385,6 @@ failInit: } -/* ArenaConfigure -- configure an arena */ - -Res ArenaConfigure(Arena arena, ArgList args) -{ - Res res; - mps_arg_s arg; - - AVERT(Arena, arena); - AVERT(ArgList, args); - - if (ArgPick(&arg, args, MPS_KEY_COMMIT_LIMIT)) { - Size limit = arg.val.size; - res = ArenaSetCommitLimit(arena, limit); - if (res != ResOK) - return res; - } - if (ArgPick(&arg, args, MPS_KEY_SPARE_COMMIT_LIMIT)) { - Size limit = arg.val.size; - res = ArenaSetSpareCommitLimit(arena, limit); - if (res != ResOK) - return res; - } - - return ResOK; -} - - /* ArenaFinish -- finish the generic part of the arena * * .finish.caller: Unlike PoolFinish, this is called by the class finish diff --git a/mps/code/mpm.h b/mps/code/mpm.h index 05286a200d2..022064f3a2f 100644 --- a/mps/code/mpm.h +++ b/mps/code/mpm.h @@ -498,7 +498,6 @@ extern Bool ArenaClassCheck(ArenaClass class); extern Bool ArenaCheck(Arena arena); extern Res ArenaCreate(Arena *arenaReturn, ArenaClass class, ArgList args); -extern Res ArenaConfigure(Arena arena, ArgList args); extern void ArenaDestroy(Arena arena); extern Res ArenaInit(Arena arena, ArenaClass class, Size grainSize, ArgList args); diff --git a/mps/code/mps.h b/mps/code/mps.h index 10207eb6e94..d9e750417e0 100644 --- a/mps/code/mps.h +++ b/mps/code/mps.h @@ -439,7 +439,6 @@ extern mps_res_t mps_arena_create(mps_arena_t *, mps_arena_class_t, ...); extern mps_res_t mps_arena_create_v(mps_arena_t *, mps_arena_class_t, va_list); extern mps_res_t mps_arena_create_k(mps_arena_t *, mps_arena_class_t, mps_arg_s []); -extern mps_res_t mps_arena_configure(mps_arena_t, mps_arg_s []); extern void mps_arena_destroy(mps_arena_t); extern size_t mps_arena_reserved(mps_arena_t); diff --git a/mps/code/mpsi.c b/mps/code/mpsi.c index 112ab313c00..9d9d4986000 100644 --- a/mps/code/mpsi.c +++ b/mps/code/mpsi.c @@ -350,20 +350,6 @@ mps_res_t mps_arena_create_k(mps_arena_t *mps_arena_o, } -/* mps_arena_configure -- configure an arena object */ - -mps_res_t mps_arena_configure(mps_arena_t arena, mps_arg_s args[]) -{ - Res res; - - ArenaEnter(arena); - res = ArenaConfigure(arena, args); - ArenaLeave(arena); - - return (mps_res_t)res; -} - - /* mps_arena_destroy -- destroy an arena object */ void mps_arena_destroy(mps_arena_t arena) diff --git a/mps/code/mpsicv.c b/mps/code/mpsicv.c index c1ea620c810..29a81b174c8 100644 --- a/mps/code/mpsicv.c +++ b/mps/code/mpsicv.c @@ -320,7 +320,7 @@ static mps_res_t root_single(mps_ss_t ss, void *p, size_t s) * mps_arena_reserved * incidentally tests: * mps_alloc - * mps_arena_configure + * mps_arena_commit_limit_set * mps_class_mv * mps_pool_create * mps_pool_destroy @@ -347,10 +347,7 @@ static void arena_commit_test(mps_arena_t arena) res = mps_alloc(&p, pool, FILLER_OBJECT_SIZE); } while (res == MPS_RES_OK); die_expect(res, MPS_RES_COMMIT_LIMIT, "Commit limit allocation"); - MPS_ARGS_BEGIN(args) { - MPS_ARGS_ADD(args, MPS_KEY_COMMIT_LIMIT, limit); - die(mps_arena_configure(arena, args), "commit_limit_set after"); - } MPS_ARGS_END(args); + die(mps_arena_commit_limit_set(arena, limit), "commit_limit_set after"); res = mps_alloc(&p, pool, FILLER_OBJECT_SIZE); die_expect(res, MPS_RES_OK, "Allocation failed after raising commit_limit"); mps_pool_destroy(pool); diff --git a/mps/manual/source/glossary/c.rst b/mps/manual/source/glossary/c.rst index 23b2d960048..ffdf1899243 100644 --- a/mps/manual/source/glossary/c.rst +++ b/mps/manual/source/glossary/c.rst @@ -354,8 +354,7 @@ Memory Management Glossary: C The commit limit is a limit on the :term:`committed ` :term:`memory (2)` that the :term:`arena` will obtain from the operating system. It can be changed by - passing the :c:macro:`MPS_KEY_ARENA_COMMIT_LIMIT` - :term:`keyword argument` to :c:func:`mps_arena_configure`. + calling :c:func:`mps_arena_commit_limit_set`. committed (1) diff --git a/mps/manual/source/glossary/s.rst b/mps/manual/source/glossary/s.rst index b18c186fd23..dc9355f2a0f 100644 --- a/mps/manual/source/glossary/s.rst +++ b/mps/manual/source/glossary/s.rst @@ -467,8 +467,7 @@ Memory Management Glossary: S committed memory` that the MPS will obtain from the operating system. It can be retrieved by calling :c:func:`mps_arena_spare_commit_limit` and changed by - passing the :c:macro:`MPS_KEY_ARENA_SPARE_COMMIT_LIMIT` - :term:`keyword argument` to :c:func:`mps_arena_configure`. + calling :c:func:`mps_arena_spare_commit_limit_set`. spare committed memory diff --git a/mps/manual/source/release.rst b/mps/manual/source/release.rst index 5a862a6bc47..ad285d7adc6 100644 --- a/mps/manual/source/release.rst +++ b/mps/manual/source/release.rst @@ -23,10 +23,6 @@ New features :c:macro:`MPS_KEY_SPARE_COMMIT_LIMIT` sets the :term:`spare commit limit` for the arena. -#. The new function :c:func:`mps_arena_configure` provides a - :term:`keyword argument` interface for changing the properties of - an arena. - Interface changes ................. @@ -41,10 +37,6 @@ Interface changes deprecated in favour of the generic functions :c:func:`mps_pool_free_size` and :c:func:`mps_pool_total_size`. -#. The functions :c:func:`mps_arena_commit_limit_set` and - :c:func:`mps_arena_spare_commit_limit_set` are deprecated in favour - of :c:func:`mps_arena_configure`. - Other changes ............. diff --git a/mps/manual/source/topic/arena.rst b/mps/manual/source/topic/arena.rst index 7c9f580adde..f98de4ba56d 100644 --- a/mps/manual/source/topic/arena.rst +++ b/mps/manual/source/topic/arena.rst @@ -92,19 +92,6 @@ the way that they acquire the memory to be managed. :c:func:`mps_arena_destroy`. -.. c:function:: mps_res_t mps_arena_configure(mps_arena_t arena, mps_arg_s args[]) - - Configure an :term:`arena`. - - ``arena`` is the arena to configure. - - ``args`` are :term:`keyword arguments` specifying configuration - parameters. See the documentation for the arena class. - - Returns :c:macro:`MPS_RES_OK` if the arena was configured - successfully, or another :term:`result code` otherwise. - - .. c:function:: void mps_arena_destroy(mps_arena_t arena) Destroy an :term:`arena`. @@ -186,10 +173,6 @@ Client arenas Client arenas have no mechanism for returning unused memory. - When configuring a client arena, :c:func:`mps_arena_configure` - accepts the :term:`keyword argument` - :c:macro:`MPS_KEY_COMMIT_LIMIT` as described above. - .. c:function:: mps_res_t mps_arena_extend(mps_arena_t arena, mps_addr_t base, size_t size) @@ -312,11 +295,6 @@ Virtual memory arenas res = mps_arena_create_k(&arena, mps_arena_class_vm(), args); } MPS_ARGS_END(args); - When configuring a virtual memory arena, - :c:func:`mps_arena_configure` accepts the :term:`keyword - arguments` :c:macro:`MPS_KEY_COMMIT_LIMIT` and - :c:macro:`MPS_KEY_SPARE_COMMIT_LIMIT` as described above. - .. index:: single: arena; properties @@ -349,9 +327,10 @@ Arena properties memory that the MPS will map to RAM via the operating system's virtual memory interface. - The commit limit can be changed by passing the + The commit limit can be set by passing the :c:macro:`MPS_KEY_COMMIT_LIMIT` :term:`keyword argument` to - :c:func:`mps_arena_create_k` or :c:func:`mps_arena_configure`. The + :c:func:`mps_arena_create_k`. It can be changed by calling + :c:func:`mps_arena_commit_limit_set`. The commit limit cannot be set to a value that is lower than the number of bytes that the MPS is using. If an attempt is made to set the commit limit to a value greater than or equal to that @@ -376,6 +355,20 @@ Arena properties there is more committed memory than the commit limit. +.. c:function:: mps_res_t mps_arena_commit_limit_set(mps_arena_t arena, size_t limit) + + Change the :term:`commit limit` for an :term:`arena`. + + ``arena`` is the arena to change the commit limit for. + + ``limit`` is the new commit limit in :term:`bytes (1)`. + + Returns :c:macro:`MPS_RES_OK` if successful, or another + :term:`result code` if not. + + See :c:func:`mps_arena_spare_commit_limit` for details. + + .. c:function:: size_t mps_arena_committed(mps_arena_t arena) Return the total :term:`committed ` memory for an @@ -469,10 +462,11 @@ Arena properties use, neither by the :term:`client program`, or by the MPS itself) the MPS is allowed to have. - The spare commit limit can be changed by passing the + The spare commit limit can be set by passing the :c:macro:`MPS_KEY_SPARE_COMMIT_LIMIT` :term:`keyword - argument` to :c:func:`mps_arena_create_k` or - :c:func:`mps_arena_configure`. Setting it to a value lower than + argument` to :c:func:`mps_arena_create_k`. It can be changed + by calling :c:func:`mps_arena_spare_commit_limit_set`. + Setting it to a value lower than the current amount of spare committed memory causes spare committed memory to be uncommitted so as to bring the value under the limit. In particular, setting it to 0 will mean that the MPS @@ -500,8 +494,8 @@ Arena properties The amount of "spare committed" memory can be limited passing the :c:macro:`MPS_KEY_SPARE_COMMIT_LIMIT` :term:`keyword - argument` to :c:func:`mps_arena_create_k` or - :c:func:`mps_arena_configure`. The value of the limit can be + argument` to :c:func:`mps_arena_create_k` or by calling + :c:func:`mps_arena_spare_commit_limit_set`. The value of the limit can be retrieved with :c:func:`mps_arena_spare_commit_limit`. This is analogous to the functions for limiting the amount of :term:`committed ` memory. @@ -512,6 +506,23 @@ Arena properties so this function always returns 0. +.. c:function:: void mps_arena_spare_commit_limit_set(mps_arena_t arena, size_t limit) + + Change the :term:`spare commit limit` for an :term:`arena`. + + ``arena`` is the arena to change the spare commit limit for. + + ``limit`` is the new spare commit limit in :term:`bytes (1)`. + + Non-virtual-memory arena classes (for example, a :term:`client + arena`) do not have spare committed memory. For these arenas, this + function sets a value but has no other effect. + + Initially the spare commit limit is a configuration-dependent + value. The value of the limit can be retrieved by the function + :c:func:`mps_arena_spare_commit_limit`. + + .. index:: single: arena; states diff --git a/mps/manual/source/topic/deprecated.rst b/mps/manual/source/topic/deprecated.rst index 5a3f9900bf1..dfd4d8d74cb 100644 --- a/mps/manual/source/topic/deprecated.rst +++ b/mps/manual/source/topic/deprecated.rst @@ -25,41 +25,6 @@ supported interface. Deprecated in version 1.115 ........................... -.. c:function:: mps_res_t mps_arena_commit_limit_set(mps_arena_t arena, size_t limit) - - .. deprecated:: - - Pass the :c:macro:`MPS_KEY_COMMIT_LIMIT` :term:`keyword - argument` to :c:func:`mps_arena_create_k` or - :c:func:`mps_arena_configure`. - - Change the :term:`commit limit` for an :term:`arena`. - - ``arena`` is the arena to change the commit limit for. - - ``limit`` is the new commit limit in :term:`bytes (1)`. - - Returns :c:macro:`MPS_RES_OK` if successful, or another - :term:`result code` if not. - - -.. c:function:: void mps_arena_spare_commit_limit_set(mps_arena_t arena, size_t limit) - - Change the :term:`spare commit limit` for an :term:`arena`. - - ``arena`` is the arena to change the spare commit limit for. - - ``limit`` is the new spare commit limit in :term:`bytes (1)`. - - Non-virtual-memory arena classes (for example, a :term:`client - arena`) do not have spare committed memory. For these arenas, this - function sets a value but has no other effect. - - Initially the spare commit limit is a configuration-dependent - value. The value of the limit can be retrieved by the function - :c:func:`mps_arena_spare_commit_limit`. - - .. c:type:: typedef mps_pool_class_t mps_class_t .. deprecated:: diff --git a/mps/test/function/165.c b/mps/test/function/165.c index da0734ba279..5bd3bda7a44 100644 --- a/mps/test/function/165.c +++ b/mps/test/function/165.c @@ -59,10 +59,7 @@ static void test(void) /* Set the spare commit limit to 0MB */ - MPS_ARGS_BEGIN(args) { - MPS_ARGS_ADD(args, MPS_KEY_SPARE_COMMIT_LIMIT, 0); - cdie(mps_arena_configure(arena, args), "mps_arena_configure"); - } MPS_ARGS_END(args); + mps_arena_spare_commit_limit_set(arena, (size_t) 0); die(mps_alloc(&objs[0], pool, BIGSIZE), "alloc"); com0 = mps_arena_committed(arena); mps_free(pool, objs[0], BIGSIZE); @@ -74,10 +71,7 @@ static void test(void) /* Try again but with arena hysteresis */ /* nb. size_t unsigned, therefore (size_t)-1 is the maximum limit */ - MPS_ARGS_BEGIN(args) { - MPS_ARGS_ADD(args, MPS_KEY_SPARE_COMMIT_LIMIT, -1); - cdie(mps_arena_configure(arena, args), "mps_arena_configure"); - } MPS_ARGS_END(args); + mps_arena_spare_commit_limit_set(arena, (size_t)-1); die(mps_alloc(&objs[0], pool, BIGSIZE), "alloc"); com0 = mps_arena_committed(arena); mps_free(pool, objs[0], BIGSIZE); @@ -87,10 +81,7 @@ static void test(void) report("reduce2", "%ld", com0-com1); /* Reducing the spare committed limit should return most of the spare */ - MPS_ARGS_BEGIN(args) { - MPS_ARGS_ADD(args, MPS_KEY_SPARE_COMMIT_LIMIT, 1024*1024); - cdie(mps_arena_configure(arena, args), "mps_arena_configure"); - } MPS_ARGS_END(args); + mps_arena_spare_commit_limit_set(arena, (size_t)(1024*1024)); com2 = mps_arena_committed(arena); report("reduce3", "%ld", com0-com2); diff --git a/mps/test/function/231.c b/mps/test/function/231.c index ac13e02d4a1..c8c29fa44e2 100644 --- a/mps/test/function/231.c +++ b/mps/test/function/231.c @@ -27,10 +27,7 @@ static void test(void) report_res("create2", mps_arena_create_k(&arena, mps_arena_class_vm(), mps_args_none)); - MPS_ARGS_BEGIN(args) { - MPS_ARGS_ADD(args, MPS_KEY_COMMIT_LIMIT, 16 * 1024); - report_res("configure", mps_arena_configure(arena, args)); - } MPS_ARGS_END(args); + report_res("configure", mps_arena_commit_limit_set(arena, 16 * 1024)); mps_arena_destroy(arena); } From 38f73575ae2a1c8b0cc6dd7e02c85be92f60148e Mon Sep 17 00:00:00 2001 From: Richard Brooksby Date: Wed, 3 Feb 2016 16:50:42 +0000 Subject: [PATCH 11/11] Removing result code from arenasetsparecommitlimit since it can never fail. See . Copied from Perforce Change: 189084 ServerID: perforce.ravenbrook.com --- mps/code/arena.c | 3 +-- mps/code/mpm.h | 2 +- mps/code/mpsi.c | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/mps/code/arena.c b/mps/code/arena.c index 94dd0044733..722e450c4d5 100644 --- a/mps/code/arena.c +++ b/mps/code/arena.c @@ -1314,7 +1314,7 @@ Size ArenaSpareCommitLimit(Arena arena) return arena->spareCommitLimit; } -Res ArenaSetSpareCommitLimit(Arena arena, Size limit) +void ArenaSetSpareCommitLimit(Arena arena, Size limit) { AVERT(Arena, arena); /* Can't check limit, as all possible values are allowed. */ @@ -1326,7 +1326,6 @@ Res ArenaSetSpareCommitLimit(Arena arena, Size limit) } EVENT2(SpareCommitLimitSet, arena, limit); - return ResOK; } /* Used by arenas which don't use spare committed memory */ diff --git a/mps/code/mpm.h b/mps/code/mpm.h index 022064f3a2f..b8cb8c250ee 100644 --- a/mps/code/mpm.h +++ b/mps/code/mpm.h @@ -620,7 +620,7 @@ extern Size ArenaSpareCommitted(Arena arena); extern Size ArenaCommitLimit(Arena arena); extern Res ArenaSetCommitLimit(Arena arena, Size limit); extern Size ArenaSpareCommitLimit(Arena arena); -extern Res ArenaSetSpareCommitLimit(Arena arena, Size limit); +extern void ArenaSetSpareCommitLimit(Arena arena, Size limit); extern Size ArenaNoPurgeSpare(Arena arena, Size size); extern Res ArenaNoGrow(Arena arena, LocusPref pref, Size size); diff --git a/mps/code/mpsi.c b/mps/code/mpsi.c index 9d9d4986000..283fbc6123e 100644 --- a/mps/code/mpsi.c +++ b/mps/code/mpsi.c @@ -204,7 +204,7 @@ mps_res_t mps_arena_commit_limit_set(mps_arena_t arena, size_t limit) void mps_arena_spare_commit_limit_set(mps_arena_t arena, size_t limit) { ArenaEnter(arena); - (void)ArenaSetSpareCommitLimit(arena, limit); + ArenaSetSpareCommitLimit(arena, limit); ArenaLeave(arena); return;