Author: Remi Meier <[email protected]>
Branch: card-marking
Changeset: r1229:49532f4219aa
Date: 2014-05-22 11:28 +0200
http://bitbucket.org/pypy/stmgc/changeset/49532f4219aa/
Log: try to detect when an object is fully marked
diff --git a/c7/stm/core.c b/c7/stm/core.c
--- a/c7/stm/core.c
+++ b/c7/stm/core.c
@@ -469,7 +469,7 @@
if (i == myself)
continue;
- src = REAL_ADDRESS(stm_object_pages, start);
+ /* src = REAL_ADDRESS(stm_object_pages, start); */
dst = REAL_ADDRESS(get_segment_base(i), start);
if (is_private_page(i, first_page)) {
/* The page is a private page. We need to diffuse this
@@ -504,6 +504,21 @@
uintptr_t last_card_index = get_card_index(obj_size - 1);
long i, myself = STM_SEGMENT->segment_num;
+ /* simple heuristic to check if probably the whole object is
+ marked anyway so we can do page-wise synchronize */
+ if (write_locks[first_card_index + 1] == CARD_MARKED_OLD
+ && write_locks[first_card_index + last_card_index] == CARD_MARKED_OLD
+ && write_locks[first_card_index + (last_card_index >> 1) + 1] ==
CARD_MARKED_OLD) {
+
+ dprintf(("card_wise_sync assumes %p,size:%lu is fully marked\n", obj,
obj_size));
+ _reset_object_cards(get_priv_segment(STM_SEGMENT->segment_num),
+ obj, CARD_CLEAR, false);
+ _page_wise_synchronize_object_now(obj);
+ return;
+ }
+
+ dprintf(("card_wise_sync syncs %p,size:%lu card-wise\n", obj, obj_size));
+
while (card_index <= last_card_index) {
uintptr_t card_lock_idx = first_card_index + card_index;
@@ -532,6 +547,8 @@
dst = REAL_ADDRESS(get_segment_base(i), start);
memcpy(dst, src, copy_size);
}
+ } else {
+ assert(write_locks[card_lock_idx] != CARD_MARKED); /* always only
MARKED_OLD */
}
card_index++;
diff --git a/c7/stmgc.h b/c7/stmgc.h
--- a/c7/stmgc.h
+++ b/c7/stmgc.h
@@ -148,7 +148,7 @@
#define _STM_GCFLAG_WRITE_BARRIER 0x01
#define _STM_GCFLAG_HAS_CARDS 0x08
#define _STM_GCFLAG_CARDS_SET 0x10
-#define _STM_CARD_SIZE 32 /* 16 may be safe too */
+#define _STM_CARD_SIZE 32 /* >= 32 */
#define _STM_NSE_SIGNAL_MAX _STM_TIME_N
#define _STM_FAST_ALLOC (66*1024)
diff --git a/c7/test/test_random.py b/c7/test/test_random.py
--- a/c7/test/test_random.py
+++ b/c7/test/test_random.py
@@ -368,7 +368,7 @@
#"SOME_MEDIUM_SIZE+16",
#"SOME_LARGE_SIZE+16",
])
- with_cards = int(size) >= 32
+ with_cards = int(size) >= 32 and global_state.rnd.randrange(1, 100) > 10
r = global_state.get_new_root_name(False, size, with_cards)
thread_state.push_roots(ex)
@@ -382,7 +382,7 @@
def op_allocate_ref(ex, global_state, thread_state):
num = str(global_state.rnd.randrange(1, 100))
- with_cards = int(num) >= 4
+ with_cards = int(num) >= 4 and global_state.rnd.randrange(1, 100) > 10
r = global_state.get_new_root_name(True, num, with_cards)
thread_state.push_roots(ex)
ex.do('%s = stm_allocate_refs(%s, %s)' % (r, num, bool(with_cards)))
@@ -417,7 +417,7 @@
r = thread_state.get_random_root()
trs = thread_state.transaction_state
is_ref = global_state.has_ref_type(r)
- has_cards = global_state.has_cards(r)
+ has_cards = global_state.has_cards(r) and global_state.rnd.randrange(1,
100) > 5
#
# check for possible write-write conflict:
was_written = False
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit