[FFmpeg-devel] [PATCH] avcodec/mpegaudio_tablegen: more dynamic initialization speedups

Ganesh Ajjanagadde gajjanag at mit.edu
Sat Nov 28 13:46:28 CET 2015


On Sat, Nov 28, 2015 at 7:27 AM, Ganesh Ajjanagadde <gajjanag at mit.edu> wrote:
> On Sat, Nov 28, 2015 at 4:41 AM, Michael Niedermayer <michaelni at gmx.at> wrote:
>> On Sat, Nov 28, 2015 at 12:46:31AM -0500, Ganesh Ajjanagadde wrote:
>>> This further speeds up runtime initialization, with identical generated tables.
>>>
>>> Sample benchmark (x86-64, Haswell, GNU/Linux):
>>>
>>> old:
>>> 34441423 decicycles in mpegaudio_tableinit,    8192 runs,      0 skips
>>>
>>> new:
>>> 10776291 decicycles in mpegaudio_tableinit,    8192 runs,      0 skips
>>>
>>> Most low hanging fruit is taken care of here. For some idea, note that
>>> 83,064 array elements totalling 233,722 bytes need to be initialized.
>>> Thus, with this patch, we average ~ 12.9 cycles per element or ~ 4.6
>>> cycles per byte.
>>>
>>> I personally consider this net ~ 10x and overall perf numbers sufficient
>>> for using dynamic initialization all the time here, especially since the
>>> tables are large.
>>>
>>> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
>>> -------------------------------------------------------------------------------
>>> The reason this is being posted before pushing in the other one is that if
>>> people agree to do dynamic initialization here, the introduction of avutil/tablegen
>>> can be deferred to a future date.
>>>
>>> Note that if one had a ~8000 element static lut for the pow_43 values,
>>> one can bring down the cost slightly, to ~ 8-10 cycles per element but not more,
>>> so definitely not an order of improvement like the current patches.
>>> I personally do not like this "middle path" as I find it too complex for a slight
>>> speed gain, while still having a large ~ 64,000 byte size cost.
>>> -------------------------------------------------------------------------------
>>>  libavcodec/mpegaudio_tablegen.h | 22 +++++++++++++++-------
>>>  1 file changed, 15 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/libavcodec/mpegaudio_tablegen.h b/libavcodec/mpegaudio_tablegen.h
>>> index dd67a09..91b29cb 100644
>>> --- a/libavcodec/mpegaudio_tablegen.h
>>> +++ b/libavcodec/mpegaudio_tablegen.h
>>
>> seems this doesnt apply
>
> It was not meant to be directly applied, but only after the other
> mpegaudio_tablegen.h patch:
> https://ffmpeg.org/pipermail/ffmpeg-devel/2015-November/183914.html
> has been applied with the first speedup.

Even that may not apply cleanly, since there was some minor renaming
done based on comments by Ronald.
Basically, I request an answer to the 3 alternatives I posted before
moving forward, creating a clean patchset, etc.
Or if you really want to verify this yourself before answering the 3
alternatives, I can create a clean 2 patch set now itself, with the
caveat that they can't be applied to master yet (which requires an
answer to the 3 alternatives).

[...]


More information about the ffmpeg-devel mailing list