Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r1591:3a3942c0f6e1
Date: 2015-01-28 11:50 +0100
http://bitbucket.org/pypy/stmgc/changeset/3a3942c0f6e1/

Log:    Enable or disable writing the profiling info after forks

diff --git a/c7/stm/prof.c b/c7/stm/prof.c
--- a/c7/stm/prof.c
+++ b/c7/stm/prof.c
@@ -90,7 +90,7 @@
     }
 }
 
-int stm_set_timing_log(const char *profiling_file_name,
+int stm_set_timing_log(const char *profiling_file_name, int fork_mode,
                        int expand_marker(stm_loc_marker_t *, char *, int))
 {
     close_timing_log();
@@ -116,6 +116,7 @@
     if (!open_timing_log(profiling_file_name))
         return -1;
 
-    profiling_basefn = strdup(profiling_file_name);
+    if (fork_mode != 0)
+        profiling_basefn = strdup(profiling_file_name);
     return 0;
 }
diff --git a/c7/stmgc.h b/c7/stmgc.h
--- a/c7/stmgc.h
+++ b/c7/stmgc.h
@@ -469,13 +469,15 @@
                                   stm_loc_marker_t *markers);
 
 /* Calling this sets up a stmcb_timing_event callback that will produce
-   a binary file calling 'profiling_file_name'.  After a fork(), it is
-   written to 'profiling_file_name.fork<PID>'.  Call it with NULL to
+   a binary file called 'profiling_file_name'.  Call it with
+   'fork_mode == 0' for only the main process, and with
+   'fork_mode == 1' to also write files called
+   'profiling_file_name.fork<PID>' after a fork().  Call it with NULL to
    stop profiling.  Returns -1 in case of error (see errno then).
    The optional 'expand_marker' function pointer is called to expand
    the marker's odd_number and object into data, starting at the given
    position and with the given maximum length. */
-int stm_set_timing_log(const char *profiling_file_name,
+int stm_set_timing_log(const char *profiling_file_name, int fork_mode,
                        int expand_marker(stm_loc_marker_t *, char *, int));
 
 
diff --git a/c7/test/support.py b/c7/test/support.py
--- a/c7/test/support.py
+++ b/c7/test/support.py
@@ -154,7 +154,7 @@
                                       stm_loc_marker_t *markers);
 stmcb_timing_event_fn stmcb_timing_event;
 
-int stm_set_timing_log(const char *profiling_file_name,
+int stm_set_timing_log(const char *profiling_file_name, int prof_mode,
                        int expand_marker(stm_loc_marker_t *, char *, int));
 
 void stm_push_marker(stm_thread_local_t *, uintptr_t, object_t *);
diff --git a/c7/test/test_prof.py b/c7/test/test_prof.py
--- a/c7/test/test_prof.py
+++ b/c7/test/test_prof.py
@@ -27,13 +27,13 @@
 
     def test_simple(self):
         filename = os.path.join(str(udir), 'simple.prof')
-        r = lib.stm_set_timing_log(filename, ffi.NULL)
+        r = lib.stm_set_timing_log(filename, 0, ffi.NULL)
         assert r == 0
         try:
             self.start_transaction()
             self.commit_transaction()
         finally:
-            lib.stm_set_timing_log(ffi.NULL, ffi.NULL)
+            lib.stm_set_timing_log(ffi.NULL, 0, ffi.NULL)
 
         result = read_log(filename)
         assert result[0][2] == lib.STM_TRANSACTION_START
@@ -48,7 +48,7 @@
             p[0] = chr(100 + marker.odd_number)
             return 1
         filename = os.path.join(str(udir), 'contention.prof')
-        r = lib.stm_set_timing_log(filename, expand_marker)
+        r = lib.stm_set_timing_log(filename, 0, expand_marker)
         assert r == 0
         try:
             p = stm_allocate_old(16)
@@ -62,7 +62,7 @@
             stm_set_char(p, 'B')                # write
             py.test.raises(Conflict, self.commit_transaction)
         finally:
-            lib.stm_set_timing_log(ffi.NULL, ffi.NULL)
+            lib.stm_set_timing_log(ffi.NULL, 0, ffi.NULL)
 
         result = read_log(filename)
         id0 = result[0][1][0]
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to