[pypy-commit] pypy stm-thread-2: Now we need to increase a bit the checkinterval().
arigo
noreply at buildbot.pypy.org
Tue Feb 19 11:21:25 CET 2013
Author: Armin Rigo <arigo at tunes.org>
Branch: stm-thread-2
Changeset: r61454:edea071e1cf5
Date: 2013-02-19 11:21 +0100
http://bitbucket.org/pypy/pypy/changeset/edea071e1cf5/
Log: Now we need to increase a bit the checkinterval().
diff --git a/pypy/module/thread/stm.py b/pypy/module/thread/stm.py
--- a/pypy/module/thread/stm.py
+++ b/pypy/module/thread/stm.py
@@ -19,9 +19,9 @@
"""NOT_RPYTHON: set up a mechanism to send to the C code the value
set by space.actionflag.setcheckinterval()."""
#
- # Set the default checkinterval to 50000, found by exploration to
+ # Set the default checkinterval to 200000, found by exploration to
# be a good default value. XXX do some more in-depth tests
- space.actionflag.setcheckinterval(50000)
+ space.actionflag.setcheckinterval(200000)
#
def setcheckinterval_callback():
self.configure_transaction_length(space)
diff --git a/rpython/translator/stm/src_stm/et.c b/rpython/translator/stm/src_stm/et.c
--- a/rpython/translator/stm/src_stm/et.c
+++ b/rpython/translator/stm/src_stm/et.c
@@ -43,8 +43,9 @@
revision_t start_time;
revision_t my_lock;
long atomic; /* 0 = not atomic, > 0 atomic */
- long count_reads;
- long reads_size_limit, reads_size_limit_nonatomic; /* see should_break_tr. */
+ unsigned long count_reads;
+ unsigned long reads_size_limit; /* see should_break_tr. */
+ unsigned long reads_size_limit_nonatomic;
int active; /* 0 = inactive, 1 = regular, 2 = inevitable */
int readonly_updates;
unsigned int num_commits;
@@ -369,7 +370,7 @@
static void AbortTransaction(int num)
{
struct tx_descriptor *d = thread_descriptor;
- long limit;
+ unsigned long limit;
assert(d->active);
assert(!is_inevitable(d));
assert(num < ABORT_REASONS);
@@ -409,9 +410,9 @@
static void update_reads_size_limit(struct tx_descriptor *d)
{
- /* 'reads_size_limit' is set to LONG_MAX if we are atomic; else
+ /* 'reads_size_limit' is set to ULONG_MAX if we are atomic; else
we copy the value from reads_size_limit_nonatomic. */
- d->reads_size_limit = d->atomic ? LONG_MAX : d->reads_size_limit_nonatomic;
+ d->reads_size_limit = d->atomic ? ULONG_MAX : d->reads_size_limit_nonatomic;
}
static void init_transaction(struct tx_descriptor *d)
diff --git a/rpython/translator/stm/src_stm/rpyintf.c b/rpython/translator/stm/src_stm/rpyintf.c
--- a/rpython/translator/stm/src_stm/rpyintf.c
+++ b/rpython/translator/stm/src_stm/rpyintf.c
@@ -62,7 +62,7 @@
return is_inevitable(d);
}
-static long stm_regular_length_limit = LONG_MAX;
+static unsigned long stm_regular_length_limit = ULONG_MAX;
void stm_add_atomic(long delta)
{
@@ -84,7 +84,7 @@
/* a single comparison to handle all cases:
- if d->atomic, then we should return False. This is done by
- forcing reads_size_limit to LONG_MAX as soon as atomic > 0.
+ forcing reads_size_limit to ULONG_MAX as soon as atomic > 0.
- otherwise, if is_inevitable(), then we should return True.
This is done by forcing both reads_size_limit and
@@ -95,9 +95,9 @@
greater than reads_size_limit == reads_size_limit_nonatomic.
*/
#ifdef RPY_STM_ASSERT
- /* reads_size_limit is LONG_MAX if d->atomic, or else it is equal to
+ /* reads_size_limit is ULONG_MAX if d->atomic, or else it is equal to
reads_size_limit_nonatomic. */
- assert(d->reads_size_limit == (d->atomic ? LONG_MAX :
+ assert(d->reads_size_limit == (d->atomic ? ULONG_MAX :
d->reads_size_limit_nonatomic));
/* if is_inevitable(), reads_size_limit_nonatomic should be 0
(and thus reads_size_limit too, if !d->atomic.) */
@@ -105,13 +105,15 @@
assert(d->reads_size_limit_nonatomic == 0);
#endif
- return d->count_reads >= d->reads_size_limit;
+ return d->count_reads > d->reads_size_limit;
}
void stm_set_transaction_length(long length_max)
{
struct tx_descriptor *d = thread_descriptor;
BecomeInevitable("set_transaction_length");
+ if (length_max <= 0)
+ length_max = 1;
stm_regular_length_limit = length_max;
}
@@ -160,7 +162,7 @@
When such a shortened transaction succeeds, the next one will
see its length limit doubled, up to the maximum. */
if (counter == 0) {
- long limit = d->reads_size_limit_nonatomic;
+ unsigned long limit = d->reads_size_limit_nonatomic;
if (limit != 0 && limit < (stm_regular_length_limit >> 1))
limit = (limit << 1) | 1;
else
diff --git a/rpython/translator/stm/test/richards.py b/rpython/translator/stm/test/richards.py
--- a/rpython/translator/stm/test/richards.py
+++ b/rpython/translator/stm/test/richards.py
@@ -439,9 +439,12 @@
if len(sys.argv) > 2:
max_num_threads = int(sys.argv[2])
assert max_num_threads <= iterations
+ if len(sys.argv) > 3:
+ sys.setcheckinterval(int(sys.argv[3]))
else:
iterations = 10
num_threads = min(iterations, max_num_threads)
- print "Running %d iterations on %d threads" % (iterations, num_threads)
+ print "Running %d iterations on %d threads; checkinterval=%d" % (
+ iterations, num_threads, sys.getcheckinterval())
transaction.set_num_threads(num_threads)
main(iterations = iterations)
More information about the pypy-commit
mailing list