[pypy-svn] r77097 - in pypy/branch/gen2-gc/pypy/rpython/memory/gc: . test
arigo at codespeak.net
arigo at codespeak.net
Wed Sep 15 18:27:06 CEST 2010
Author: arigo
Date: Wed Sep 15 18:27:04 2010
New Revision: 77097
Modified:
pypy/branch/gen2-gc/pypy/rpython/memory/gc/minimarkpage.py
pypy/branch/gen2-gc/pypy/rpython/memory/gc/test/test_minimarkpage.py
Log:
Track the number of pages that are currently in use.
Modified: pypy/branch/gen2-gc/pypy/rpython/memory/gc/minimarkpage.py
==============================================================================
--- pypy/branch/gen2-gc/pypy/rpython/memory/gc/minimarkpage.py (original)
+++ pypy/branch/gen2-gc/pypy/rpython/memory/gc/minimarkpage.py Wed Sep 15 18:27:04 2010
@@ -74,6 +74,11 @@
self.uninitialized_pages = PAGE_NULL
self.num_uninitialized_pages = 0
self.free_pages = NULL
+ self.used_pages = 0 # number of pages at least partially filled
+
+
+ def pages_in_use(self):
+ return self.used_pages
def malloc(self, size):
@@ -150,6 +155,7 @@
ll_assert(self.page_for_size[size_class] == PAGE_NULL,
"allocate_new_page() called but a page is already waiting")
self.page_for_size[size_class] = result
+ self.used_pages += 1
return result
@@ -258,6 +264,7 @@
llarena.arena_reserve(pageaddr, llmemory.sizeof(llmemory.Address))
pageaddr.address[0] = self.free_pages
self.free_pages = pageaddr
+ self.used_pages -= 1
def walk_page(self, page, block_size, nblocks, ok_to_free_func):
Modified: pypy/branch/gen2-gc/pypy/rpython/memory/gc/test/test_minimarkpage.py
==============================================================================
--- pypy/branch/gen2-gc/pypy/rpython/memory/gc/test/test_minimarkpage.py (original)
+++ pypy/branch/gen2-gc/pypy/rpython/memory/gc/test/test_minimarkpage.py Wed Sep 15 18:27:04 2010
@@ -39,23 +39,27 @@
#
ac = ArenaCollection(arenasize, pagesize, 99)
assert ac.num_uninitialized_pages == 0
+ assert ac.used_pages == 0
#
page = ac.allocate_new_page(5)
checknewpage(page, 5)
assert ac.num_uninitialized_pages == 2
assert ac.uninitialized_pages - pagesize == cast_ptr_to_adr(page)
assert ac.page_for_size[5] == page
+ assert ac.used_pages == 1
#
page = ac.allocate_new_page(3)
checknewpage(page, 3)
assert ac.num_uninitialized_pages == 1
assert ac.uninitialized_pages - pagesize == cast_ptr_to_adr(page)
assert ac.page_for_size[3] == page
+ assert ac.used_pages == 2
#
page = ac.allocate_new_page(4)
checknewpage(page, 4)
assert ac.num_uninitialized_pages == 0
assert ac.page_for_size[4] == page
+ assert ac.used_pages == 3
def arena_collection_for_test(pagesize, pagelayout, fill_with_objects=False):
@@ -389,7 +393,8 @@
def test_random():
import random
pagesize = hdrsize + 24*WORD
- ac = arena_collection_for_test(pagesize, " " * 28)
+ num_pages = 28
+ ac = arena_collection_for_test(pagesize, " " * num_pages)
live_objects = {}
#
# Run the test until ac.allocate_new_arena() is called.
@@ -422,3 +427,4 @@
except DoneTesting:
# the following output looks cool on a 112-character-wide terminal.
print ac._startpageaddr.arena.usagemap
+ assert ac.used_pages == num_pages
More information about the Pypy-commit
mailing list