[pypy-commit] stmgc c8-efficient-serial-execution: Introduce general data structure for timing event workloads
Author: tobias@masterthesis-vm
Branch: c8-efficient-serial-execution
Changeset: r2018:7c3284e554f1
Date: 2017-03-01 21:56 +0100
http://bitbucket.org/pypy/stmgc/changeset/7c3284e554f1/
Log:Introduce general data structure for timing event workloads
diff --git a/c8/stmgc.h b/c8/stmgc.h
--- a/c8/stmgc.h
+++ b/c8/stmgc.h
@@ -574,6 +574,13 @@
STM_GC_MAJOR_START,
STM_GC_MAJOR_DONE,
+/* execution duration profiling events */
+STM_DURATION_WRITE_BARRIER,
+STM_DURATION_VALIDATION,
+STM_DURATION_COMMIT,
+STM_DURATION_MINOR_GC,
+STM_DURATION_MAJOR_GC,
+
_STM_EVENT_N
};
@@ -596,6 +603,22 @@
uintptr_t odd_number; /* marker odd number, or 0 if marker is missing */
object_t *object; /* marker object, or NULL if marker is missing */
} stm_loc_marker_t;
+/* Allow any kind of payload to be attached to a timing event. */
+enum stm_payload_type_e {
+STM_EVENT_PAYLOAD_MARKER,
+STM_EVENT_PAYLOAD_DURATION,
+
+_STM_EVENT_PAYLOAD_N
+};
+typedef union {
+stm_loc_marker_t *loc_marker;
+uint32_t duration;
+} stm_timing_event_payload_data_t;
+/* Wrapper for payload holding data type and data. */
+typedef struct {
+enum stm_payload_type_e payload_type;
+stm_timing_event_payload_data_t payload_data;
+} stm_timing_event_payload_t;
extern void (*stmcb_timing_event)(stm_thread_local_t *tl, /* the local thread
*/
enum stm_event_e event,
stm_loc_marker_t *marker);
___
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] stmgc c8-efficient-serial-execution: Adapt stmgc API in support.py to timing event function interface change
Author: tobias@masterthesis-vm
Branch: c8-efficient-serial-execution
Changeset: r2020:58cddde10089
Date: 2017-03-03 11:42 +0100
http://bitbucket.org/pypy/stmgc/changeset/58cddde10089/
Log:Adapt stmgc API in support.py to timing event function interface
change
diff --git a/c8/test/support.py b/c8/test/support.py
--- a/c8/test/support.py
+++ b/c8/test/support.py
@@ -173,10 +173,23 @@
uintptr_t odd_number;
object_t *object;
} stm_loc_marker_t;
-
+enum stm_payload_type_e {
+STM_EVENT_PAYLOAD_MARKER,
+STM_EVENT_PAYLOAD_DURATION,
+...
+};
+typedef union {
+stm_loc_marker_t *loc_marker;
+uint32_t duration;
+} stm_timing_event_payload_data_t;
+/* Wrapper for payload holding data type and data. */
+typedef struct {
+enum stm_payload_type_e type;
+stm_timing_event_payload_data_t data;
+} stm_timing_event_payload_t;
typedef void (*stmcb_timing_event_fn)(stm_thread_local_t *tl,
enum stm_event_e event,
- stm_loc_marker_t *markers);
+ stm_timing_event_payload_t *payload);
stmcb_timing_event_fn stmcb_timing_event;
typedef int (*stm_expand_marker_fn)(char *seg_base, stm_loc_marker_t *marker,
@@ -224,7 +237,7 @@
object_t *nvalue, stm_thread_local_t *tl);
bool _check_hashtable_write_entry(object_t *, stm_hashtable_entry_t *,
object_t *nvalue);
-
+
stm_hashtable_entry_t *stm_hashtable_lookup(object_t *hashtableobj,
stm_hashtable_t *hashtable,
uintptr_t index);
___
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] stmgc c8-efficient-serial-execution: Fix marker tests
Author: tobias@masterthesis-vm
Branch: c8-efficient-serial-execution
Changeset: r2021:32769a7365e2
Date: 2017-03-03 11:53 +0100
http://bitbucket.org/pypy/stmgc/changeset/32769a7365e2/
Log:Fix marker tests
diff --git a/c8/test/test_marker.py b/c8/test/test_marker.py
--- a/c8/test/test_marker.py
+++ b/c8/test/test_marker.py
@@ -7,10 +7,11 @@
def recording(self, *kinds):
seen = []
@ffi.callback("stmcb_timing_event_fn")
-def timing_event(tl, event, marker):
+def timing_event(tl, event, payload):
if len(kinds) > 0 and event not in kinds:
return
-if marker:
+if payload and payload.type == lib.STM_EVENT_PAYLOAD_MARKER:
+marker = payload.data.loc_marker
expanded = (marker.odd_number, marker.object)
else:
expanded = None
___
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] stmgc c8-efficient-serial-execution: Refactor timing event function to accept general payloads
Author: tobias@masterthesis-vm
Branch: c8-efficient-serial-execution
Changeset: r2019:87f8a688298c
Date: 2017-03-02 16:44 +0100
http://bitbucket.org/pypy/stmgc/changeset/87f8a688298c/
Log:Refactor timing event function to accept general payloads
diff --git a/c8/stm/marker.c b/c8/stm/marker.c
--- a/c8/stm/marker.c
+++ b/c8/stm/marker.c
@@ -3,6 +3,9 @@
# include "core.h" // silence flymake
#endif
+#define payload(marker) stm_timing_event_payload_data_t data = { &marker }; \
+stm_timing_event_payload_t payload = { \
+STM_EVENT_PAYLOAD_MARKER, data };
static bool marker_fetch(stm_thread_local_t *tl, stm_loc_marker_t *out_marker)
{
@@ -92,19 +95,16 @@
stm_loc_marker_t marker;
marker_fetch_obj_write(start, contention, &marker);
+payload(marker)
stmcb_timing_event(STM_SEGMENT->running_thread,
- STM_CONTENTION_WRITE_READ, &marker);
+ STM_CONTENTION_WRITE_READ, &payload);
}
static void _timing_become_inevitable(void)
{
stm_loc_marker_t marker;
marker_fetch(STM_SEGMENT->running_thread, &marker);
+payload(marker)
stmcb_timing_event(STM_SEGMENT->running_thread,
- STM_BECOME_INEVITABLE, &marker);
+ STM_BECOME_INEVITABLE, &payload);
}
-
-
-void (*stmcb_timing_event)(stm_thread_local_t *tl, /* the local thread */
- enum stm_event_e event,
- stm_loc_marker_t *marker);
diff --git a/c8/stm/prof.c b/c8/stm/prof.c
--- a/c8/stm/prof.c
+++ b/c8/stm/prof.c
@@ -6,37 +6,45 @@
static char *profiling_basefn = NULL;
static stm_expand_marker_fn profiling_expand_marker;
-#define MARKER_LEN_MAX 160
+#define EXTRA_LEN_MAX 160
static bool close_timing_log(void); /* forward */
static void _stm_profiling_event(stm_thread_local_t *tl,
enum stm_event_e event,
- stm_loc_marker_t *marker)
+ stm_timing_event_payload_t *payload)
{
struct buf_s {
uint32_t tv_sec;
uint32_t tv_nsec;
uint32_t thread_num;
uint8_t event;
-uint8_t marker_length;
-char extra[MARKER_LEN_MAX+1];
+uint8_t extra_length;
+char extra[EXTRA_LEN_MAX+1];
} __attribute__((packed));
struct buf_s buf;
struct timespec t;
buf.thread_num = tl->thread_local_counter;
buf.event = event;
-buf.marker_length = 0;
+buf.extra_length = 0;
-if (marker != NULL && marker->odd_number != 0) {
-buf.marker_length = profiling_expand_marker(get_segment_base(0),
-marker,
-buf.extra, MARKER_LEN_MAX);
+if (payload != NULL) {
+if (payload->type == STM_EVENT_PAYLOAD_MARKER) {
+stm_loc_marker_t *marker = payload->data.loc_marker;
+if (marker != NULL && marker->odd_number != 0) {
+buf.extra_length = profiling_expand_marker(get_segment_base(0),
+marker,
+buf.extra,
EXTRA_LEN_MAX);
+}
+} else if (payload->type == STM_EVENT_PAYLOAD_DURATION) {
+uint32_t duration = payload->data.duration;
+buf.extra_length = sprintf(buf.extra, "%u", duration);
+}
}
-size_t result, outsize = offsetof(struct buf_s, extra) + buf.marker_length;
+size_t result, outsize = offsetof(struct buf_s, extra) + buf.extra_length;
FILE *f = profiling_file;
if (f == NULL)
return;
@@ -146,3 +154,7 @@
profiling_basefn = strdup(profiling_file_name);
return 0;
}
+
+void (*stmcb_timing_event)(stm_thread_local_t *tl, /* the local thread */
+ enum stm_event_e event,
+ stm_timing_event_payload_t *payload);
diff --git a/c8/stmgc.h b/c8/stmgc.h
--- a/c8/stmgc.h
+++ b/c8/stmgc.h
@@ -596,6 +596,7 @@
"gc minor done",\
"gc major start", \
"gc major done"
+/* TODO names for new duration events */
/* The markers pushed in the shadowstack are an odd number followed by a
regular object pointer. */
@@ -616,12 +617,12 @@
} stm_timing_event_payload_data_t;
/* Wrapper for payload holding data type and data. */
typedef struct {
-enum stm_payload_type_e payload_type;
-stm_timing_event_payload_data_t payload_data;
+enum stm_payload_type_e type;
+stm_timing_event_payload_data_t data;
} stm_timing_event_payload_t;
extern void (*stmcb_timing_event)(stm_thread_local_t *tl, /* the local thread
*/
enum stm_event_e event,
- stm_loc_marker_t *marker);
+ stm_timing
[pypy-commit] stmgc c8-efficient-serial-execution: Add names of duration events
Author: tobias@masterthesis-vm Branch: c8-efficient-serial-execution Changeset: r2022:ea8cfda82123 Date: 2017-03-03 15:18 +0100 http://bitbucket.org/pypy/stmgc/changeset/ea8cfda82123/ Log:Add names of duration events diff --git a/c8/stmgc.h b/c8/stmgc.h --- a/c8/stmgc.h +++ b/c8/stmgc.h @@ -595,8 +595,13 @@ "gc minor start", \ "gc minor done",\ "gc major start", \ -"gc major done" -/* TODO names for new duration events */ +"gc major done",\ +/* names of duration events */ \ +"duration of write slowpath", \ +"duration of validation", \ +"duration of commit", \ +"duration of minor gc", \ +"duration of major gc" /* The markers pushed in the shadowstack are an odd number followed by a regular object pointer. */ ___ pypy-commit mailing list [email protected] https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] stmgc c8-efficient-serial-execution: Add macros for timing instrumentation
Author: tobias@masterthesis-vm
Branch: c8-efficient-serial-execution
Changeset: r2023:f1f7a2e83f3c
Date: 2017-03-06 10:55 +0100
http://bitbucket.org/pypy/stmgc/changeset/f1f7a2e83f3c/
Log:Add macros for timing instrumentation
diff --git a/c8/stm/prof.c b/c8/stm/prof.c
--- a/c8/stm/prof.c
+++ b/c8/stm/prof.c
@@ -39,8 +39,11 @@
buf.extra,
EXTRA_LEN_MAX);
}
} else if (payload->type == STM_EVENT_PAYLOAD_DURATION) {
-uint32_t duration = payload->data.duration;
-buf.extra_length = sprintf(buf.extra, "%u", duration);
+struct timespec *duration = payload->data.duration;
+buf.extra_length = sprintf(buf.extra,
+"s%un%u",
+duration->tv_sec,
+duration->tv_nsec);
}
}
diff --git a/c8/stm/timing.h b/c8/stm/timing.h
new file mode 100644
--- /dev/null
+++ b/c8/stm/timing.h
@@ -0,0 +1,16 @@
+#include
+
+/* Use raw monotonic time, i.e., solely based on local hardware (no NTP
+ adjustments) as in prof.c to obtain values comparable with total program
+ runtime. */
+#define start_timer() struct timespec start; \
+ clock_gettime(CLOCK_MONOTONIC_RAW, &start);
+
+#define stop_timer() struct timespec stop; \
+ clock_gettime(CLOCK_MONOTONIC_RAW, &stop);
+
+/* Must use start_timer and stop_timer before using this macro. */
+#define get_duration() struct timespec duration = { \
+ stop.tv_sec - start.tv_sec, \
+ stop.tv_nsec - start.tv_nsec \
+ };
diff --git a/c8/stmgc.h b/c8/stmgc.h
--- a/c8/stmgc.h
+++ b/c8/stmgc.h
@@ -201,7 +201,7 @@
/* PUBLIC API */
/* Number of segments (i.e. how many transactions can be executed in
- parallel, in maximum). If you try to start transactions in more
+ parallel, at maximum). If you try to start transactions in more
threads than the number of segments, it will block, waiting for the
next segment to become free.
*/
@@ -616,9 +616,11 @@
_STM_EVENT_PAYLOAD_N
};
+
+#include
typedef union {
stm_loc_marker_t *loc_marker;
-uint32_t duration;
+struct timespec *duration;
} stm_timing_event_payload_data_t;
/* Wrapper for payload holding data type and data. */
typedef struct {
___
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] stmgc c8-efficient-serial-execution: Add macros to log duration measurements using a timing event
Author: tobias@masterthesis-vm
Branch: c8-efficient-serial-execution
Changeset: r2024:39dec57efb62
Date: 2017-03-06 11:36 +0100
http://bitbucket.org/pypy/stmgc/changeset/39dec57efb62/
Log:Add macros to log duration measurements using a timing event
diff --git a/c8/stm/marker.c b/c8/stm/marker.c
--- a/c8/stm/marker.c
+++ b/c8/stm/marker.c
@@ -3,9 +3,6 @@
# include "core.h" // silence flymake
#endif
-#define payload(marker) stm_timing_event_payload_data_t data = { &marker }; \
-stm_timing_event_payload_t payload = { \
-STM_EVENT_PAYLOAD_MARKER, data };
static bool marker_fetch(stm_thread_local_t *tl, stm_loc_marker_t *out_marker)
{
@@ -95,16 +92,18 @@
stm_loc_marker_t marker;
marker_fetch_obj_write(start, contention, &marker);
-payload(marker)
+stm_marker_payload(marker)
stmcb_timing_event(STM_SEGMENT->running_thread,
- STM_CONTENTION_WRITE_READ, &payload);
+ STM_CONTENTION_WRITE_READ,
+ &stm_marker_payload);
}
static void _timing_become_inevitable(void)
{
stm_loc_marker_t marker;
marker_fetch(STM_SEGMENT->running_thread, &marker);
-payload(marker)
+stm_marker_payload(marker)
stmcb_timing_event(STM_SEGMENT->running_thread,
- STM_BECOME_INEVITABLE, &payload);
+ STM_BECOME_INEVITABLE,
+ &stm_marker_payload);
}
diff --git a/c8/stm/marker.h b/c8/stm/marker.h
--- a/c8/stm/marker.h
+++ b/c8/stm/marker.h
@@ -16,6 +16,12 @@
#define timing_become_inevitable() \
(timing_enabled() ? _timing_become_inevitable() : (void)0)
+#define stm_marker_payload(marker) \
+stm_timing_event_payload_data_t stm_marker_data = \
+{ .loc_marker = &marker }; \
+stm_timing_event_payload_t stm_marker_payload = \
+{ STM_EVENT_PAYLOAD_MARKER, stm_marker_data };
+
static inline void emit_wait(stm_thread_local_t *tl, enum stm_event_e event)
{
diff --git a/c8/stm/prof.c b/c8/stm/prof.c
--- a/c8/stm/prof.c
+++ b/c8/stm/prof.c
@@ -42,8 +42,8 @@
struct timespec *duration = payload->data.duration;
buf.extra_length = sprintf(buf.extra,
"s%un%u",
-duration->tv_sec,
-duration->tv_nsec);
+(uint32_t)duration->tv_sec,
+(uint32_t)duration->tv_nsec);
}
}
diff --git a/c8/stm/timing.h b/c8/stm/timing.h
--- a/c8/stm/timing.h
+++ b/c8/stm/timing.h
@@ -14,3 +14,17 @@
stop.tv_sec - start.tv_sec, \
stop.tv_nsec - start.tv_nsec \
};
+
+#define stm_duration_payload(duration) \
+stm_timing_event_payload_data_t stm_duration_data = \
+{ .duration = &duration }; \
+stm_timing_event_payload_t stm_duration_payload =\
+{ STM_EVENT_PAYLOAD_DURATION, stm_duration_data };
+
+#define publish_event(event) \
+stmcb_timing_event(STM_SEGMENT->running_thread, event,
&stm_duration_payload);
+
+#define stop_timer_and_publish(event) stop_timer() \
+ get_duration() \
+ stm_duration_payload(duration) \
+ publish_event(event)
___
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] stmgc c8-efficient-serial-execution: Adapt test interface of stmgc and fix crash if timing events are not enabled
Author: tobias@masterthesis-vm
Branch: c8-efficient-serial-execution
Changeset: r2026:3d8a3ec72e8a
Date: 2017-03-06 17:02 +0100
http://bitbucket.org/pypy/stmgc/changeset/3d8a3ec72e8a/
Log:Adapt test interface of stmgc and fix crash if timing events are not
enabled
diff --git a/c8/stm/timing.h b/c8/stm/timing.h
--- a/c8/stm/timing.h
+++ b/c8/stm/timing.h
@@ -22,7 +22,9 @@
{ STM_EVENT_PAYLOAD_DURATION, stm_duration_data };
#define publish_event(event) \
-stmcb_timing_event(STM_SEGMENT->running_thread, event,
&stm_duration_payload);
+(timing_enabled() ? \
+stmcb_timing_event(STM_SEGMENT->running_thread, event,
&stm_duration_payload) : \
+(void)0);
#define stop_timer_and_publish(event) stop_timer() \
get_duration() \
diff --git a/c8/test/support.py b/c8/test/support.py
--- a/c8/test/support.py
+++ b/c8/test/support.py
@@ -180,7 +180,7 @@
};
typedef union {
stm_loc_marker_t *loc_marker;
-uint32_t duration;
+struct timespec *duration;
} stm_timing_event_payload_data_t;
/* Wrapper for payload holding data type and data. */
typedef struct {
___
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] stmgc c8-efficient-serial-execution: Instrument write barrier slowpath
Author: tobias@masterthesis-vm
Branch: c8-efficient-serial-execution
Changeset: r2025:39847b4aa093
Date: 2017-03-06 12:23 +0100
http://bitbucket.org/pypy/stmgc/changeset/39847b4aa093/
Log:Instrument write barrier slowpath
diff --git a/c8/stm/core.c b/c8/stm/core.c
--- a/c8/stm/core.c
+++ b/c8/stm/core.c
@@ -959,7 +959,9 @@
__attribute__((flatten))
void _stm_write_slowpath(object_t *obj) {
+start_timer()
write_slowpath_common(obj, /* mark_card */ false);
+stop_timer_and_publish(STM_DURATION_WRITE_BARRIER)
}
diff --git a/c8/stm/core.h b/c8/stm/core.h
--- a/c8/stm/core.h
+++ b/c8/stm/core.h
@@ -15,6 +15,7 @@
#include
#include
#include "list.h"
+#include "timing.h"
//
diff --git a/c8/stmgc.c b/c8/stmgc.c
--- a/c8/stmgc.c
+++ b/c8/stmgc.c
@@ -22,6 +22,7 @@
#include "stm/detach.h"
#include "stm/hashtable.h"
#include "stm/queue.h"
+#include "stm/timing.h"
#include "stm/misc.c"
#include "stm/list.c"
diff --git a/c8/stmgc.h b/c8/stmgc.h
--- a/c8/stmgc.h
+++ b/c8/stmgc.h
@@ -642,7 +642,6 @@
the given position and with the given maximum length. */
typedef int (*stm_expand_marker_fn)(char *seg_base, stm_loc_marker_t *marker,
char *output, int output_size);
-/* TODO generalize expand function */
int stm_set_timing_log(const char *profiling_file_name, int fork_mode,
stm_expand_marker_fn expand_marker);
___
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit
