1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-30 04:10:54 -08:00

The fragmentation limit argument to the mvt pool class is now passed as a floating point fraction, not a percentage, in the keyword interface.

Copied from Perforce
 Change: 181862
 ServerID: perforce.ravenbrook.com
This commit is contained in:
Richard Brooksby 2013-05-16 13:54:06 +01:00
parent 30ffeaec27
commit f0e9d74c3c
11 changed files with 53 additions and 30 deletions

View file

@ -92,6 +92,13 @@ Bool ArgCheckRank(Arg arg) {
return TRUE;
}
Bool ArgCheckdouble(Arg arg) {
/* It would be nice if we could check doubles with C89, but
it doesn't have isfinite() etc. which are in C99. */
UNUSED(arg);
return TRUE;
}
ARG_DEFINE_KEY(args_end, Shouldnt);

View file

@ -53,6 +53,7 @@ extern Bool ArgCheckCount(Arg arg);
extern Bool ArgCheckPointer(Arg arg);
extern Bool ArgCheckRankSet(Arg arg);
extern Bool ArgCheckRank(Arg arg);
extern Bool ArgCheckdouble(Arg arg);
#endif /* arg_h */

View file

@ -1031,7 +1031,7 @@
3114A66C156E95EB001E0AA3 /* btcv.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = btcv.c; sourceTree = "<group>"; };
3114A67C156E9668001E0AA3 /* mv2test */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = mv2test; sourceTree = BUILT_PRODUCTS_DIR; };
3114A686156E9674001E0AA3 /* mv2test.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mv2test.c; sourceTree = "<group>"; };
3114A68E156E96B6001E0AA3 /* poolmv2.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 0; path = poolmv2.c; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.c; };
3114A68E156E96B6001E0AA3 /* poolmv2.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 0; path = poolmv2.c; sourceTree = "<group>"; };
3114A695156E971B001E0AA3 /* messtest */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = messtest; sourceTree = BUILT_PRODUCTS_DIR; };
3114A69F156E9725001E0AA3 /* messtest.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = messtest.c; sourceTree = "<group>"; };
3114A6AC156E9759001E0AA3 /* walkt0 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = walkt0; sourceTree = BUILT_PRODUCTS_DIR; };
@ -1103,6 +1103,7 @@
31CD33BC173A9F1500524741 /* poolams.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = poolams.c; sourceTree = "<group>"; };
31CD33BD173A9F1500524741 /* poolams.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = poolams.h; sourceTree = "<group>"; };
31CD33BE173ABB3000524741 /* poolmv2.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = poolmv2.h; sourceTree = "<group>"; };
31D4D5FD1745058100BE84B5 /* poolmv2.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = poolmv2.c; sourceTree = "<group>"; };
31D60006156D3C5F00337B26 /* segsmss.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = segsmss.c; sourceTree = "<group>"; };
31D6000D156D3CB200337B26 /* awluthe */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = awluthe; sourceTree = BUILT_PRODUCTS_DIR; };
31D60017156D3CC300337B26 /* awluthe.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = awluthe.c; sourceTree = "<group>"; };
@ -1729,6 +1730,7 @@
31EEAC5A156AB40800714D05 /* Extra pools */ = {
isa = PBXGroup;
children = (
31D4D5FD1745058100BE84B5 /* poolmv2.c */,
31CD33BE173ABB3000524741 /* poolmv2.h */,
311F2F5D17398B0400C15B6A /* lo.h */,
31F6CCA91739B0CF00C48748 /* mpscamc.h */,

View file

@ -14,7 +14,7 @@ extern const struct mps_key_s _mps_key_mvt_reserve_depth;
#define MPS_KEY_MVT_RESERVE_DEPTH_FIELD count
extern const struct mps_key_s _mps_key_mvt_frag_limit;
#define MPS_KEY_MVT_FRAG_LIMIT (&_mps_key_mvt_frag_limit)
#define MPS_KEY_MVT_FRAG_LIMIT_FIELD count
#define MPS_KEY_MVT_FRAG_LIMIT_FIELD d
/* The mvt pool class has five extra parameters to mps_pool_create:
* mps_res_t mps_pool_create(mps_pool_t * pool, mps_arena_t arena,

View file

@ -206,18 +206,15 @@ static mps_res_t make(mps_addr_t *p, mps_ap_t ap, size_t size)
static mps_res_t stress(mps_class_t class, mps_arena_t arena,
size_t (*size)(int i), ...)
size_t (*size)(int i), mps_arg_s args[])
{
mps_res_t res;
mps_ap_t ap;
va_list arg;
int i, k;
int *ps[TEST_SET_SIZE];
size_t ss[TEST_SET_SIZE];
va_start(arg, size);
res = mps_pool_create_v(&pool, arena, class, arg);
va_end(arg);
res = mps_pool_create_k(&pool, arena, class, args);
if(res != MPS_RES_OK) return res;
die(mps_ap_create(&ap, pool, mps_rank_exact()), "BufferCreate");
@ -299,15 +296,16 @@ static void stress_with_arena_class(mps_arena_class_t aclass)
min = MPS_PF_ALIGN;
mean = 42;
max = 8192;
die(stress(mps_class_mvt(), arena, randomSize,
min, /* min_size */
mean, /* median_size */
max, /* maximum_size */
(mps_count_t)TEST_SET_SIZE/2, /* reserve_depth */
(mps_count_t)30 /* fragmentation_limit */
),
"stress MVT");
MPS_ARGS_BEGIN(args) {
MPS_ARGS_ADD(args, MPS_KEY_MIN_SIZE, min);
MPS_ARGS_ADD(args, MPS_KEY_MEAN_SIZE, mean);
MPS_ARGS_ADD(args, MPS_KEY_MAX_SIZE, max);
MPS_ARGS_ADD(args, MPS_KEY_MVT_RESERVE_DEPTH, TEST_SET_SIZE/2);
MPS_ARGS_ADD(args, MPS_KEY_MVT_FRAG_LIMIT, 0.3);
MPS_ARGS_DONE(args);
die(stress(mps_class_mvt(), arena, randomSize, args), "stress MVT");
} MPS_ARGS_END(args);
mps_arena_destroy(arena);

View file

@ -203,8 +203,9 @@ static void MVTVarargs(ArgStruct args[MPS_ARGS_MAX], va_list varargs)
args[2].val.size = va_arg(varargs, Size);
args[3].key = MPS_KEY_MVT_RESERVE_DEPTH;
args[3].val.count = va_arg(varargs, Count);
/* Divide the old "percentage" argument by 100, fixing job003319. */
args[4].key = MPS_KEY_MVT_FRAG_LIMIT;
args[4].val.count = va_arg(varargs, Count);
args[4].val.d = (double)va_arg(varargs, Count) / 100.0;
args[5].key = MPS_KEY_ARGS_END;
AVER(ArgListCheck(args));
}
@ -220,7 +221,7 @@ ARG_DEFINE_KEY(mvt_min_size, Size);
ARG_DEFINE_KEY(mvt_mean_size, Size);
ARG_DEFINE_KEY(mvt_max_size, Size);
ARG_DEFINE_KEY(mvt_reserve_depth, Count);
ARG_DEFINE_KEY(mvt_frag_limit, Count);
ARG_DEFINE_KEY(mvt_frag_limit, double);
static Res MVTInit(Pool pool, ArgList args)
{
@ -250,8 +251,11 @@ static Res MVTInit(Pool pool, ArgList args)
maxSize = arg.val.size;
if (ArgPick(&arg, args, MPS_KEY_MVT_RESERVE_DEPTH))
reserveDepth = arg.val.count;
if (ArgPick(&arg, args, MPS_KEY_MVT_FRAG_LIMIT))
fragLimit = arg.val.count;
if (ArgPick(&arg, args, MPS_KEY_MVT_FRAG_LIMIT)) {
/* pending complete fix for job003319 */
AVER(0 <= arg.val.d <= 1);
fragLimit = (Count)(arg.val.d * 100);
}
AVER(0 < minSize);
AVER(minSize <= meanSize);

View file

@ -159,17 +159,17 @@ MVT interface
reserve does not guarantee any particular amount of allocation.
* :c:macro:`MPS_KEY_MVT_FRAG_LIMIT` (type :c:type:`mps_count_t`)
is a percentage from 1 to 100 (inclusive). It sets an upper
is a double from 0.0 to 1.0 (inclusive). It sets an upper
limit on the space overhead of an MVT pool, in case block death
times and allocations do not correlate well. If the free space
managed by the pool as a ratio of all the space managed by the
pool exceeds the fragmentation limit, the pool falls back to a
first fit allocation policy, exploiting space more efficiently
at a cost in time efficiency. A fragmentation limit of 0 would
at a cost in time efficiency. A fragmentation limit of 0.0 would
cause the pool to operate as a first-fit pool, at a significant
cost in time efficiency: therefore this is not permitted.
A fragmentation limit of 100 causes the pool to always use
A fragmentation limit of 1.0 causes the pool to always use
temporal fit (unless resources are exhausted). If the objects
allocated in the pool have similar lifetime expectancies, this
mode will have the best time- and space-efficiency. If the
@ -185,7 +185,7 @@ MVT interface
MPS_ARGS_ADD(ARGS, MPS_KEY_MEAN_SIZE, 32);
MPS_ARGS_ADD(ARGS, MPS_KEY_MAX_SIZE, 1024);
MPS_ARGS_ADD(ARGS, MPS_KEY_MVT_RESERVE_DEPTH, 256);
MPS_ARGS_ADD(ARGS, MPS_KEY_MVT_FRAG_LIMIT, 50);
MPS_ARGS_ADD(ARGS, MPS_KEY_MVT_FRAG_LIMIT, 0.5);
MPS_ARGS_DONE(args);
res = mps_pool_create_k(&pool, arena, mps_class_mvt(), args);
} MPS_ARGS_END(args);
@ -203,6 +203,12 @@ MVT interface
mps_count_t reserve_depth,
mps_count_t fragmentation_limit)
.. note::
The fragmentation_limit is a percentage from 0 to 100
inclusive when passed to :c:func:`mps_pool_create`, not a
double from 0.0 to 1.0 as in :c:func:`mps_pool_create_k`.
.. index::
pair: MVT; introspection

View file

@ -7,7 +7,6 @@ Reference
:numbered:
interface
keyword
error
arena
pool

Binary file not shown.

File diff suppressed because one or more lines are too long

View file

@ -159,17 +159,17 @@ MVT interface
reserve does not guarantee any particular amount of allocation.
* :c:macro:`MPS_KEY_MVT_FRAG_LIMIT` (type :c:type:`mps_count_t`)
is a percentage from 1 to 100 (inclusive). It sets an upper
is a double from 0.0 to 1.0 (inclusive). It sets an upper
limit on the space overhead of an MVT pool, in case block death
times and allocations do not correlate well. If the free space
managed by the pool as a ratio of all the space managed by the
pool exceeds the fragmentation limit, the pool falls back to a
first fit allocation policy, exploiting space more efficiently
at a cost in time efficiency. A fragmentation limit of 0 would
at a cost in time efficiency. A fragmentation limit of 0.0 would
cause the pool to operate as a first-fit pool, at a significant
cost in time efficiency: therefore this is not permitted.
A fragmentation limit of 100 causes the pool to always use
A fragmentation limit of 1.0 causes the pool to always use
temporal fit (unless resources are exhausted). If the objects
allocated in the pool have similar lifetime expectancies, this
mode will have the best time- and space-efficiency. If the
@ -185,7 +185,7 @@ MVT interface
MPS_ARGS_ADD(ARGS, MPS_KEY_MEAN_SIZE, 32);
MPS_ARGS_ADD(ARGS, MPS_KEY_MAX_SIZE, 1024);
MPS_ARGS_ADD(ARGS, MPS_KEY_MVT_RESERVE_DEPTH, 256);
MPS_ARGS_ADD(ARGS, MPS_KEY_MVT_FRAG_LIMIT, 50);
MPS_ARGS_ADD(ARGS, MPS_KEY_MVT_FRAG_LIMIT, 0.5);
MPS_ARGS_DONE(args);
res = mps_pool_create_k(&pool, arena, mps_class_mvt(), args);
} MPS_ARGS_END(args);
@ -203,6 +203,12 @@ MVT interface
mps_count_t reserve_depth,
mps_count_t fragmentation_limit)
.. note::
The fragmentation_limit is a percentage from 0 to 100
inclusive when passed to :c:func:`mps_pool_create`, not a
double from 0.0 to 1.0 as in :c:func:`mps_pool_create_k`.
.. index::
pair: MVT; introspection