Author: Remi Meier <remi.me...@inf.ethz.ch> Branch: Changeset: r1205:b0dd12f874f8 Date: 2014-05-08 17:32 +0200 http://bitbucket.org/pypy/stmgc/changeset/b0dd12f874f8/
Log: try to reduce the commit-time overhead a bit (adds to all other threads as sync-pause time) diff --git a/c7/stm/contention.c b/c7/stm/contention.c --- a/c7/stm/contention.c +++ b/c7/stm/contention.c @@ -98,13 +98,14 @@ /************************************************************/ -static void contention_management(uint8_t other_segment_num, +static bool contention_management(uint8_t other_segment_num, enum contention_kind_e kind, object_t *obj) { assert(_has_mutex()); assert(other_segment_num != STM_SEGMENT->segment_num); + bool others_may_have_run = false; if (must_abort()) abort_with_mutex(); @@ -152,6 +153,7 @@ if (contmgr.try_sleep && kind != WRITE_WRITE_CONTENTION && contmgr.other_pseg->safe_point != SP_WAIT_FOR_C_TRANSACTION_DONE) { + others_may_have_run = true; /* Sleep. - Not for write-write contentions, because we're not at a @@ -225,6 +227,7 @@ if (must_abort()) abort_with_mutex(); + others_may_have_run = true; dprintf(("contention: wait C_ABORTED...\n")); cond_wait(C_ABORTED); dprintf(("contention: done\n")); @@ -278,6 +281,7 @@ stmcb_commit_soon(); } } + return others_may_have_run; } static void write_write_contention_management(uintptr_t lock_idx, @@ -301,10 +305,10 @@ s_mutex_unlock(); } -static void write_read_contention_management(uint8_t other_segment_num, +static bool write_read_contention_management(uint8_t other_segment_num, object_t *obj) { - contention_management(other_segment_num, WRITE_READ_CONTENTION, obj); + return contention_management(other_segment_num, WRITE_READ_CONTENTION, obj); } static void inevitable_contention_management(uint8_t other_segment_num) diff --git a/c7/stm/contention.h b/c7/stm/contention.h --- a/c7/stm/contention.h +++ b/c7/stm/contention.h @@ -1,7 +1,7 @@ static void write_write_contention_management(uintptr_t lock_idx, object_t *obj); -static void write_read_contention_management(uint8_t other_segment_num, +static bool write_read_contention_management(uint8_t other_segment_num, object_t *obj); static void inevitable_contention_management(uint8_t other_segment_num); diff --git a/c7/stm/core.c b/c7/stm/core.c --- a/c7/stm/core.c +++ b/c7/stm/core.c @@ -286,13 +286,15 @@ ({ if (was_read_remote(remote_base, item, remote_version)) { /* A write-read conflict! */ - write_read_contention_management(i, item); - - /* If we reach this point, we didn't abort, but maybe we - had to wait for the other thread to commit. If we - did, then we have to restart committing from our call - to synchronize_all_threads(). */ - return true; + if (write_read_contention_management(i, item)) { + /* If we reach this point, we didn't abort, but we + had to wait for the other thread to commit. If we + did, then we have to restart committing from our call + to synchronize_all_threads(). */ + return true; + } + /* we aborted the other transaction without waiting, so + we can just continue */ } })); } @@ -501,6 +503,9 @@ /* the call to minor_collection() above leaves us with STM_TIME_BOOKKEEPING */ + /* synchronize overflow objects living in privatized pages */ + push_overflow_objects_from_privatized_pages(); + s_mutex_lock(); restart: @@ -520,11 +525,11 @@ STM_SEGMENT->jmpbuf_ptr = NULL; /* if a major collection is required, do it here */ - if (is_major_collection_requested()) + if (is_major_collection_requested()) { + int oldstate = change_timing_state(STM_TIME_MAJOR_GC); major_collection_now_at_safe_point(); - - /* synchronize overflow objects living in privatized pages */ - push_overflow_objects_from_privatized_pages(); + change_timing_state(oldstate); + } /* synchronize modified old objects to other threads */ push_modified_to_other_segments(); _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit