Author: Armin Rigo <[email protected]>
Branch: c7-full-profiling
Changeset: r1446:40660c139f6a
Date: 2014-10-04 14:47 +0200
http://bitbucket.org/pypy/stmgc/changeset/40660c139f6a/
Log: Fix demo2.c
diff --git a/c7/demo/demo2.c b/c7/demo/demo2.c
--- a/c7/demo/demo2.c
+++ b/c7/demo/demo2.c
@@ -3,6 +3,7 @@
#include <assert.h>
#include <pthread.h>
#include <semaphore.h>
+#include <time.h>
#ifdef USE_HTM
# include "../../htm-c7/stmgc.h"
@@ -59,12 +60,25 @@
}
void stmcb_commit_soon() {}
-static void expand_marker(char *base, uintptr_t odd_number,
- object_t *following_object,
- char *outputbuf, size_t outputbufsize)
+static void timing_event(stm_thread_local_t *tl, /* the local thread */
+ enum stm_event_e event,
+ stm_loc_marker_t *markers)
{
- assert(following_object == NULL);
- snprintf(outputbuf, outputbufsize, "<%p %lu>", base, odd_number);
+ static char *event_names[] = { STM_EVENT_NAMES };
+
+ char buf[1024], *p;
+ struct timespec tp;
+ clock_gettime(CLOCK_MONOTONIC, &tp);
+
+ p = buf;
+ p += sprintf(p, "{%.9f} %p %s", tp.tv_sec + 0.000000001 * tp.tv_nsec,
+ tl, event_names[event]);
+ if (markers != NULL) {
+ p += sprintf(p, ", markers: %lu, %lu",
+ markers[0].odd_number, markers[1].odd_number);
+ }
+ sprintf(p, "\n");
+ fputs(buf, stderr);
}
@@ -108,18 +122,6 @@
stm_start_transaction(&stm_thread_local);
- if (stm_thread_local.longest_marker_state != 0) {
- fprintf(stderr, "[%p] marker %d for %.6f seconds:\n",
- &stm_thread_local,
- stm_thread_local.longest_marker_state,
- stm_thread_local.longest_marker_time);
- fprintf(stderr, "\tself:\t\"%s\"\n\tother:\t\"%s\"\n",
- stm_thread_local.longest_marker_self,
- stm_thread_local.longest_marker_other);
- stm_thread_local.longest_marker_state = 0;
- stm_thread_local.longest_marker_time = 0.0;
- }
-
nodeptr_t prev = initial;
stm_read((objptr_t)prev);
@@ -223,7 +225,6 @@
void unregister_thread_local(void)
{
- stm_flush_timing(&stm_thread_local, 1);
stm_unregister_thread_local(&stm_thread_local);
}
@@ -296,7 +297,7 @@
stm_setup();
stm_register_thread_local(&stm_thread_local);
stm_rewind_jmp_enterframe(&stm_thread_local, &rjbuf);
- stmcb_expand_marker = expand_marker;
+ stmcb_timing_event = timing_event;
setup_list();
diff --git a/c7/stmgc.h b/c7/stmgc.h
--- a/c7/stmgc.h
+++ b/c7/stmgc.h
@@ -438,6 +438,23 @@
_STM_EVENT_N
};
+#define STM_EVENT_NAMES \
+ "transaction start", \
+ "transaction commit", \
+ "transaction abort", \
+ "contention write write", \
+ "contention write read", \
+ "contention inevitable", \
+ "aborting other contention", \
+ "wait free segment", \
+ "wait sync pause", \
+ "wait contention", \
+ "wait done", \
+ "gc minor start", \
+ "gc minor done", \
+ "gc major start", \
+ "gc major done"
+
/* The markers pushed in the shadowstack are an odd number followed by a
regular pointer. */
typedef struct {
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit