[FFmpeg-devel] [PATCH] avutil/md5: inline function, 2% speedup

Giorgio Vazzana mywing81 at gmail.com
Mon May 20 21:43:07 CEST 2013


2013/5/20 Michael Niedermayer <michaelni at gmx.at>:
> Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> ---
>  libavutil/md5.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavutil/md5.c b/libavutil/md5.c
> index e3c4981..2df37cc 100644
> --- a/libavutil/md5.c
> +++ b/libavutil/md5.c
> @@ -92,7 +92,7 @@ static const uint32_t T[64] = { // T[i]= fabs(sin(i+1)<<32)
>          a = b + (a << t | a >> (32 - t));                               \
>      } while (0)
>
> -static void body(uint32_t ABCD[4], uint32_t X[16])
> +static av_always_inline void body(uint32_t ABCD[4], uint32_t X[16])
>  {
>      int i av_unused;
>      uint32_t t;
> --

On my pc I get:

AMD Athlon(tm) II X3 450 Processor

# git head
size: 1048576  runs: 1024  time:    5.660 +- 0.023
size: 1048576  runs: 1024  time:    5.661 +- 0.030
size: 1048576  runs: 1024  time:    5.656 +- 0.022
size: 1048576  runs: 1024  time:    5.647 +- 0.026

# patch "av_always_inline"
size: 1048576  runs: 1024  time:    5.523 +- 0.027
size: 1048576  runs: 1024  time:    5.527 +- 0.032
size: 1048576  runs: 1024  time:    5.525 +- 0.032
size: 1048576  runs: 1024  time:    5.519 +- 0.024

But what about something like the attached patch? It seems to run faster here:

# patch "nblocks"
size: 1048576  runs: 1024  time:    5.428 +- 0.037
size: 1048576  runs: 1024  time:    5.426 +- 0.034
size: 1048576  runs: 1024  time:    5.426 +- 0.034
size: 1048576  runs: 1024  time:    5.428 +- 0.038

(Strangely, using nblock+av_always_inline is slower for some reason:

# patch "nblocks"+"av_always_inline"
size: 1048576  runs: 1024  time:    5.520 +- 0.025
size: 1048576  runs: 1024  time:    5.520 +- 0.025
size: 1048576  runs: 1024  time:    5.519 +- 0.025
size: 1048576  runs: 1024  time:    5.520 +- 0.026
)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lavu_md5_nblocks.patch
Type: application/octet-stream
Size: 1837 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130520/11d1cd25/attachment.obj>


More information about the ffmpeg-devel mailing list