[m-rev.] diff: Make Mercury compatible with latest ThreadScope versions.

Paul Bone pbone at csse.unimelb.edu.au
Sat Jun 16 15:57:18 AEST 2012


Conform to latest ThreadScope expectations.

ThreadScope compatibility is a moving target.  This patch ensures that
modern versions of ThreadScope can open eventlog files produced by Mercury.

runtime/mercury_threadscope.c:
    An extra mandatory event has been added to ThreadScope, GcGlobalSync.
    Mercury now writes out this event at a suitable time so that ThreadScope
    can still open Mercury's eventlog files.

    Arguably this is a bug-compatibility patch because ThreadScope is
    supposed to be forwards and backwards compatible.  The ThreadScope
    authors are considering removing the requirement for this event, so that
    they can open older eventlog files.

Index: runtime/mercury_threadscope.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_threadscope.c,v
retrieving revision 1.18
diff -u -r1.18 mercury_threadscope.c
--- runtime/mercury_threadscope.c	21 Sep 2011 07:59:39 -0000	1.18
+++ runtime/mercury_threadscope.c	16 Jun 2012 05:18:19 -0000
@@ -63,6 +63,7 @@
 **       Word64         -- time (nanosecs)
 **       [Word16]       -- length of the rest (for variable-sized events only)
 **       ... extra event-specific info ...
+**
 ** EventTypeExt :
 **       Word16         -- unique identifier for this extension type.
 **       Word16         -- size of the payload in bytes.
@@ -164,8 +165,25 @@
 #define MR_TS_EVENT_SPARK_FIZZLE        40 /* () */
 #define MR_TS_EVENT_SPARK_GC            41 /* () */
 #define MR_TS_EVENT_INTERN_STRING       42 /* (string, id) */
+#define MR_TS_EVENT_WALL_CLOCK_TIME     43 /* (capset, unix_epoch_seconds, nanoseconds) */
+#define MR_TS_EVENT_THREAD_LABEL        44 /* (thread, name_string)  */
+#define MR_TS_EVENT_CAP_CREATE          45 /* (cap)                  */
+#define MR_TS_EVENT_CAP_DELETE          46 /* (cap)                  */
+#define MR_TS_EVENT_CAP_DISABLE         47 /* (cap)                  */
+#define MR_TS_EVENT_CAP_ENABLE          48 /* (cap)                  */
+#define MR_TS_EVENT_HEAP_ALLOCATED      49 /* (heap_capset, alloc_bytes) */
+#define MR_TS_EVENT_HEAP_SIZE           50 /* (heap_capset, size_bytes) */
+#define MR_TS_EVENT_HEAP_LIVE           51 /* (heap_capset, live_bytes) */
+#define MR_TS_EVENT_HEAP_INFO_GHC       52 /* (heap_capset, n_generations,
+                                         max_heap_size, alloc_area_size,
+                                         mblock_size, block_size) */
+#define MR_TS_EVENT_GC_STATS_GHC        53 /* (heap_capset, generation,
+                                         copied_bytes, slop_bytes, frag_bytes,
+                                         par_n_threads,
+                                         par_max_copied, par_tot_copied) */
+#define MR_TS_EVENT_GC_GLOBAL_SYNC      54 /* ()                     */
 
-#define MR_TS_NUM_EVENT_TAGS            43
+#define MR_TS_NUM_EVENT_TAGS            55
 
 #define MR_TS_MER_EVENT_START           100
 
@@ -513,6 +531,20 @@
         0,
         0xFFFF
     },
+    /*
+     * We don't use events 43--53.
+     */
+    {
+        MR_TS_EVENT_GC_GLOBAL_SYNC,
+        /*
+        ** If using parallel marking this also means that marker threads are
+        ** ready.  This doesn't apply to Mercury as Boehm uses seperate
+        ** threads
+        */
+        "The world has stopped and GC may begin",
+        0,
+        0xFFFF
+    },
     {
         MR_TS_MER_EVENT_SPARK_CREATE,
         "A spark is being created with attributes for Mercury",
@@ -2037,6 +2069,21 @@
 
         put_event_header(buffer, MR_TS_EVENT_GC_START,
             get_current_time_nanosecs());
+
+        if (!enough_room_for_event(buffer, MR_TS_EVENT_GC_GLOBAL_SYNC)) {
+            flush_event_buffer(buffer);
+            open_block(buffer, MR_thread_engine_base->MR_eng_id);
+        } else if (!block_is_open(buffer)) {
+            open_block(buffer, MR_thread_engine_base->MR_eng_id);
+        }
+
+        /*
+        ** Idealy this event should be posted after the world has stopped.
+        ** Doing so means adding more instrumentation into Boehm.
+        */
+        put_event_header(buffer, MR_TS_EVENT_GC_GLOBAL_SYNC,
+            get_current_time_nanosecs());
+
         MR_US_UNLOCK(&(buffer->MR_tsbuffer_lock));
     }
 }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: Digital signature
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20120616/a3709285/attachment.sig>


More information about the reviews mailing list