[pypy-commit] stmgc c7-refactor: A first real test for nursery collection. Fails
arigo
noreply at buildbot.pypy.org
Sun Feb 23 15:29:55 CET 2014
Author: Armin Rigo <arigo at tunes.org>
Branch: c7-refactor
Changeset: r813:07aa2f23e825
Date: 2014-02-23 14:40 +0100
http://bitbucket.org/pypy/stmgc/changeset/07aa2f23e825/
Log: A first real test for nursery collection. Fails
diff --git a/c7/stm/gcpage.c b/c7/stm/gcpage.c
--- a/c7/stm/gcpage.c
+++ b/c7/stm/gcpage.c
@@ -24,10 +24,6 @@
free_uniform_pages = NULL;
}
-//static void check_gcpage_still_shared(void)
-//{
-// //...;
-//}
#define GCPAGE_NUM_PAGES 20
diff --git a/c7/stm/gcpage.h b/c7/stm/gcpage.h
--- a/c7/stm/gcpage.h
+++ b/c7/stm/gcpage.h
@@ -43,7 +43,6 @@
static void setup_gcpage(void);
static void teardown_gcpage(void);
-//static void check_gcpage_still_shared(void);
static char *allocate_outside_nursery_large(uint64_t size);
diff --git a/c7/stm/nursery.c b/c7/stm/nursery.c
--- a/c7/stm/nursery.c
+++ b/c7/stm/nursery.c
@@ -29,6 +29,7 @@
static union {
struct {
uint64_t used; /* number of bytes from the nursery used so far */
+ uint64_t initial_value_of_used;
};
char reserved[64];
} nursery_ctl __attribute__((aligned(64)));
@@ -51,6 +52,7 @@
static void teardown_nursery(void)
{
list_free(old_objects_pointing_to_young);
+ nursery_ctl.initial_value_of_used = 0;
}
static inline bool _is_in_nursery(object_t *obj)
@@ -289,7 +291,7 @@
static void reset_nursery(void)
{
/* reset the global amount-of-nursery-used-so-far */
- nursery_ctl.used = 0;
+ nursery_ctl.used = nursery_ctl.initial_value_of_used;
/* reset the write locks */
memset(write_locks + ((NURSERY_START >> 4) - READMARKER_START),
@@ -332,7 +334,7 @@
if (old_end > NURSERY_START) {
char *creation_markers = REAL_ADDRESS(other_pseg->pub.segment_base,
NURSERY_START >> 8);
- assert(old_end < NURSERY_START + NURSERY_SIZE);
+ assert(old_end <= NURSERY_START + NURSERY_SIZE);
memset(creation_markers, 0, (old_end - NURSERY_START) >> 8);
}
else {
@@ -371,8 +373,6 @@
information).
*/
- //check_gcpage_still_shared();
-
collect_roots_in_nursery();
long i;
@@ -516,5 +516,6 @@
assert(free_count == NURSERY_ALIGN(free_count));
assert(nursery_ctl.used <= NURSERY_SIZE - free_count);
nursery_ctl.used = NURSERY_SIZE - free_count;
+ nursery_ctl.initial_value_of_used = nursery_ctl.used;
}
#endif
diff --git a/c7/test/test_nursery.py b/c7/test/test_nursery.py
--- a/c7/test/test_nursery.py
+++ b/c7/test/test_nursery.py
@@ -58,10 +58,31 @@
self.pop_root()
#
self.push_root(lp1)
- lp2 = stm_allocate(16)
+ lp2 = stm_allocate(SOME_MEDIUM_SIZE)
lp1b = self.pop_root()
assert lp1b != lp1 # collection occurred
+ def test_several_minor_collections(self):
+ # make a long, ever-growing linked list of objects, in one transaction
+ lib._stm_set_nursery_free_count(NURSERY_SECTION_SIZE * 2)
+ self.start_transaction()
+ lp1 = stm_allocate(16)
+ self.push_root(lp1)
+ lp2 = lp1
+ N = (NURSERY_SECTION_SIZE * 5) / 16
+ for i in range(N):
+ self.push_root(lp2)
+ lp3 = stm_allocate(16)
+ lp2 = self.pop_root()
+ stm_set_ref(lp2, 0, lp3)
+ lp2 = lp3
+ lp1 = self.pop_root()
+ lp2 = lp1
+ for i in range(N):
+ assert lp2
+ lp2 = stm_get_ref(lp2, 0)
+ assert lp2 == lp3
+
def test_many_allocs(self):
obj_size = 1024
num = (lib.NB_NURSERY_PAGES * 4096) / obj_size + 100 # more than what fits in the nursery
More information about the pypy-commit
mailing list