[pypy-commit] stmgc c8-private-pages: re-introduce the total_allocated counter
Raemi
noreply at buildbot.pypy.org
Thu Jan 15 18:42:59 CET 2015
Author: Remi Meier <remi.meier at inf.ethz.ch>
Branch: c8-private-pages
Changeset: r1530:749fe619048d
Date: 2015-01-15 10:44 +0100
http://bitbucket.org/pypy/stmgc/changeset/749fe619048d/
Log: re-introduce the total_allocated counter
diff --git a/c8/stm/gcpage.h b/c8/stm/gcpage.h
--- a/c8/stm/gcpage.h
+++ b/c8/stm/gcpage.h
@@ -2,6 +2,13 @@
/* Granularity when grabbing more unused pages: take 20 at a time */
#define GCPAGE_NUM_PAGES 20
+/* More parameters fished directly from PyPy's default GC
+ XXX document me */
+#define GC_MIN (NB_NURSERY_PAGES * 4096 * 8)
+#define GC_MAJOR_COLLECT 1.82
+
+
+
static char *uninitialized_page_start; /* within segment 0 */
static char *uninitialized_page_stop;
diff --git a/c8/stm/largemalloc.c b/c8/stm/largemalloc.c
--- a/c8/stm/largemalloc.c
+++ b/c8/stm/largemalloc.c
@@ -352,6 +352,7 @@
}
mscan->size = request_size;
mscan->prev_size = BOTH_CHUNKS_USED;
+ increment_total_allocated(request_size + LARGE_MALLOC_OVERHEAD);
#ifndef NDEBUG
memset((char *)&mscan->d, 0xda, request_size);
#endif
@@ -367,6 +368,7 @@
assert(chunk->prev_size != THIS_CHUNK_FREE);
/* 'size' is at least MIN_ALLOC_SIZE */
+ increment_total_allocated(-(chunk->size + LARGE_MALLOC_OVERHEAD));
#ifndef NDEBUG
{
diff --git a/c8/stm/misc.c b/c8/stm/misc.c
--- a/c8/stm/misc.c
+++ b/c8/stm/misc.c
@@ -99,4 +99,9 @@
return NULL;
return _last_cl_entry->written[_last_cl_entry_index++].object;
}
+
+uint64_t _stm_total_allocated(void)
+{
+ return increment_total_allocated(0);
+}
#endif
diff --git a/c8/stm/pages.c b/c8/stm/pages.c
--- a/c8/stm/pages.c
+++ b/c8/stm/pages.c
@@ -4,16 +4,37 @@
#include <unistd.h>
/************************************************************/
+struct {
+ volatile bool major_collection_requested;
+ uint64_t total_allocated; /* keep track of how much memory we're
+ using, ignoring nurseries */
+ uint64_t total_allocated_bound;
+} pages_ctl;
+
static void setup_pages(void)
{
+ pages_ctl.total_allocated_bound = GC_MIN;
}
static void teardown_pages(void)
{
+ memset(&pages_ctl, 0, sizeof(pages_ctl));
memset(pages_status, 0, sizeof(pages_status));
}
+static uint64_t increment_total_allocated(ssize_t add_or_remove)
+{
+ uint64_t ta = __sync_add_and_fetch(&pages_ctl.total_allocated,
+ add_or_remove);
+
+ if (ta >= pages_ctl.total_allocated_bound)
+ pages_ctl.major_collection_requested = true;
+
+ return ta;
+}
+
+
/************************************************************/
@@ -30,6 +51,9 @@
/* set this flag *after* we un-protected it, because XXX later */
set_page_status_in(segnum, pagenum, PAGE_ACCESSIBLE);
+
+ // XXX: maybe?
+ //increment_total_allocated(4096);
}
__attribute__((unused))
@@ -47,4 +71,7 @@
perror("mprotect");
stm_fatalerror("mprotect failed! Consider running 'sysctl vm.max_map_count=16777216'");
}
+
+ // XXX: maybe?
+ //increment_total_allocated(-4096);
}
diff --git a/c8/stm/pages.h b/c8/stm/pages.h
--- a/c8/stm/pages.h
+++ b/c8/stm/pages.h
@@ -43,6 +43,8 @@
static void page_mark_accessible(long segnum, uintptr_t pagenum);
static void page_mark_inaccessible(long segnum, uintptr_t pagenum);
+static uint64_t increment_total_allocated(ssize_t add_or_remove);
+
static inline char *get_virtual_page(long segnum, uintptr_t pagenum)
{
diff --git a/c8/stmgc.h b/c8/stmgc.h
--- a/c8/stmgc.h
+++ b/c8/stmgc.h
@@ -109,6 +109,8 @@
object_t *_stm_enum_objects_pointing_to_nursery(long index);
object_t *_stm_next_last_cl_entry();
void _stm_start_enum_last_cl_entry();
+
+uint64_t _stm_total_allocated(void);
#endif
/* ==================== HELPERS ==================== */
diff --git a/c8/test/support.py b/c8/test/support.py
--- a/c8/test/support.py
+++ b/c8/test/support.py
@@ -80,6 +80,7 @@
object_t * _get_ptr(object_t *obj, int n);
void stm_collect(long level);
+uint64_t _stm_total_allocated(void);
void _stm_set_nursery_free_count(uint64_t free_count);
void _stm_largemalloc_init_arena(char *data_start, size_t data_size);
More information about the pypy-commit
mailing list