[FFmpeg-devel] [PATCH] avcodec/bitstream: replace qsort with AV_QSORT

Michael Niedermayer michael at niedermayer.cc
Sun Oct 18 04:25:57 CEST 2015

On Sat, Oct 17, 2015 at 09:30:01PM -0400, Ganesh Ajjanagadde wrote:
> Commit 3a0a2f33a6c955823fa4fb12c0b49cd29a496659 claims large performance
> advantages for AV_QSORT over libc's qsort. The reason is that I suspect
> that libc's qsort (at least on non LTO builds, like the typical FFmpeg config)
> can't inline the comparison callback:
> https://stackoverflow.com/questions/5290695/is-there-any-way-a-c-c-compiler-can-inline-a-c-callback-function.
> AV_QSORT has two things going for it:
> 1. The guaranteed inlining of qsort itself. This yields a negligible
> boost that may be ignored.
> 2. The more serious possibility of potentially allowing the comparison
> function to be inlined - this is likely responsible for the large boosts
> reported.
> There is a comment explaining that this is a place that could use some
> performance improvement. Thus AV_QSORT is used to achieve that.
> Benchmarks deemed unnecessary due to existing claims about AV_QSORT.
> Tested with FATE.
> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
> ---
>  libavcodec/bitstream.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)



Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The educated differ from the uneducated as much as the living from the
dead. -- Aristotle 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20151018/20fd4dd0/attachment.sig>

More information about the ffmpeg-devel mailing list