Author: Tobias Weber <[email protected]>
Branch: c8-adaptive-trx-length-per-thread
Changeset: r2063:6074cbac03a5
Date: 2017-05-17 12:22 +0200
http://bitbucket.org/pypy/stmgc/changeset/6074cbac03a5/
Log: Initialize single thread mode properties of thread local in setup.c
diff --git a/c8/stm/nursery.c b/c8/stm/nursery.c
--- a/c8/stm/nursery.c
+++ b/c8/stm/nursery.c
@@ -47,12 +47,7 @@
}
static void stm_transaction_length_handle_validation(stm_thread_local_t *tl,
bool aborts) {
- if (!tl->initialized) { // TODO move to setup.c
- tl->relative_transaction_length = STM_MIN_RELATIVE_TRANSACTION_LENGTH;
- tl->initialized = true;
- }
- double new = get_new_transaction_length(tl, aborts);
- tl->relative_transaction_length = new;
+ tl->relative_transaction_length = get_new_transaction_length(tl, aborts);
}
static uintptr_t stm_get_transaction_length(stm_thread_local_t *tl) {
diff --git a/c8/stm/setup.c b/c8/stm/setup.c
--- a/c8/stm/setup.c
+++ b/c8/stm/setup.c
@@ -245,6 +245,11 @@
numbers automatically. */
tl->last_associated_segment_num = num + 1;
tl->thread_local_counter = ++thread_local_counters;
+
+ /* init single thread mode */
+ tl->relative_transaction_length = STM_MIN_RELATIVE_TRANSACTION_LENGTH;
+ tl->transaction_length_backoff = 0;
+
*_get_cpth(tl) = pthread_self();
_init_shadow_stack(tl);
set_gs_register(get_segment_base(num + 1));
diff --git a/c8/stmgc.h b/c8/stmgc.h
--- a/c8/stmgc.h
+++ b/c8/stmgc.h
@@ -89,10 +89,11 @@
struct stm_thread_local_s *prev, *next;
intptr_t self_or_0_if_atomic;
void *creating_pthread[2];
- /* adaptive single thread mode */
+ /* == adaptive single thread mode == */
+ /* factor that is multiplied with max transaction length before the start
of the next transaction on this thread */
double relative_transaction_length;
+ /* when zero, transaction length may increase or decrease, otherwise
transaction length may only decrease. is (re-)set to some value upon abort and
counted down until zero upon successful validation. */
int transaction_length_backoff;
- bool initialized;
} stm_thread_local_t;
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit