Performance of ffmpeg

161 views
Skip to first unread message

Vincent de vries

unread,
Feb 12, 2021, 6:45:32 AM2/12/21
to OSv Development

Hi,

I performed some benchmarks comparing OSv to containers and general purpose OSs running under a hypervisor. Particularly, I carried out an ffmpeg benchmark that re-encodes a 30mb video from h.264 to h.265 using 16 threads with 16vCPUs. The results show that roughly all platforms perform equal, the exception being OSv (which takes ~1.4x longer).

I also performed another CPU-bound benchmark that simply checks whether numbers are prime -- in this case, OSv performs equal to the other platforms.

What could be the reason for the slowdown with ffmpeg? I can think of either something thread related, or perhaps OSv is not able to use special CPU instructions to its full potential (e.g. AVX). Or maybe OSv simply does not fare that well with 16 vCPUs?

Best regards,
Vincent

Dor Laor

unread,
Feb 12, 2021, 12:51:40 PM2/12/21
to Vincent de vries, OSv Development
OSv doesn't remove the cpu bits so it shouldn't be an issue. It can be
a libc library change too. Maybe ffmpeg has flags to reduce optimizations you can play with.

Most likely it's scheduling or locking, especially spinlocks. 
Best is to compare a single vcpu performance first.
 


Best regards,
Vincent

--
You received this message because you are subscribed to the Google Groups "OSv Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osv-dev+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/osv-dev/e8b49bf2-b4a4-4b91-a2b1-1f6348f4735bn%40googlegroups.com.

Waldek Kozaczuk

unread,
Feb 16, 2021, 5:06:08 PM2/16/21
to Vincent de vries, OSv Development
Here is an output of something similar with 4 vCPUs:

OSv v0.55.0-121-g3e898f4d
eth0: 192.168.122.15
Booted up in 170.53 ms
Cmdline: /ffmpeg.so -i http://clips.vorwaerts-gmbh.de/VfE_html5.mp4 -c:v libx265 -crf 28 -an -f mpegts tcp://192.168.122.1:12345
ffmpeg version 4.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 8 (Ubuntu 8.3.0-6ubuntu1)
  configuration: --disable-all --enable-ffmpeg --enable-small --enable-avcodec --enable-avformat --enable-avfilter --enable-swresample --enable-swscale --enable-decoder='h264,h265' --enable-encoder='rawvideo,libx264,libx265,png' --enable-parser='h264,h265' --enable-protocol='file,http' --enable-demuxer=mov --enable-muxer='rawvideo,mp4,mpegts,image2' --enable-filter=scale --enable-libx264 --enable-libx265 --enable-gpl
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
Guessed Channel Layout for Input Stream #0.1 : mono
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'http://clips.vorwaerts-gmbh.de/VfE_html5.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 1
    compatible_brands: mp42avc1
    creation_time   : 2011-03-16T10:41:51.000000Z
  Duration: 00:01:00.08, start: 0.000000, bitrate: 699 kb/s
    Stream #0:0(eng): Video: h264 (avc1 / 0x31637661), yuv420p(tv, smpte170m/smpte170m/bt709), 640x360, 633 kb/s, 24.04 fps, 24.04 tbr, 2500 tbn, 5k tbc (default)
    Metadata:
      creation_time   : 2011-03-16T10:41:52.000000Z
      handler_name    : Apple Video Media Handler
    Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, 62 kb/s (default)
    Metadata:
      creation_time   : 2011-03-16T10:41:53.000000Z
      handler_name    : Apple Sound Media Handler
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> hevc (libx265))
Press [q] to stop, [?] for help
x265 [info]: HEVC encoder version 2.9
x265 [info]: build info [Linux][GCC 8.2.0][64 bit] 8bit+10bit+12bit
x265 [info]: using cpu capabilities: MMX2 SSE2Fast LZCNT SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
x265 [info]: Main profile, Level-2.1 (Main tier)
x265 [info]: Thread pool created using 4 threads
x265 [info]: Slices                              : 1
x265 [info]: frame threads / pool features       : 2 / wpp(6 rows)
x265 [warning]: Source height < 720p; disabling lookahead-slices
x265 [info]: Coding QT: max CU size, min CU size : 64 / 8
x265 [info]: Residual QT: max TU size, max depth : 32 / 1 inter / 1 intra
x265 [info]: ME / range / subpel / merge         : hex / 57 / 2 / 2
x265 [info]: Keyframe min / max / scenecut / bias: 24 / 250 / 40 / 5.00
x265 [info]: Lookahead / bframes / badapt        : 20 / 4 / 2
x265 [info]: b-pyramid / weightp / weightb       : 1 / 1 / 0
x265 [info]: References / ref-limit  cu / depth  : 3 / on / on
x265 [info]: AQ: mode / str / qg-size / cu-tree  : 1 / 1.0 / 32 / 1
x265 [info]: Rate Control / qCompress            : CRF-28.0 / 0.60
x265 [info]: tools: rd=3 psy-rd=2.00 rskip signhide tmvp strong-intra-smoothing
x265 [info]: tools: deblock sao
Output #0, mpegts, to 'tcp://192.168.122.1:12345':
  Metadata:
    major_brand     : mp42
    minor_version   : 1
    compatible_brands: mp42avc1
    encoder         : Lavf58.29.100
    Stream #0:0(eng): Video: hevc (libx265), yuv420p, 640x360, q=2-31, 24.04 fps, 90k tbn, 24.04 tbc (default)
    Metadata:
      creation_time   : 2011-03-16T10:41:52.000000Z
      handler_name    : Apple Video Media Handler
      encoder         : Lavc58.54.100 libx265
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Input #0, mpegts, from 'tcp://0.0.0.0:12345?listen':
  Duration: N/A, start: 1.483200, bitrate: N/A
  Program 1
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: hevc (Main) (HEVC / 0x43564548), yuv420p(tv), 640x360, 24 fps, 24.04 tbr, 90k tbn, 24.04 tbc
Output #0, mp4, to '/tmp/test.mp4':
  Metadata:
    encoder         : Lavf58.45.100
    Stream #0:0: Video: hevc (Main) (hev1 / 0x31766568), yuv420p(tv), 640x360, q=2-31, 24 fps, 24.04 tbr, 90k tbn, 90k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame= 1445 fps=102 q=-0.0 Lsize=    2120kB time=00:00:59.98 bitrate= 289.5kbits/s speed=4.22x    
video:1797kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 17.960039%
frame= 1445 fps=116 q=-1.0 Lsize=    1825kB time=00:00:59.98 bitrate= 249.2kbits/s speed=4.81x    
video:1807kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.998210%
x265 [info]: frame I:     10, Avg QP:26.05  kb/s: 3621.02
x265 [info]: frame P:    480, Avg QP:28.24  kb/s: 562.45  
x265 [info]: frame B:    955, Avg QP:35.16  kb/s: 45.17  
x265 [info]: Weighted P-Frames: Y:5.0% UV:3.3%
x265 [info]: consecutive B-frames: 31.8% 6.5% 9.4% 39.4% 12.9%

encoded 1445 frames in 14.19s (101.84 fps), 241.74 kb/s, Avg QP:32.80

Please note a line about a thread pool with 4 threads.

Can you show us yours? 

As Dor suggested, it would be nice to start with 1 vCPU and see a difference and then move on from that.

Waldek

--

Roman Shaposhnik

unread,
Feb 16, 2021, 5:13:59 PM2/16/21
to Waldek Kozaczuk, Vincent de vries, OSv Development
Old time ffmpeg hacker here -- please remember that ffmpeg has a
pretty convoluted build system that will disable accelerations (used
to do it even silently) if the environment is not setup quite right.
So... in order for this to be apples-to-apples it kind of needs to be
the same ELF.

Thanks,
Roman.
> To view this discussion on the web visit https://groups.google.com/d/msgid/osv-dev/CAL9cFfOpOE67s7r0Q%2BCyc0%3DC3iuVZVDpR9MhzfbYLUgxJyTgkQ%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages