help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] Big objects and GC


From: Gwenael Casaccio
Subject: Re: [Help-smalltalk] Big objects and GC
Date: Wed, 11 May 2011 13:47:21 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110424 Lightning/1.0b2 Thunderbird/3.1.10

On 05/11/2011 11:45 AM, Paolo Bonzini wrote:

Here is the patch, all the tests are green ;-)

Nice patch!

I have a few comments.

diff --git a/libgst/oop.c b/libgst/oop.c
index ad264d9..018ec95 100644
--- a/libgst/oop.c
+++ b/libgst/oop.c
@@ -66,6 +66,7 @@

/* Define this flag to turn on debugging code for OOP table management */
/* #define GC_DEBUGGING */
+#define GC_DEBUGGING

Spurious change.

@@ -701,7 +702,7 @@ _gst_make_oop_fixed (OOP oop)
{
gst_object newObj;
int size;
- if (oop->flags & F_FIXED)
+ if ((oop->flags & F_FIXED) || (oop->flags & F_LARGE))
return;

Can you try representing large objects with F_FIXED but not F_OLD? At
the same time, makeFixed would not cause objects to become old, which is
useful for objects passed to C.

Apparently, I even had some code to handle this in _gst_tenure_oop:

if (oop->flags & F_OLD)
return;

if (!(oop->flags & F_FIXED))
{
int size = SIZE_TO_BYTES (TO_INT(oop->object->objSize));
newObj = (gst_object) _gst_mem_alloc (_gst_mem.old, size);
if (!newObj)
abort ();

memcpy (newObj, oop->object, size);
_gst_mem.numOldOOPs++;

oop->object = newObj;
}

where the increment of numOldOOPs should be moved outside the if.

@@ -780,6 +781,38 @@ _gst_alloc_obj (size_t size,
}

gst_object
+_gst_alloc_large_obj (size_t size,
+ OOP *p_oop)
+{
+ gst_object p_instance;
+
+ size = ROUNDED_BYTES (size);
+
+ /* If the object is big enough, we put it directly in fixedspace. */
+ p_instance = (gst_object) _gst_mem_alloc (_gst_mem.fixed, size);
+ if COMMON (p_instance)
+ goto ok;
+
+ _gst_global_gc (size);
+ p_instance = (gst_object) _gst_mem_alloc (_gst_mem.fixed, size);
+ if COMMON (p_instance)
+ goto ok;
+
+ _gst_compact (0);

Compacting is not going to be helpful, for fixed objects.

@@ -1452,7 +1485,7 @@ _gst_sweep_oop (OOP oop)
_gst_make_oop_non_weak (oop);

/* Free unreachable oldspace objects. */
- if UNCOMMON (oop->flags & F_FIXED)
+ if UNCOMMON ((oop->flags & F_FIXED) || (oop->flags & F_LARGE))
{
_gst_mem.numOldOOPs--;

This makes stats wrong. With the idea above, the code would be like:

if ((oop->flags & F_LOADED) == 0)
{
if UNCOMMON (oop->flags & F_FIXED)
_gst_mem_free (_gst_mem.fixed, oop->object);
else if UNCOMMON (oop->flags & F_OLD)
_gst_mem_free (_gst_mem.old, oop->object);
}

if UNCOMMON (oop->flags & F_OLD)
{
_gst_mem.numOldOOPs--;
stats.reclaimedOldSpaceBytesSinceLastGlobalGC +=
SIZE_TO_BYTES (TO_INT (OOP_TO_OBJ (oop)->objSize));
}

It is a very good start though, thanks!

Paolo

Here is the new patch, I've removed like you've said the F_LARGE and make the F_FIXED working with both new and old generation the spurious change is removed ;-). I've included your idea just swap the two if because the memory can be freed before the size is accessed.

Gwen

Attachment: large-oop.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]