diff --git a/mps/code/eventdef.h b/mps/code/eventdef.h index a0a368bd61e..e3a07a42118 100644 --- a/mps/code/eventdef.h +++ b/mps/code/eventdef.h @@ -744,7 +744,9 @@ #define EVENT_GenInit_PARAMS(PARAM, X) \ PARAM(X, 0, P, arena) /* arena owning generation */ \ PARAM(X, 1, P, gen) /* the generation */ \ - PARAM(X, 2, U, serial) /* serial number within arena */ + PARAM(X, 2, U, serial) /* serial number within arena */ \ + PARAM(X, 3, W, capacity) /* capacity in bytes */ \ + PARAM(X, 4, D, mortality) /* initial mortality estimate */ #define EVENT_GenFinish_PARAMS(PARAM, X) \ PARAM(X, 0, P, arena) /* arena owning generation */ \ diff --git a/mps/code/locus.c b/mps/code/locus.c index e8919b159fe..8e4e39e932e 100644 --- a/mps/code/locus.c +++ b/mps/code/locus.c @@ -123,6 +123,7 @@ static Bool GenParamCheck(GenParamStruct *params) { CHECKL(params != NULL); CHECKL(params->capacity > 0); + CHECKL(params->capacity <= SizeMAX / 1024); CHECKL(params->mortality >= 0.0); CHECKL(params->mortality <= 1.0); return TRUE; @@ -139,13 +140,13 @@ static void GenDescInit(Arena arena, GenDesc gen, GenParamStruct *params) gen->serial = arena->genSerial; ++ arena->genSerial; gen->zones = ZoneSetEMPTY; - gen->capacity = params->capacity; + gen->capacity = params->capacity * 1024; gen->mortality = params->mortality; RingInit(&gen->locusRing); RingInit(&gen->segRing); gen->sig = GenDescSig; AVERT(GenDesc, gen); - EVENT3(GenInit, arena, gen, gen->serial); + EVENT5(GenInit, arena, gen, gen->serial, gen->capacity, gen->mortality); } @@ -458,7 +459,7 @@ double ChainDeferral(Chain chain) if (chain->activeTraces == TraceSetEMPTY) { for (i = 0; i < chain->genCount; ++i) { - double genTime = chain->gens[i].capacity * 1024.0 + double genTime = (double)chain->gens[i].capacity - (double)GenDescNewSize(&chain->gens[i]); if (genTime < time) time = genTime; diff --git a/mps/code/locus.h b/mps/code/locus.h index c558c9209ea..63e5cc39be9 100644 --- a/mps/code/locus.h +++ b/mps/code/locus.h @@ -43,8 +43,8 @@ typedef struct GenDescStruct { Sig sig; /* */ Serial serial; /* serial number within arena */ ZoneSet zones; /* zoneset for this generation */ - Size capacity; /* capacity in kB */ - double mortality; /* predicted mortality */ + Size capacity; /* capacity in bytes */ + double mortality; /* moving average mortality */ RingStruct locusRing; /* Ring of all PoolGen's in this GenDesc (locus) */ RingStruct segRing; /* Ring of GCSegs in this generation */ GenTraceStatsStruct trace[TraceLIMIT]; diff --git a/mps/code/policy.c b/mps/code/policy.c index f89cceed4cb..a9c8099975e 100644 --- a/mps/code/policy.c +++ b/mps/code/policy.c @@ -232,7 +232,7 @@ static Res policyCondemnChain(double *mortalityReturn, Chain chain, Trace trace) gen = &chain->gens[topCondemnedGen]; AVERT(GenDesc, gen); genNewSize = GenDescNewSize(gen); - if (genNewSize >= gen->capacity * (Size)1024) + if (genNewSize >= gen->capacity) break; } diff --git a/mps/tool/monitor b/mps/tool/monitor index f9a89300e7d..902d430b3be 100755 --- a/mps/tool/monitor +++ b/mps/tool/monitor @@ -310,6 +310,7 @@ class Gen(EventHandler): self._model.add_time_series( self, mortality_average, "fraction", f"mortality.avg", f"mortality of data in generation, moving average") + mortality_average.append(t, event.mortality); self._ref_size = ref_size = TimeSeries() self._model.add_time_series( self, ref_size, "bytes", f"ref",