mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-04-27 16:51:06 -07:00
New function policycollectiontime estimates the time needed to collect the arena. mysterious constants are given names and moved to config.h.
Copied from Perforce Change: 188160 ServerID: perforce.ravenbrook.com
This commit is contained in:
parent
b41d6be0e4
commit
d506458eea
5 changed files with 80 additions and 26 deletions
|
|
@ -1272,6 +1272,24 @@ Size ArenaAvail(Arena arena)
|
|||
}
|
||||
|
||||
|
||||
/* ArenaCollectable -- return estimate of collectable memory in arena */
|
||||
|
||||
Size ArenaCollectable(Arena arena)
|
||||
{
|
||||
/* Conservative estimate -- see job003929. */
|
||||
return ArenaCommitted(arena) - ArenaSpareCommitted(arena);
|
||||
}
|
||||
|
||||
|
||||
/* ArenaScannable -- return estimate of scannable memory in arena */
|
||||
|
||||
Size ArenaScannable(Arena arena)
|
||||
{
|
||||
/* Conservative estimate -- see job003929. */
|
||||
return ArenaCommitted(arena) - ArenaSpareCommitted(arena);
|
||||
}
|
||||
|
||||
|
||||
/* ArenaExtend -- Add a new chunk in the arena */
|
||||
|
||||
Res ArenaExtend(Arena arena, Addr base, Size size)
|
||||
|
|
|
|||
|
|
@ -392,22 +392,45 @@
|
|||
#define MVT_FRAG_LIMIT_DEFAULT 30
|
||||
|
||||
|
||||
/* Arena Configuration -- see <code/arena.c>
|
||||
*
|
||||
* .client.seg-size: ARENA_CLIENT_GRAIN_SIZE is the minimum size, in
|
||||
* bytes, of a grain in the client arena. It's set at 8192 with no
|
||||
* particular justification.
|
||||
*/
|
||||
/* Arena Configuration -- see <code/arena.c> */
|
||||
|
||||
#define ArenaPollALLOCTIME (65536.0)
|
||||
|
||||
#define ARENA_ZONESHIFT ((Shift)20)
|
||||
|
||||
/* .client.seg-size: ARENA_CLIENT_GRAIN_SIZE is the minimum size, in
|
||||
* bytes, of a grain in the client arena. It's set at 8192 with no
|
||||
* particular justification. */
|
||||
|
||||
#define ARENA_CLIENT_GRAIN_SIZE ((Size)8192)
|
||||
|
||||
#define ARENA_DEFAULT_ZONED TRUE
|
||||
|
||||
#define ArenaDefaultZONESET (ZoneSetUNIV << (MPS_WORD_WIDTH / 2))
|
||||
|
||||
/* ARENA_MINIMUM_COLLECTABLE_SIZE is the minimum size (in bytes) of
|
||||
* collectable memory that might be considered worthwhile to run a
|
||||
* full garbage collection. */
|
||||
|
||||
#define ARENA_MINIMUM_COLLECTABLE_SIZE ((Size)1000000)
|
||||
|
||||
/* ARENA_DEFAULT_COLLECTION_RATE is an estimate of the MPS's
|
||||
* collection rate (in bytes per second), for use in the case where
|
||||
* there isn't enough data to use a measured value. */
|
||||
|
||||
#define ARENA_DEFAULT_COLLECTION_RATE (25000000.0)
|
||||
|
||||
/* ARENA_DEFAULT_COLLECTION_OVERHEAD is an estimate of the MPS's
|
||||
* collection overhead (in seconds), for use in the case where there
|
||||
* isn't enough data to use a measured value. */
|
||||
|
||||
#define ARENA_DEFAULT_COLLECTION_OVERHEAD (0.1)
|
||||
|
||||
/* ARENA_MAX_COLLECT_FRACTION is the maximum fraction of runtime that
|
||||
* ArenaStep is prepared to spend in collections. */
|
||||
|
||||
#define ARENA_MAX_COLLECT_FRACTION (0.1)
|
||||
|
||||
/* TODO: This is left over from before the branch/2014-01-29/mps-chain-zones
|
||||
and 2014-01-17/cbs-tract-alloc reformed allocation, and may now be doing
|
||||
more harm than good. Experiment with setting to ZoneSetUNIV. */
|
||||
|
|
|
|||
|
|
@ -765,36 +765,24 @@ static Bool arenaShouldCollectWorld(Arena arena,
|
|||
Clock now,
|
||||
Clock clocks_per_sec)
|
||||
{
|
||||
double scanRate;
|
||||
Size arenaSize;
|
||||
double arenaScanTime;
|
||||
double sinceLastWorldCollect;
|
||||
|
||||
/* don't collect the world if we're not given any time */
|
||||
if ((interval > 0.0) && (multiplier > 0.0)) {
|
||||
/* don't collect the world if we're already collecting. */
|
||||
if (arena->busyTraces == TraceSetEMPTY) {
|
||||
/* don't collect the world if it's very small */
|
||||
arenaSize = ArenaCommitted(arena) - ArenaSpareCommitted(arena);
|
||||
if (arenaSize > 1000000) {
|
||||
Size collectableSize = ArenaCollectable(arena);
|
||||
if (collectableSize > ARENA_MINIMUM_COLLECTABLE_SIZE) {
|
||||
/* how long would it take to collect the world? */
|
||||
if ((arena->tracedSize > 1000000.0) &&
|
||||
(arena->tracedTime > 1.0))
|
||||
scanRate = arena->tracedSize / arena->tracedTime;
|
||||
else
|
||||
scanRate = 25000000.0; /* a reasonable default. */
|
||||
arenaScanTime = arenaSize / scanRate;
|
||||
arenaScanTime += 0.1; /* for overheads. */
|
||||
double collectionTime = PolicyCollectionTime(arena);
|
||||
|
||||
/* how long since we last collected the world? */
|
||||
sinceLastWorldCollect = ((now - arena->lastWorldCollect) /
|
||||
(double) clocks_per_sec);
|
||||
double sinceLastWorldCollect = ((now - arena->lastWorldCollect) /
|
||||
(double) clocks_per_sec);
|
||||
/* have to be offered enough time, and it has to be a long time
|
||||
* since we last did it. */
|
||||
if ((interval * multiplier > arenaScanTime) &&
|
||||
sinceLastWorldCollect > arenaScanTime * 10.0) {
|
||||
if ((interval * multiplier > collectionTime) &&
|
||||
sinceLastWorldCollect > collectionTime / ARENA_MAX_COLLECT_FRACTION)
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -623,8 +623,9 @@ extern void ArenaSetSpareCommitLimit(Arena arena, Size limit);
|
|||
extern Size ArenaNoPurgeSpare(Arena arena, Size size);
|
||||
extern Res ArenaNoGrow(Arena arena, LocusPref pref, Size size);
|
||||
|
||||
extern double ArenaMutatorAllocSize(Arena arena);
|
||||
extern Size ArenaAvail(Arena arena);
|
||||
extern Size ArenaCollectable(Arena arena);
|
||||
extern Size ArenaScannable(Arena arena);
|
||||
|
||||
extern Res ArenaExtend(Arena, Addr base, Size size);
|
||||
|
||||
|
|
@ -661,6 +662,7 @@ extern Res ArenaNoExtend(Arena arena, Addr base, Size size);
|
|||
extern Res PolicyAlloc(Tract *tractReturn, Arena arena, LocusPref pref,
|
||||
Size size, Pool pool);
|
||||
extern Bool PolicyStartTrace(Trace *traceReturn, Arena arena);
|
||||
extern double PolicyCollectionTime(Arena arena);
|
||||
|
||||
|
||||
/* Locus interface */
|
||||
|
|
|
|||
|
|
@ -258,6 +258,29 @@ failStart:
|
|||
}
|
||||
|
||||
|
||||
/* PolicyCollectionTime -- estimate time to collect the world, in seconds */
|
||||
|
||||
double PolicyCollectionTime(Arena arena)
|
||||
{
|
||||
Size collectableSize;
|
||||
double collectionRate;
|
||||
double collectionTime;
|
||||
|
||||
AVERT(Arena, arena);
|
||||
|
||||
collectableSize = ArenaCollectable(arena);
|
||||
if (arena->tracedSize >= ARENA_MINIMUM_COLLECTABLE_SIZE
|
||||
&& arena->tracedTime > 0)
|
||||
collectionRate = arena->tracedSize / arena->tracedTime;
|
||||
else
|
||||
collectionRate = ARENA_DEFAULT_COLLECTION_RATE;
|
||||
collectionTime = collectableSize / collectionRate;
|
||||
collectionTime += ARENA_DEFAULT_COLLECTION_OVERHEAD;
|
||||
|
||||
return collectionTime;
|
||||
}
|
||||
|
||||
|
||||
/* C. COPYRIGHT AND LICENSE
|
||||
*
|
||||
* Copyright (C) 2001-2015 Ravenbrook Limited <http://www.ravenbrook.com/>.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue