[Top][All Lists]

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

Re: [PATCH] Configure GMP to use GC allocation functions, remove bignum

From: Andy Wingo
Subject: Re: [PATCH] Configure GMP to use GC allocation functions, remove bignum finalizers
Date: Sun, 27 Nov 2011 20:33:08 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux)


An old thread, but one that would be good to fix.  To recap, Mark Weaver

> Without this patch, computing (factorial 100000), where factorial is
> implemented using the straightforward iterative approach below, causes
> Guile to allocate a huge amount of memory.  This happens because the
> majority of the memory used by large bignums (the digits themselves) is
> not allocated by the GC, and so the GC doesn't run until a huge amount
> of memory has been allocated.

We talked about allocating the gmp memory with libgc, but there was
concern about other gmp users in the same Guile process.

On Wed 01 Jun 2011 10:34, Andy Wingo <address@hidden> writes:

> On Wed 01 Jun 2011 01:18, Neil Jerram <address@hidden> writes:
>> Provide an API to allow the trade-off to be decided by the application
>> developer?
> I think this only makes sense as an interim measure, like if we want to
> change GMP to allocate only via GC_malloc in 2.2, then provide the
> option in 2.0.  There has to be a better long-term solution though.
> What if we get libgc to track total heap size (whether the user has
> malloc, g_slice_alloc, or whatever), and start doing GC more frequently
> if it sees the total heap size going up?

I still this this is a good idea.  The key would be to GC more often
when the heap image grows faster than GC'd memory is allocated.  We can
detect this situation by computing (ImageSize_t+1 - ImageSize_t) /
(LiveBytes_t+1 - LiveBytes_t), where ImageSize is some measure of the
total process size, perhaps via getrusage(), and LiveBytes is
GC_get_heap_size() - GC_get_free_bytes().

We could probably prototype this ourselves, outside of libgc, using
GC_set_free_space_divisor as the knob to tweak.  If it is generally
applicable we could make a patch to incorporate this in libgc proper.



reply via email to

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