Author: Tobias Weber <tobias_webe...@gmx.de> Branch: c8-tcp-style-trx-length Changeset: r2078:91207e4ad1b8 Date: 2017-06-26 12:22 +0200 http://bitbucket.org/pypy/stmgc/changeset/91207e4ad1b8/
Log: Implement TCP style linear transaction length increase after abort, exponential increase only initially or after a constant amount of transactions diff --git a/c8/stm/nursery.c b/c8/stm/nursery.c --- a/c8/stm/nursery.c +++ b/c8/stm/nursery.c @@ -21,26 +21,32 @@ #define LARGE_FILL_MARK_NURSERY_BYTES 0x1000000000L // #define LARGE_FILL_MARK_NURSERY_BYTES 0x1000000000000000L -#define STM_MIN_RELATIVE_TRANSACTION_LENGTH (0.00000001) +// corresponds to ~7 bytes nursery fill +#define STM_MIN_RELATIVE_TRANSACTION_LENGTH (0.0000000001) static double get_new_transaction_length(stm_thread_local_t *tl, bool aborts) { const int multiplier = 100; double previous = tl->relative_transaction_length; double new = previous; if (aborts) { - tl->transaction_length_backoff = 3; if (previous > STM_MIN_RELATIVE_TRANSACTION_LENGTH) { new = previous / multiplier; } else { - new = 0; + new = STM_MIN_RELATIVE_TRANSACTION_LENGTH; } + // the shorter the trx, the more backoff + tl->transaction_length_backoff = (int)(1 / new); + tl->linear_transaction_length_increment = new; } else if (tl->transaction_length_backoff == 0) { - if (previous - (STM_MIN_RELATIVE_TRANSACTION_LENGTH * 0.1) < 0) { - new = STM_MIN_RELATIVE_TRANSACTION_LENGTH; - } else if (previous < 1) { + // backoff counter is zero, exponential increase up to 1 + if (previous < 1) { new = previous * multiplier; } } else { // not abort and backoff != 0 + // in backoff, linear increase up to 1 + if (previous < 1) { + new = previous + tl->linear_transaction_length_increment; + } tl->transaction_length_backoff -= 1; } return new; diff --git a/c8/stm/setup.c b/c8/stm/setup.c --- a/c8/stm/setup.c +++ b/c8/stm/setup.c @@ -246,9 +246,10 @@ tl->last_associated_segment_num = num + 1; tl->thread_local_counter = ++thread_local_counters; - /* init single thread mode */ + /* init adaptive transaction length mode */ tl->relative_transaction_length = STM_MIN_RELATIVE_TRANSACTION_LENGTH; tl->transaction_length_backoff = 0; + tl->linear_transaction_length_increment = 0; *_get_cpth(tl) = pthread_self(); _init_shadow_stack(tl); diff --git a/c8/stmgc.h b/c8/stmgc.h --- a/c8/stmgc.h +++ b/c8/stmgc.h @@ -92,8 +92,10 @@ /* == 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. */ + /* when zero, transaction length may increase exponentially, otherwise transaction length may only increase linearly. is (re-)set to some value upon abort and counted down until zero upon successful validation. */ int transaction_length_backoff; + /* during the backoff, transaction length may increase linearly by this increment on every successful validation */ + double linear_transaction_length_increment; } stm_thread_local_t; _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit