Author: Armin Rigo <[email protected]>
Branch: stm-thread-2
Changeset: r61453:33549d9b2cbd
Date: 2013-02-19 10:53 +0100
http://bitbucket.org/pypy/pypy/changeset/33549d9b2cbd/
Log: Found it: by making the cache more efficient, len(gcptrlist) doesn't
increase much any more, but it was used as an indicator for starting
the next transaction. This would make very long transactions for no
reason.
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,6 +43,7 @@
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. */
int active; /* 0 = inactive, 1 = regular, 2 = inevitable */
int readonly_updates;
@@ -134,6 +135,7 @@
static inline gcptr AddInReadSet(struct tx_descriptor *d, gcptr R)
{
+ d->count_reads++;
if (!fxcache_add(&d->recent_reads_cache, R)) {
/* not in the cache: it may be the first time we see it,
* so insert it into the list */
@@ -245,6 +247,7 @@
assert(L->h_tid & GCFLAG_NOT_WRITTEN); /* must not be set in the 1st place */
L->h_revision = (revision_t)R; /* back-reference to the original */
g2l_insert(&d->global_to_local, R, L);
+ d->count_reads++;
gcptrlist_insert(&d->list_of_read_objects, R);
return L;
}
@@ -377,7 +380,7 @@
/* upon abort, set the reads size limit to 94% of how much was read
so far. This should ensure that, assuming the retry does the same
thing, it will commit just before it reaches the conflicting point. */
- limit = d->list_of_read_objects.size;
+ limit = d->count_reads;
if (limit > 0) {
limit -= (limit >> 4);
d->reads_size_limit_nonatomic = limit;
@@ -417,6 +420,7 @@
assert(d->list_of_read_objects.size == 0);
assert(d->gcroots.size == 0);
assert(!g2l_any_entry(&d->global_to_local));
+ d->count_reads = 0;
fxcache_clear(&d->recent_reads_cache);
}
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
@@ -91,7 +91,7 @@
reads_size_limit_nonatomic to 0 in that case.
- finally, the default case: return True if
- d->list_of_read_objects.size is
+ d->count_reads is
greater than reads_size_limit == reads_size_limit_nonatomic.
*/
#ifdef RPY_STM_ASSERT
@@ -105,7 +105,7 @@
assert(d->reads_size_limit_nonatomic == 0);
#endif
- return d->list_of_read_objects.size >= d->reads_size_limit;
+ return d->count_reads >= d->reads_size_limit;
}
void stm_set_transaction_length(long length_max)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit