MPS issue job001968

TitleMPS clients get no synchronous alert of collection begin/end
Assigned userRichard Kistruck
DescriptionMPS clients get no synchronous alert of collection begin/end

  mps_alert_collection_set(&alertfn) -- new function in mps.h
  (*alertfn)(MPS_ALERT_COLLECTION_BEGIN/END, whycode);

Related jobs:
job001969: "MPS gc-start and -end messages give no idea of timing"

RHSK 2008-11-12
There's not much a client can do with a synchronous alert, because
it may happen at any time (particularly: at interrupt time while
other client code and MPS code is in the middle of arbitrary
operations), beyond note the time it happens.

However, this is exactly what is wanted to help performance tests
of client program operations: it permits compensation for the
effect of MPS collections. (At worst: ignoring that run and trying
again, hoping not to trigger any collection at all).
AnalysisRHSK 2008-11-12
Can we synchronously deliver the gc-start and -end messages? No:
it would not be safe for clients to read the messages (via message
accessor functions) while the MPS is re-entrant.

How about timestamps on messages? Yes: see job001969.

But a synchronous alert to client callback code that can only do
very little would also be helpful.

Simple: mps_alert_collection_set stores a function pointer in
ArenaStruct. The tracer, immediately after posting a gc-start or
-end message, calls the callback (if non-null) as well.

The callback receives two ints:
alertcode (either of:
) (see mps.h), and
whycode (any of:
  TraceStartWhyCHAIN_GEN0CAP, /* start minor */
  TraceStartWhyDYNAMICCRITERION, /* start full */
  TraceStartWhyOPPORTUNISM, /* start full */
  TraceStartWhyCLIENTFULL_INCREMENTAL, /* start full */
  TraceStartWhyCLIENTFULL_BLOCK, /* do full */

Note: callback is also called for heap walk begin/end.

RHSK 2009-02-17
Use "begin/end" throughout, instead of "start/stop".
How foundunknown
Observed in1.108.2
Created byRichard Kistruck
Created on2008-11-12 15:20:56
Last modified byRichard Kistruck
Last modified on2010-03-03 15:08:18
History2008-11-12 RHSK Created.
2009-02-17 RHSK Use "begin/end" throughout, instead of "start/stop".


Change Effect Date User Description
169914 closed 2010-03-03 15:08:08 Richard Kistruck MPS master: add "mps_alert_collection_set" to w3gen.def. (So that if this .def file is used to re-export MPS functions from a client executable, mps_alert_collection_set() will be exported, along with all the other MPS interface functions).
167386 closed 2009-02-16 17:11:05 Richard Kistruck MPS br/timing: rename MPS_ALERT_COLLECTION_*. The correct term for when a new MPS operation begins is "Begin", and when it ends is "End". (Whereas several starts/stops may happen during a single MPS operation).
166703 closed 2008-11-12 15:07:04 Richard Kistruck MPS br/timing: mps_alert_collection_set() -- client sets a callback
function; MPS calls it synchronously on collection start/stop
(immediately after posting start/stop message). The callback
receives two ints: alertcode (start|stop; see mps.h), and whycode
(trace->why). Note: callback is also called for heap walk
amcss.c: show start/stop alerts.