W3C home > Mailing lists > Public > public-audio@w3.org > July to September 2013

Re: Proposal for fixing race conditions

From: Ehsan Akhgari <ehsan.akhgari@gmail.com>
Date: Wed, 17 Jul 2013 13:04:08 -0400
Message-ID: <CANTur_7JfLd45FLdP+CPvKEpEm1ro2jOpxf+ga8n6ejq61Z5gg@mail.gmail.com>
To: Jer Noble <jer.noble@apple.com>
Cc: "robert@ocallahan.org" <robert@ocallahan.org>, "K. Gadd" <kg@luminance.org>, Olivier Thereaux <Olivier.Thereaux@bbc.co.uk>, WG <public-audio@w3.org>
On Wed, Jul 17, 2013 at 11:57 AM, Jer Noble <jer.noble@apple.com> wrote:

> That is also a crucial point which I believe is getting lost in this
> conversation.  These performance concerns are only about how efficiently we
> can run legacy code while maintaining the current API.  If we're willing to
> break API backwards compatibility by making AudioBuffers immutable for
> example, and avoid using Float32Arrays anywhere except as an argument to
> the AudioBuffer constructor, then we'll avoid all of the memcpy costs in
> the normal usage of the API, except when creating an AudioBuffer.  So, it's
> not like that our two alternatives are not fixing the race conditions at
> all, or memcpy data all the time on every call into the API.
> Generally that is true, but "except when creating an AudioBuffer" is a
> very large caveat. There are some use cases (e.g., generated audio
> playback) which would hit this edge case.

The only way to avoid the memcpy when creating an AudioBuffer would be to
neuter the argument passed to it, but that will make the Float32Array
passed to it unusable from that point on, which may or may not be
acceptable.  We can also design an asynchronous AudioBuffer creation API so
that the memcpy can be implemented off the main thread (like how
decodeAudioData currently works.)

We need to come to terms with the fact that there is no free lunch.  We
just cannot design an API which never memcpy's anything and is free from
data race conditions.  Instead of discussing how terrible memcpy's are, we
need to discuss how we can avoid doing them in the use cases which we
expect to be common, or how to diminish their performance impact if they're
impossible to avoid.  This is where having practical performance sensitive
test cases which examines those scenarios come in handy.

Received on Wednesday, 17 July 2013 17:05:20 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:03:23 UTC