[pypy-commit] stmgc default: fix total_allocated accounting (caused a flood of major collections after some
Remi Meier
noreply at buildbot.pypy.org
Mon Apr 7 14:49:25 CEST 2014
Author: Remi Meier
Branch:
Changeset: r1140:cfd37feb0f23
Date: 2014-04-07 14:50 +0200
http://bitbucket.org/pypy/stmgc/changeset/cfd37feb0f23/
Log: fix total_allocated accounting (caused a flood of major collections
after some time)
diff --git a/c7/stm/gcpage.c b/c7/stm/gcpage.c
--- a/c7/stm/gcpage.c
+++ b/c7/stm/gcpage.c
@@ -80,7 +80,6 @@
/* thread-safe: use the lock of pages.c to prevent any remapping
from occurring under our feet */
mutex_pages_lock();
- increment_total_allocated(size + LARGE_MALLOC_OVERHEAD);
/* Allocate the object with largemalloc.c from the lower addresses. */
char *addr = _stm_large_malloc(size);
diff --git a/c7/stm/largemalloc.c b/c7/stm/largemalloc.c
--- a/c7/stm/largemalloc.c
+++ b/c7/stm/largemalloc.c
@@ -52,6 +52,7 @@
#define BOTH_CHUNKS_USED 0
#define CHUNK_HEADER_SIZE offsetof(struct malloc_chunk, d)
#define END_MARKER 0xDEADBEEF
+#define MIN_ALLOC_SIZE (sizeof(struct malloc_chunk) - CHUNK_HEADER_SIZE)
#define chunk_at_offset(p, ofs) ((mchunk_t *)(((char *)(p)) + (ofs)))
#define data2chunk(p) chunk_at_offset(p, -CHUNK_HEADER_SIZE)
@@ -88,7 +89,7 @@
The additional chunks of a given size are linked "vertically" in
the secondary 'u' doubly-linked list.
-
+
+-----+
| 296 |
+-----+
@@ -258,8 +259,8 @@
/* it can be very small, but we need to ensure a minimal size
(currently 32 bytes) */
- if (request_size < sizeof(struct malloc_chunk) - CHUNK_HEADER_SIZE)
- request_size = sizeof(struct malloc_chunk) - CHUNK_HEADER_SIZE;
+ if (request_size < MIN_ALLOC_SIZE)
+ request_size = MIN_ALLOC_SIZE;
size_t index = largebin_index(request_size);
sort_bin(index);
@@ -333,6 +334,7 @@
}
mscan->size = request_size;
mscan->prev_size = BOTH_CHUNKS_USED;
+ increment_total_allocated(request_size + LARGE_MALLOC_OVERHEAD);
return (char *)&mscan->d;
}
@@ -343,6 +345,9 @@
assert((chunk->size & (sizeof(char *) - 1)) == 0);
assert(chunk->prev_size != THIS_CHUNK_FREE);
+ /* 'size' is at least MIN_ALLOC_SIZE */
+ increment_total_allocated(-(chunk->size + LARGE_MALLOC_OVERHEAD));
+
#ifndef NDEBUG
assert(chunk->size >= sizeof(dlist_t));
assert(chunk->size <= (((char *)last_chunk) - (char *)data));
@@ -554,7 +559,6 @@
chunk = next_chunk(chunk); /* go to the first non-free chunk */
while (chunk != last_chunk) {
-
/* here, the chunk we're pointing to is not free */
assert(chunk->prev_size != THIS_CHUNK_FREE);
@@ -566,8 +570,6 @@
/* use the callback to know if 'chunk' contains an object that
survives or dies */
if (!_largemalloc_sweep_keep(chunk)) {
- size_t size = chunk->size;
- increment_total_allocated(-(size + LARGE_MALLOC_OVERHEAD));
_stm_large_free((char *)&chunk->d); /* dies */
}
chunk = mnext;
diff --git a/c7/stm/nursery.c b/c7/stm/nursery.c
--- a/c7/stm/nursery.c
+++ b/c7/stm/nursery.c
@@ -243,7 +243,6 @@
}
char *realobj = REAL_ADDRESS(pseg->pub.segment_base, item->addr);
ssize_t size = stmcb_size_rounded_up((struct object_s *)realobj);
- increment_total_allocated(-(size + LARGE_MALLOC_OVERHEAD));
_stm_large_free(stm_object_pages + item->addr);
} TREE_LOOP_END;
More information about the pypy-commit
mailing list