[opus] [RFC PATCH v1 1/2] Optimize repeated calls to opus_select_arch

Timothy B. Terriberry tterribe at xiph.org
Tue Jan 20 11:05:07 PST 2015


Viswanath Puttagunta wrote:
> Instead, just optimize the opus_select_arch() such that only
> the first call to it takes more time, but subsequent calls to
> it are much faster.

This has been suggested before, but it is a bad idea. The patch posted 
below is not thread-safe or even re-entrant. You can argue that the 
results should always be the same, so it won't matter, but this is quite 
hard to prove given the actual freedom a compiler has [1], and the races 
will get reported as errors by automated race detection tools (such as 
we use on Firefox), making the lives harder of everyone who has to deal 
with that.

Fixing this requires introducing dependencies on threading libraries, 
which are platform-specific (and may not even be available on some 
platforms) and will make you lose performance.

So really I think the better solution is to modify the function 
signatures, even if it looks like more typing.

[1] http://hboehm.info/boehm-hotpar11.pdf


More information about the opus mailing list