[pypy-commit] pypy stmgc-c7: Reduce the limit of inevitable transactions instead of setting it to 0.
Raemi
noreply at buildbot.pypy.org
Tue May 13 10:48:51 CEST 2014
Author: Remi Meier <remi.meier at inf.ethz.ch>
Branch: stmgc-c7
Changeset: r71481:4c7f65787861
Date: 2014-05-13 10:48 +0200
http://bitbucket.org/pypy/pypy/changeset/4c7f65787861/
Log: Reduce the limit of inevitable transactions instead of setting it to
0. Depend a bit on stmcb_commit_soon() in order for other
transactions to signal us in case we block them.
diff --git a/rpython/translator/stm/src_stm/stmgcintf.c b/rpython/translator/stm/src_stm/stmgcintf.c
--- a/rpython/translator/stm/src_stm/stmgcintf.c
+++ b/rpython/translator/stm/src_stm/stmgcintf.c
@@ -29,7 +29,7 @@
/* atomic */
pypy_stm_nursery_low_fill_mark_saved = 0;
} else {
- pypy_stm_nursery_low_fill_mark >>= 2;
+ pypy_stm_nursery_low_fill_mark = 0;
}
}
@@ -101,12 +101,8 @@
}
}
-void pypy_stm_start_transaction(stm_jmpbuf_t *jmpbuf_ptr,
- volatile long *v_counter)
+void _pypy_stm_initialize_nursery_low_fill_mark(long v_counter)
{
- pypy_stm_nursery_low_fill_mark = 1; /* will be set to a correct value below */
- _stm_start_transaction(&stm_thread_local, jmpbuf_ptr);
-
/* If v_counter==0, initialize 'pypy_stm_nursery_low_fill_mark'
from the configured length limit. If v_counter>0, we did an
abort, and we now configure 'pypy_stm_nursery_low_fill_mark'
@@ -120,8 +116,7 @@
counter = _htm_info.retry_counter;
limit = pypy_transaction_length >> counter;
#else
- counter = *v_counter;
- *v_counter = counter + 1;
+ counter = v_counter;
if (counter == 0) {
limit = pypy_transaction_length;
@@ -133,6 +128,17 @@
#endif
pypy_stm_nursery_low_fill_mark = _stm_nursery_start + limit;
+}
+
+void pypy_stm_start_transaction(stm_jmpbuf_t *jmpbuf_ptr,
+ volatile long *v_counter)
+{
+ pypy_stm_nursery_low_fill_mark = 1; /* will be set to a correct value below */
+ _stm_start_transaction(&stm_thread_local, jmpbuf_ptr);
+
+ _pypy_stm_initialize_nursery_low_fill_mark(*v_counter);
+ *v_counter = *v_counter + 1;
+
pypy_stm_ready_atomic = 1; /* reset after abort */
}
@@ -157,8 +163,6 @@
transaction.
*/
assert(pypy_stm_nursery_low_fill_mark != (uintptr_t) -1);
- assert(!(STM_SEGMENT->jmpbuf_ptr == NULL) ||
- (pypy_stm_nursery_low_fill_mark == 0));
stm_commit_transaction();
@@ -195,8 +199,10 @@
//assert(pypy_stm_nursery_low_fill_mark != 0);
assert(pypy_stm_nursery_low_fill_mark != (uintptr_t) -1);
stm_commit_transaction();
- pypy_stm_nursery_low_fill_mark = 0;
+
stm_start_inevitable_transaction(&stm_thread_local);
+ _pypy_stm_initialize_nursery_low_fill_mark(0);
+ _pypy_stm_inev_state();
}
else {
assert(pypy_stm_nursery_low_fill_mark == (uintptr_t) -1);
@@ -206,8 +212,6 @@
}
/* double-check */
if (pypy_stm_ready_atomic == 1) {
- assert(!(STM_SEGMENT->jmpbuf_ptr == NULL) ||
- (pypy_stm_nursery_low_fill_mark == 0));
}
else {
assert(pypy_stm_nursery_low_fill_mark == (uintptr_t) -1);
@@ -219,14 +223,17 @@
assert(v_old_shadowstack == stm_thread_local.shadowstack);
}
-static void _pypy_stm_inev_state(void)
+void _pypy_stm_inev_state(void)
{
+ /* Reduce the limit so that inevitable transactions are generally
+ shorter. We depend a bit on stmcb_commit_soon() in order for
+ other transactions to signal us in case we block them. */
if (pypy_stm_ready_atomic == 1) {
- pypy_stm_nursery_low_fill_mark = 0;
+ pypy_stm_nursery_low_fill_mark >>= 2;
}
else {
assert(pypy_stm_nursery_low_fill_mark == (uintptr_t) -1);
- pypy_stm_nursery_low_fill_mark_saved = 0;
+ pypy_stm_nursery_low_fill_mark_saved >>= 2;
}
}
diff --git a/rpython/translator/stm/src_stm/stmgcintf.h b/rpython/translator/stm/src_stm/stmgcintf.h
--- a/rpython/translator/stm/src_stm/stmgcintf.h
+++ b/rpython/translator/stm/src_stm/stmgcintf.h
@@ -23,6 +23,9 @@
void pypy_stm_register_thread_local(void); /* generated into stm_prebuilt.c */
void pypy_stm_unregister_thread_local(void); /* generated into stm_prebuilt.c */
+void _pypy_stm_initialize_nursery_low_fill_mark(long v_counter);
+void _pypy_stm_inev_state(void);
+
void _pypy_stm_become_inevitable(const char *);
void pypy_stm_become_globally_unique_transaction(void);
@@ -52,8 +55,9 @@
static inline void pypy_stm_start_inevitable_if_not_atomic(void) {
if (pypy_stm_ready_atomic == 1) {
int e = errno;
- pypy_stm_nursery_low_fill_mark = 0;
stm_start_inevitable_transaction(&stm_thread_local);
+ _pypy_stm_initialize_nursery_low_fill_mark(0);
+ _pypy_stm_inev_state();
errno = e;
}
}
@@ -73,8 +77,6 @@
case 1:
pypy_stm_nursery_low_fill_mark = pypy_stm_nursery_low_fill_mark_saved;
assert(pypy_stm_nursery_low_fill_mark != (uintptr_t) -1);
- assert(!(STM_SEGMENT->jmpbuf_ptr == NULL) ||
- (pypy_stm_nursery_low_fill_mark == 0));
break;
case 0:
pypy_stm_ready_atomic = 1;
More information about the pypy-commit
mailing list