mpv icon indicating copy to clipboard operation
mpv copied to clipboard

--video-sync=display-* causes 100% CPU load on one core (nvidia related?)

Open pmts opened this issue 9 years ago • 5 comments

mpv version and platform

Gentoo Linux

mpv 0.23.0 (C) 2000-2016 mpv/MPlayer/mplayer2 projects built on UNKNOWN ffmpeg library versions: libavutil 55.34.100 libavcodec 57.64.101 libavformat 57.56.100 libswscale 4.2.100 libavfilter 6.65.100 libswresample 2.3.100 ffmpeg version: 3.2.2

Reproduction steps

play any video using mpv --video-sync=display-resample, or any other display-* variant

Expected behavior

low CPU load

Actual behavior

100% cpu load on one core

Log file

http://pastebin.com/PB86fTd0

This seems related to the proprietary nvidia driver. I used 'perf top' to peek at what's happening and it seems most of that time is spent in the driver and in the kernel, waiting on some spinlock?

20,48% [kernel] [k] _raw_spin_unlock_irqrestore 11,29% [kernel] [k] sock_poll 11,01% [nvidia] [k] _nv017834rm 10,24% [kernel] [k] calc_load_exit_idle 8,96% libclutter-1.0.so.0.2600.0 [.] clutter_actor_get_transformed_paint_volume 5,12% libnvidia-glcore.so.378.09 [.] 0x0000000000a99351

Any ideas?

pmts avatar Jan 23 '17 21:01 pmts

Try export __GL_YIELD="USLEEP"

qmega avatar Jan 24 '17 02:01 qmega

@pmts BTW, it goes software, so I wouldn't expect low CPU load, it depends on what CPU you have.

[vd] Codec list:
[vd]     h264 - H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
[vd] Opening video decoder h264
[vd] Using software decoding.
[vd] Detected 8 logical cores.
[vd] Requesting 9 threads for decoding.
[vd] Selected video codec: h264 (H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10)
[ad] Codec list:
[ad]     dca (dts) - DCA (DTS Coherent Acoustics)
[ad] Opening audio decoder dca
[ad] Requesting 1 threads for decoding.

kkkrackpot avatar Jan 24 '17 07:01 kkkrackpot

Looks like the driver is polling for vsync. Does it also happen with glxgears? The "special" thing about display-sync is that it tries to render a frame on every vsync, and if the driver polls on vsync, the amount of polling would increase with display-sync.

@fhlfibh his excerpt of perf top already proves that it's not that.

ghost avatar Jan 24 '17 07:01 ghost

pmts is using 378.09 BETA drivers which enabled __GL_THREADED_OPTIMIZATIONS on by default. Turning it off by environment variable or application profile setting causes the issue to be gone. qmega's __GL_YIELD="USLEEP" also seems to work

voltmtr avatar Jan 24 '17 08:01 voltmtr

Thanks, both __GL_THREADED_OPTIMIZATIONS=0 and __GL_YIELD="USLEEP" fix this issue.

pmts avatar Jan 24 '17 10:01 pmts