2003-02-11T13:45Z drj@ravenbrook.com Collection Inception or How and Why Collections Start Summary There are three ways a collection can start: * Some nursery generation is full (See .collect.incept.chain below). * "Dynamic Criterion" See .collect.incept.dynamic below. Perhaps this is better named: global memory exhaustion. * opportunistic, via arenaShouldCollectWorld. Implementation Details Various MPS interface functions call ArenaPoll. ArenaPoll will occasionally call ArenaStep (specifically, if the mutator has allocated more than globals->pollThreshold). mps_arena_step is a direct interface to ArenaStep. ArenaStep will call ArenaStartCollect to start a collection if arenaShouldCollectWorld returns true. But ordinarily it will call TracePoll. arenaShouldCollectWorld will return true if it has been given enough time and it has been a while (specifically 10 * its time estimate) since the last world collection) (and there isn't a collection in progress). ArenaStartCollect calls traceStartCollectAll TracePoll contains the meat of the policy. Big and hairy. See strategy.lisp-machine! What is tTracePerScan, well t probably denotes time. So it denotes (an estimate of) the time taken to perform the collection in units of cScan (the cost of scanning a unit. byte?). TraceCopyScanRATIO is how much more expensive a copy is than a scan (currently 1.5). .collect.incept.dynamic: TracePoll uses a so called "dynamic" (poor Lisp Machine terminology) strategy to decide whether to collect everything (via traceStartCollectAll). .collect.incept.chain: Otherwise it maps over all Chains (arena->chainRing) and calls ChainDeferral(chain) and gets the minimum answer over all chains. The chain with the minimum answer (which is negative) gets ChainCondemnAuto called on it, then ChainStartGC. ChainCondemnAuto picks a set of gens, generates a ZoneSet covering those, and then condemns everything in those zones using TraceCondemnZones. .chain.condemn.promote: It strikes me that when we do this we ought to not promote anything that is condemned "incidentally" (that is condemned because it is in a relevant zone, but not in a generation whose time is up). In the (common) case where TracePoll decides to not start a collection then it progresses the only trace by a single quantum. === AMC's chains === Generation are created by calls to amcGenCreate from amcInitComm. There is a chain, amc->chain. Which is one of the va_args to creation. Creates count+1 generations where count = ChainGens(). Eseentially one gen is created for each gen in the chain and attached to the chain's generation locus. An additional gen is created ("topgen") and associated with the arena's locus of top generations. (See hack in PoolGenInit) Serial number of a PoolGen (->nr field) is unique within that pool's generations.