[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: User setting of GC Threshold
- From: "Peter Hill" <corwin@...>
- Date: Wed, 26 Feb 2003 17:29:02 +0800
Peter Hill:
> It seems rather limiting to me to just allow this one predefined
> auto-threshold. It would be more flexible to permit the user to define an
> automatic post-GC function which is called upon completion of GC with the
> current memory info, and which returns the new desired threshold.
Roberto Ierusalimschy:
> (I leave this "automatic post-GC function" as an exercise. Hints:
> * "automatic post-GC function" -> gc metamethod
> * "current memory info" -> lua_getgcthreshold/count"
> * "returns the new desired threshold" -> lua_setgcthreshold
Ok, I'll pass that on to the PLua list. It isn't a solution I normally would
have considered because (a) it is not obvious from the manual (and hence not
to be relied upon) that the new post-GC threshold level would already have
been determined & available before the __gc metamethods were run and (b)
since setting a new threshold can cause an immediate GC, it seems rather
dangerous to me to do so inside a __gc metamethod (which itself is called as
an ongoing part of the *current* GC).
> 1) Programming is rather limiting.
??? 8-O
> 2) "The cheapest, fastest, and more reliable components of a system are
> those that aren't there." Or, as Asko pointed out, "Every additional
> feature also adds to the learning curve, documentation pages, etc.
> etc.".
>
> 3) When we stop asking for new features, we have more time (and
> motivation) to realize how to implement them.
True. I agree with both of those in principle, and I heartily support the
goal of minimising Lua.
But... "Every additional feature also adds to the learning curve,
documentation pages, etc. etc." is not always the case.
In some cases removed features can be so commonly used (and hence
re-implemented by the user) that they become default features despite not
being official. So one still has to wade through documentation... except now
there may be several slightly different versions :-(.
And in some cases adding a feature may reduce documentation. To add the GC
threshold solution you have suggested above requires that the Lua manual
contain additional documentation explaining at what phase during GCing the
threshold is set, and what limitations are placed upon setting the threshold
(and hence potentially initiating a new GC cycle) within a __gc metamethod.
Or you could add the line "Upon completion of GC the method _THRESHOLD is
called to establish the new threshold..." and skip all that. :-)
*cheers*
Peter Hill.