[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-smalltalk] the garbage collector is not doing its job
From: |
Derek Zhou |
Subject: |
Re: [Help-smalltalk] the garbage collector is not doing its job |
Date: |
Tue, 20 Jan 2009 22:09:21 -0800 |
User-agent: |
KMail/1.9.9 |
On Monday 19 January 2009 12:34:02 am Paolo Bonzini wrote:
> I actually applied this patch instead, but you must be thanked anyway
> for the debugging.
While I was fooling around with the GC code, I found a few more minor issues:
* nearly all GCs trigger compaction, which sounds wasteful.
* heap limit never shrink. So GC can be slow even if the real memory
consumption has come down from a high peak.
* the GC statistic is not right.
Here is a patch I made to address them:
--- orig/libgst/oop.c
+++ mod/libgst/oop.c
@@ -1120,12 +1121,24 @@
{
old_limit = MAX (old_limit, _gst_mem.old->heap_total);
- /* Check if it's time to compact the heap. */
+ /* if memory is still low, go all the way on sweeping */
if UNCOMMON ((next_allocation + _gst_mem.old->heap_total)
* 100.0 / old_limit > _gst_mem.grow_threshold_percent)
{
- s = "done, heap compacted";
- _gst_compact (0);
+ int target_limit;
+ _gst_finish_incremental_gc ();
+
+ /* Check if it's time to compact the heap. Compactions make the most
+ sense if there were lots of garbage. And the heap limit is shrunk
+ to avoid excessive garbage accumulation in the next round */
+ target_limit = (next_allocation + _gst_mem.old->heap_total) *
+ (100.0 + _gst_mem.space_grow_rate) /
_gst_mem.grow_threshold_percent;
+ if UNCOMMON ( target_limit < old_limit)
+ {
+ s = "done, heap compacted";
+ _gst_compact (0);
+ grow_memory_no_compact (target_limit);
+ }
}
/* Check if it's time to grow the heap. */
@@ -1280,10 +1292,13 @@
_gst_mem.live_flags &= ~F_REACHABLE;
_gst_mem.live_flags |= F_OLD;
- _gst_mem.reclaimedBytesPerGlobalGC =
- _gst_mem.factor * stats.reclaimedOldSpaceBytesSinceLastGlobalGC +
- (1 - _gst_mem.factor) * _gst_mem.reclaimedBytesPerScavenge;
-
+ if (stats.reclaimedOldSpaceBytesSinceLastGlobalGC)
+ {
+ _gst_mem.reclaimedBytesPerGlobalGC =
+ _gst_mem.factor * stats.reclaimedOldSpaceBytesSinceLastGlobalGC +
+ (1 - _gst_mem.factor) * _gst_mem.reclaimedBytesPerGlobalGC;
+ stats.reclaimedOldSpaceBytesSinceLastGlobalGC = 0;
+ }
#ifdef ENABLE_JIT_TRANSLATION
/* Go and really free the blocks associated to garbage collected
native code. */
- [Help-smalltalk] the garbage collector is not doing its job, Derek Zhou, 2009/01/17
- Re: [Help-smalltalk] the garbage collector is not doing its job, Derek Zhou, 2009/01/19
- Re: [Help-smalltalk] the garbage collector is not doing its job, Paolo Bonzini, 2009/01/19
- Re: [Help-smalltalk] the garbage collector is not doing its job, Paolo Bonzini, 2009/01/19
- Re: [Help-smalltalk] the garbage collector is not doing its job,
Derek Zhou <=
- Re: [Help-smalltalk] the garbage collector is not doing its job, Paolo Bonzini, 2009/01/21
- Re: [Help-smalltalk] the garbage collector is not doing its job, Derek Zhou, 2009/01/21
- [Help-smalltalk] Re: the garbage collector is not doing its job, Paolo Bonzini, 2009/01/21
- [Help-smalltalk] Re: the garbage collector is not doing its job, Derek Zhou, 2009/01/21
- [Help-smalltalk] Re: the garbage collector is not doing its job, Paolo Bonzini, 2009/01/23
- Re: [Help-smalltalk] the garbage collector is not doing its job, Derek Zhou, 2009/01/21