continuations to optimize code
Wed Dec 5 15:21:40 CET 2001
On 5 Dec 2001, Bjorn Gustavsson wrote:
>Was that a deep recursion?
Yes, it could be.
Your theory sounds quite plausible, and offers an explanation to
why a closure could be so much cheaper than a stack frame in
BTW, as the parser generates HTML as it goes along, quite a lot
of garbage is produced.
>Here is a theory that might partially explain your speedups.
>In the recursive case, you presumably get a big stack. At every
>garbage collection, all of the stack is scanned looking for
>live data. As the stack grows towards the heap, you could also
>get more frequent garbage collections than in the non-recursive
>case, and you would get fullsweep GCs (forcing copying of all
>In the non-recursive case, the root set for the GC is probably
>small (since the stack is presumably small). Each GC is
>presumably fast since the root set is small and your
>continuations are already on the older generation heap. Perhaps
>no fullsweeps are done, as your output function produces
>garbage, but only little or no more live data. Therefore the
>continuation data will stay on the older generation heap and
>not be copied very often.
>Just a bunch of guesses, based on unverified assumptions.
Ulf Wiger, Senior Specialist,
/ / / Architecture & Design of Carrier-Class Software
/ / / Strategic Product & System Management
/ / / Ericsson Telecom AB, ATM Multiservice Networks
More information about the erlang-questions