MPS issue job003353

TitleCollection start reason hard to analyze
Statussuspended
Prioritynice
Assigned userGareth Rees
OrganizationRavenbrook
DescriptionThe function mps_message_gc_start_why [1] returns an English-language description of why the collection started. This is hard to analyze programmatically: (a) have to do string match; (b) no definitive list of reasons. Also needlessly hard to internationalize.
AnalysisInternally to the MPS this is just an enumerated number, so we could expose it somehow.

GDR 2013-03-08: I propose adding the following to the public interface:

    /* Garbage collection causes.
     * Keep in sync with TraceStartWhy* in mpmtypes.h.
     * Not meant to be used by clients. They should use the macros below. */
    enum {
      _mps_GC_CAUSE_NURSERY_FULL = 1,
      _mps_GC_CAUSE_DYNAMIC,
      _mps_GC_CAUSE_OPPORTUNISM,
      _mps_GC_CAUSE_CLIENT_INCREMENTAL,
      _mps_GC_CAUSE_CLIENT_BLOCK,
      _mps_GC_CAUSE_WALK,
      _mps_GC_CAUSE_EXTENSION,
      _mps_GC_CAUSE_UNKNOWN
    };

    /* Garbage collection causes.
     * These are what clients should use. */
    #define mps_gc_cause_nursery_full() _mps_GC_CAUSE_NURSERY_FULL
    #define mps_gc_cause_dynamic() _mps_GC_CAUSE_DYNAMIC
    #define mps_gc_cause_opportunism() _mps_GC_CAUSE_OPPORTUNISM
    #define mps_gc_cause_client_incremental() _mps_GC_CAUSE_CLIENT_INCREMENTAL
    #define mps_gc_cause_client_block() _mps_GC_CAUSE_CLIENT_BLOCK
    #define mps_gc_cause_walk() _mps_GC_CAUSE_WALK
    #define mps_gc_cause_extension() _mps_GC_CAUSE_EXTENSION
    #define mps_gc_cause_unknown() _mps_GC_CAUSE_UNKNOWN

    typedef int mps_gc_cause_t; /* a garbage collection cause */

    extern mps_gc_cause_t mps_message_gc_start_cause(mps_arena_t, mps_message_t);

GDR 2013-03-12: RB suggests [2] that we "Defer this until there's a clear requirement" which seems sensible.
How foundinspection
Evidence[1] <https://info.ravenbrook.com/project/mp...ollection.html#mps_message_gc_start_why>
[2] <https://info.ravenbrook.com/mail/2013/03/12/13-03-07/0/>
Observed in1.110.0
Created byGareth Rees
Created on2012-10-31 17:10:23
Last modified byGareth Rees
Last modified on2018-07-15 19:18:55
History2012-10-31 GDR Created.
2013-03-08 GDR Added proposal.
2013-03-12 GDR Suspend it.