Author: Remi Meier <remi.me...@inf.ethz.ch> Branch: c8-private-pages Changeset: r1538:6872a592d2bd Date: 2015-01-16 15:31 +0100 http://bitbucket.org/pypy/stmgc/changeset/6872a592d2bd/
Log: uncomment some important code for resizing largemalloc when grabbing new pages for smallmalloc... diff --git a/c8/stm/gcpage.c b/c8/stm/gcpage.c --- a/c8/stm/gcpage.c +++ b/c8/stm/gcpage.c @@ -9,7 +9,7 @@ static void setup_gcpage(void) { char *base = stm_object_pages + END_NURSERY_PAGE * 4096UL; - uintptr_t length = (NB_PAGES - END_NURSERY_PAGE) * 4096UL; + uintptr_t length = NB_SHARED_PAGES * 4096UL; _stm_largemalloc_init_arena(base, length); uninitialized_page_start = stm_object_pages + END_NURSERY_PAGE * 4096UL; diff --git a/c8/stm/largemalloc.c b/c8/stm/largemalloc.c --- a/c8/stm/largemalloc.c +++ b/c8/stm/largemalloc.c @@ -32,7 +32,7 @@ typedef struct malloc_chunk { size_t prev_size; /* - if the previous chunk is free: size of its data - otherwise, if this chunk is free: 1 - - otherwise, 0. */ + - otherwise, 0. both chunks used */ size_t size; /* size of the data in this chunk */ dlist_t d; /* if free: a doubly-linked list 'largebins' */ @@ -393,6 +393,7 @@ /* unlink the following chunk */ unlink_chunk(mscan); + #ifndef NDEBUG mscan->prev_size = (size_t)-258; /* 0xfffffffffffffefe */ mscan->size = (size_t)-515; /* 0xfffffffffffffdfd */ diff --git a/c8/stm/smallmalloc.c b/c8/stm/smallmalloc.c --- a/c8/stm/smallmalloc.c +++ b/c8/stm/smallmalloc.c @@ -62,10 +62,8 @@ uninitialized_page_stop -= decrease_by; first_small_uniform_loc = uninitialized_page_stop - stm_object_pages; - /* XXX: */ - /* char *base = stm_object_pages + END_NURSERY_PAGE * 4096UL; */ - /* if (!_stm_largemalloc_resize_arena(uninitialized_page_stop - base)) */ - /* goto out_of_memory; */ + if (!_stm_largemalloc_resize_arena(uninitialized_page_stop - uninitialized_page_start)) + goto out_of_memory; /* make writable in sharing seg */ setup_N_pages(uninitialized_page_stop, GCPAGE_NUM_PAGES); diff --git a/c8/test/test_largemalloc.py b/c8/test/test_largemalloc.py --- a/c8/test/test_largemalloc.py +++ b/c8/test/test_largemalloc.py @@ -49,6 +49,25 @@ # lib._stm_large_dump() + def test_random_sweep(self): + @ffi.callback("bool(char *)") + def keep(data): + print "keep?", data, data not in to_free + return data not in to_free + lib._stm_largemalloc_keep = keep + + OBJS = 6 + FREE = 2 + random.seed(12) + for _ in range(100): + allocd = {lib._stm_large_malloc(64) for _ in range(OBJS)} + while allocd: + to_free = set(random.sample(allocd, min(FREE, len(allocd)))) + print "allocd", allocd, "free", to_free + lib._stm_largemalloc_sweep() + allocd -= to_free + + def test_overflow_1(self): d = lib._stm_large_malloc(self.size - 32) assert ra(d) == self.rawmem + 16 _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit