Re: AudioNode GC rules

On Thu, Mar 21, 2013 at 9:50 AM, Robert O'Callahan <robert@ocallahan.org>wrote:

> On Thu, Mar 21, 2013 at 3:49 PM, Srikumar Subramanian <
> srikumarks@gmail.com> wrote:
>
>> For code like the granular synthesis example which creates tens of
>> nodes or perhaps hundreds of nodes every second, ....<snip>
>>
>
> Got a link to that example?
>

http://chromium.googlecode.com/svn/trunk/samples/audio/granular.html


> For an analogy, this case seems similar to whether a language spec
>> should mandate tail call elimination. On one hand it is only an
>> optimization. On the other its guaranteed presence leads devs to write
>> very different code - perhaps using a lot of (mutual) recursion that
>> would in a moment bomb an implementation that didn't support TCO.
>> Python went the "nope" route and Scheme went the "yep" route. Both
>> have their fans.
>>
>
> That's a fair point. Coming up with spec text for this seems hard but we
> can probably work something out. It shouldn't affect audio output though,
> just bound space usage. E.g. we could define "finished" nodes and specify
> that the asymptotic space usage of the nodes of an AudioContext should be
> O(N) in the number of non-finished nodes.


While space usage is one factor, the main factor impacting performance is,
I think, the time cost of having around such "finished" but connected
nodes. As long as "finished" node subchains - i.e. those that include
source nodes and consist only of "finished" nodes - contribute zero compute
cost irrespective of space reclamation, cases like granular synthesis would
be viable.

The benefit of the current "dynamic lifetime" prescription is that these
finished nodes propagate finishedness by disconnecting their outputs,
thereby eliminating checks that the destination would otherwise have to do.
So rephrasing the "dynamic lifetime" mechanism as a "finishedness
proagation" mechanism might get the benefits without having to touch on GC
related issues, freeing up implementors to choose from a wider range of
techniques.

-Kumar


>
>
> Rob
> --
> Wrfhf pnyyrq gurz gbtrgure naq fnvq, “Lbh xabj gung gur ehyref bs gur
> Tragvyrf ybeq vg bire gurz, naq gurve uvtu bssvpvnyf rkrepvfr nhgubevgl
> bire gurz. Abg fb jvgu lbh. Vafgrnq, jubrire jnagf gb orpbzr terng nzbat
> lbh zhfg or lbhe freinag, naq jubrire jnagf gb or svefg zhfg or lbhe fynir
> — whfg nf gur Fba bs Zna qvq abg pbzr gb or freirq, ohg gb freir, naq gb
> tvir uvf yvsr nf n enafbz sbe znal.” [Znggurj 20:25-28]
>

Received on Thursday, 21 March 2013 05:57:28 UTC