Syncplay / syncplay

Client/server to synchronize media playback on mpv/VLC/MPC-HC/MPC-BE on many computers
http://syncplay.pl/
Apache License 2.0
2.09k stars 213 forks source link

VLC uses vast amount of CPU capacity #39

Closed nnamrrehdlopoel closed 9 years ago

nnamrrehdlopoel commented 10 years ago

When running for Syncplay, VLC uses a vast amount of CPU capacity (for my friend 25% as it is a 4-core-CPU); even if no file is being played. There is no problem, when VLC runs alone.

nnamrrehdlopoel

Et0h commented 10 years ago

There is no simple VLC API that Syncplay can use, so I created one called syncplay.lua. This works by Syncplay continually polling VLC for its status, so it does not matter whether a file is playing or not.

Your friend could try increasing the value PLAYER_ASK_DELAY (stored in Syncplay's constants.py) and this should result in VLC being polled less often. It may cause problems if set too high, so experiment to find a level that works best (and let us know what that level is).

nnamrrehdlopoel commented 10 years ago

my friend solved the problem by adding

    vlc.misc.mwait(vlc.misc.mdate() + 1000) -- Don't waste processor time

in line 529 above the last two 'end's of the syncplay.lua Now his capacity is back at ~0%

Et0h commented 10 years ago

Excellent. I'll look into adding that to Syncplay. If it does get added and your friend wants credit I'll need a name or alias.

Et0h commented 10 years ago

If VLC is regularly waiting one thing to think about is whether this would necessitate decreasing how often Syncplay polls VLC to avoid backlog. Also worth checking whether reducing poll frequency from Syncplay removes the need to mwait through VLC.

DerGenaue commented 10 years ago

Hi, I'm nnamrrehdlopoel's friend,

i'm not sure whether this is a good idea, but I expect you not to have set the poll frequency to 1 million times per sec. Now, mwait reduces the frequency to max. 1000 times / sec. I think this should be enough.

Backlog should actually be no problem as after every mwait all logged commands are executed in the loop.

Et0h commented 10 years ago

My only concern was if it polled far more frequently than it waited add then it'd be needlessly responding to older polls. I'll test it when I get a chance.

Uriziel commented 10 years ago

This actually is a reasonable change. If you want you can also make a pull request with it and we'll get it merged once properly tested.

Et0h commented 10 years ago

Hopefully https://github.com/Uriziel/syncplay/commit/69c03bdaa5b539ee16a1d65a74a0b4adf9d8b329 properly addresses the issue. Thank you for raising the issue nnamrrehdlopoel, and thank you for coding a fix DerGenaue.