gcl-devel
[Top][All Lists]
Advanced

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

[Gcl-devel] Re: alloca


From: Camm Maguire
Subject: [Gcl-devel] Re: alloca
Date: 09 Dec 2005 11:04:56 -0500
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Greetings!

Torbjorn Granlund <address@hidden> writes:

> Joe Keane <address@hidden> writes:
> 
>   I think the TMP_ALLOC is more trouble than it's worth.
>   
>   The alternative is, in every case, have a modest fixed-size local array;
>   use that, or `malloc' if needed, later `free' if needed.
>   
> This seems error prone, and would require massive changed of the
> sources.  I have a better idea:
> 
> Define TMP_SMALLOC and TMP_BALLOC, the former doing exacly what
> TMP_ALLOC does today with --enable-alloca, and TMP_BALLOC using
> the stack unconditionally, i.e., doing what TMP_ALLOC does today
> with --enable-alloca=malloc-reentrant.
> 
> TMP_ALLOC is changed to choose TMP_SALLOC under a threshold and
> TMP_BALLOC else.
> 
> This requires minimal changes, the only ones required are to
> gmp-impl.h, with optional changes at points where it is known the
> allocation is large or small.
> 
> And you know what?  It is already implemented and will come in
> GMP 4.2.  :-)
> 

This level of flexibility sounds great, thanks!

Just wanted to weigh in as GCL maintainer, stack allocation within gmp
is almost always a win for us.  It is still the case on most 32bit
machines that the heap is effectively limited to 1Gb by the default
shared lib placements commonly in use, leaving nearly twice as much for
stack(!).  Even if one compiles statically, working with more than a
2Gb heap often has significant limitations, in which case one still
has at least 1Gb of stack in principle.

At one time, we were quite sensitive to these internal details, but
now we are reliably independent as we control garbage collection in a
special wrapper around gmp functions (bignum bodies are much more
efficiently handled on relocatable pages).  Still, avoiding the memory
management system entirely with stack allocations will always be even
faster.

Take care,

> -- 
> Torbjörn
> _______________________________________________
> gmp-discuss mailing list
> address@hidden
> http://swox.com/mailman/listinfo/gmp-discuss
> 
> 
> 

-- 
Camm Maguire                                            address@hidden
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah




reply via email to

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