[pypy-commit] stmgc c8-tcp-style-trx-length: Distinguish min and default trx length to allow shrinking to single instruction level

tobweber pypy.commits at gmail.com
Mon Jul 31 19:23:00 EDT 2017


Author: Tobias Weber <tobias_weber89 at gmx.de>
Branch: c8-tcp-style-trx-length
Changeset: r2132:c6265dd2c77c
Date: 2017-07-21 11:29 +0200
http://bitbucket.org/pypy/stmgc/changeset/c6265dd2c77c/

Log:	Distinguish min and default trx length to allow shrinking to single
	instruction level

diff --git a/c8/stm/nursery.c b/c8/stm/nursery.c
--- a/c8/stm/nursery.c
+++ b/c8/stm/nursery.c
@@ -22,12 +22,18 @@
 // #define LARGE_FILL_MARK_NURSERY_BYTES   0x1000000000000000L
 
 // corresponds to ~4 KB nursery fill
-#define STM_MIN_RELATIVE_TRANSACTION_LENGTH (0.000001)
+#define STM_DEFAULT_REL_TRANSACTION_LENGTH (0.000001)
+// commit after ~4 B or likely after every instruction
+#define STM_MIN_RELATIVE_TRANSACTION_LENGTH (0.000000001)
+
 #define BACKOFF_COUNT (10)
-#define BACKOFF_MULTIPLIER (BACKOFF_COUNT / -log10(STM_MIN_RELATIVE_TRANSACTION_LENGTH))
+#define BACKOFF_MULTIPLIER (BACKOFF_COUNT / -log10(STM_DEFAULT_REL_TRANSACTION_LENGTH))
 
 static inline void set_backoff(stm_thread_local_t *tl, double rel_trx_len) {
-    // the shorter the trx, the more backoff: 100 at min trx length, proportional decrease to 5 at max trx length (think a/x + b = backoff)
+    /* the shorter the trx, the more backoff:
+    think a*x + b = backoff, x := -log(rel-trx-len),
+    backoff is <BACKOFF_COUNT> + b at default trx length,
+    linear decrease to b at max trx length */
     tl->transaction_length_backoff =
         (int)((BACKOFF_MULTIPLIER * -log10(rel_trx_len)) + 5);
     // printf("thread %d, backoff %d\n", tl->thread_local_counter, tl->transaction_length_backoff);
diff --git a/c8/stm/setup.c b/c8/stm/setup.c
--- a/c8/stm/setup.c
+++ b/c8/stm/setup.c
@@ -247,7 +247,7 @@
     tl->thread_local_counter = ++thread_local_counters;
 
     /* init adaptive transaction length mode */
-    tl->relative_transaction_length = STM_MIN_RELATIVE_TRANSACTION_LENGTH;
+    tl->relative_transaction_length = STM_DEFAULT_REL_TRANSACTION_LENGTH;
     tl->transaction_length_backoff = 0;
     tl->linear_transaction_length_increment = 0;
 


More information about the pypy-commit mailing list