Author: Remi Meier
Branch:
Changeset: r1100:49dc2a80331b
Date: 2014-03-27 13:05 +0100
http://bitbucket.org/pypy/stmgc/changeset/49dc2a80331b/
Log: tweaks and some stats
diff --git a/duhton/demo/micro_transactions.duh
b/duhton/demo/micro_transactions.duh
new file mode 100644
--- /dev/null
+++ b/duhton/demo/micro_transactions.duh
@@ -0,0 +1,18 @@
+
+
+
+(setq c (container 0))
+
+
+(defun increment ()
+ ;;(set c (+ (get c) 1))
+ )
+
+
+(setq n 0)
+(while (< n 10000000)
+ (transaction increment)
+ (setq n (+ n 1))
+ )
+
+(run-transactions)
diff --git a/htm-c7/stmgc.c b/htm-c7/stmgc.c
--- a/htm-c7/stmgc.c
+++ b/htm-c7/stmgc.c
@@ -13,6 +13,10 @@
#define ABORT_GIL_LOCKED 1
+static __thread int gil_transactions = 0;
+static __thread int htm_transactions = 0;
+
+
#define smp_spinloop() asm volatile ("pause":::"memory")
static void acquire_gil(stm_thread_local_t *tl) {
@@ -75,10 +79,12 @@
if (mutex_locked(&_stm_gil)) {
gil_retry_counter--;
if (gil_retry_counter > 0) {
- if (spin_and_acquire_gil(tl))
+ if (spin_and_acquire_gil(tl)) {
return;
- else
+ } else {
+ smp_spinloop();
goto transaction_retry;
+ }
}
acquire_gil(tl);
} else if (is_persistent(status)) {
@@ -86,8 +92,10 @@
} else {
/* transient abort */
transient_retry_counter--;
- if (transient_retry_counter > 0)
+ if (transient_retry_counter > 0) {
+ smp_spinloop();
goto transaction_retry;
+ }
acquire_gil(tl);
}
@@ -104,14 +112,23 @@
if (mutex_locked(&_stm_gil)) {
assert(!xtest());
if (pthread_mutex_unlock(&_stm_gil) != 0) abort();
- fprintf(stderr, "G");
+ gil_transactions++;
+ //fprintf(stderr, "G");
} else {
xend();
- fprintf(stderr, "H");
+ htm_transactions++;
+ //fprintf(stderr, "H");
}
}
+void stm_unregister_thread_local(stm_thread_local_t *tl) {
+ fprintf(stderr,
+ "in %p\ngil_transactions: %d\nhtm_transactions: %d\nratio: %f\n",
+ tl, gil_transactions, htm_transactions,
+ (float)gil_transactions / (float)htm_transactions);
+ free(tl->shadowstack_base);
+}
diff --git a/htm-c7/stmgc.h b/htm-c7/stmgc.h
--- a/htm-c7/stmgc.h
+++ b/htm-c7/stmgc.h
@@ -77,9 +77,7 @@
tl->shadowstack = tl->shadowstack_base;
tl->last_abort__bytes_in_nursery = 0;
}
-inline static void stm_unregister_thread_local(stm_thread_local_t *tl) {
- free(tl->shadowstack_base);
-}
+void stm_unregister_thread_local(stm_thread_local_t *tl);
extern pthread_mutex_t _stm_gil;
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit