Author: Tobias Weber <[email protected]>
Branch: c8-adaptive-trx-length
Changeset: r2044:2d9a2b1a8249
Date: 2017-04-29 11:26 +0200
http://bitbucket.org/pypy/stmgc/changeset/2d9a2b1a8249/
Log: Implement quick and dirty adaptive mode prototype
diff --git a/c8/stm/core.c b/c8/stm/core.c
--- a/c8/stm/core.c
+++ b/c8/stm/core.c
@@ -289,6 +289,11 @@
/* conflict! */
dprintf(("_stm_validate() failed for obj %p\n", obj));
+ /* disregard race conditions */
+ if (stm_global_conflicts < stm_max_conflicts) {
+ stm_global_conflicts += 1;
+ }
+
/* first reset all modified objects from the backup
copies as soon as the first conflict is detected;
then we will proceed below to update our segment
@@ -1163,6 +1168,7 @@
if (repeat_count == 0) { /* else, 'nursery_mark' was already set
in abort_data_structures_from_segment_num() */
+ stm_update_transaction_length();
STM_SEGMENT->nursery_mark = ((stm_char *)_stm_nursery_start +
stm_fill_mark_nursery_bytes);
}
diff --git a/c8/stm/nursery.c b/c8/stm/nursery.c
--- a/c8/stm/nursery.c
+++ b/c8/stm/nursery.c
@@ -13,14 +13,26 @@
static uintptr_t _stm_nursery_start;
+#define DEFAULT_FILL_MARK_NURSERY_BYTES (NURSERY_SIZE / 4)
+#define LARGE_FILL_MARK_NURSERY_BYTES 0x3000000000000000L;
-#define DEFAULT_FILL_MARK_NURSERY_BYTES (NURSERY_SIZE / 4)
+// uintptr_t stm_fill_mark_nursery_bytes = DEFAULT_FILL_MARK_NURSERY_BYTES;
+uintptr_t stm_fill_mark_nursery_bytes = LARGE_FILL_MARK_NURSERY_BYTES;
-uintptr_t stm_fill_mark_nursery_bytes = DEFAULT_FILL_MARK_NURSERY_BYTES;
+static uint32_t stm_max_conflicts = 1000;
+static uint32_t stm_global_conflicts = 0;
+
+static void stm_update_transaction_length(void) {
+ float relative_conflicts = (float) stm_global_conflicts /
stm_max_conflicts;
+ uintptr_t max_reduction =
+ LARGE_FILL_MARK_NURSERY_BYTES - DEFAULT_FILL_MARK_NURSERY_BYTES;
+ stm_fill_mark_nursery_bytes =
+ LARGE_FILL_MARK_NURSERY_BYTES - (relative_conflicts * max_reduction);
+}
+
/************************************************************/
-
static void setup_nursery(void)
{
assert(_STM_FAST_ALLOC <= NURSERY_SIZE);
diff --git a/c8/stm/nursery.h b/c8/stm/nursery.h
--- a/c8/stm/nursery.h
+++ b/c8/stm/nursery.h
@@ -56,4 +56,9 @@
static inline struct object_s *mark_loc(object_t *obj);
static inline bool _is_from_same_transaction(object_t *obj);
+static uint32_t stm_max_conflicts;
+static uint32_t stm_global_conflicts;
+
+static void stm_update_transaction_length(void);
+
#endif
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit