fzwoch / obs-teleport

An OBS Studio plugin for an open NDI-like replacement. Pretty simple, straight forward. No NDI compatibility in any form.
GNU General Public License v2.0
438 stars 16 forks source link

Performance issue. #36

Closed ItsVinnyX closed 2 years ago

ItsVinnyX commented 2 years ago

So I used NDI before but unfortunately, the Screen Capture module footage was lagging/choppy for me, the audio was fine though. I tried with Screen Capture HX and the gameplay was smooth but I ran into the issue with the audio being delayed.

I learned about Teleport and was hopeful. I set it up on both machines and the audio was surprisingly on point with practically zero notice in delay. However, I noticed a sudden delay in gameplay footage between swapping from different IP selections within the menu. One was noticeably better than the other. Well, I found the correct one without delay, but the moment I hopped into a game, I had terrible FPS... I mean it was from 100+ to about 30 FPS. I did some investigation and the moment I disabled "Teleport" on the gaming rig "The Sender" my frames shot right up.

Any clue on what could be causing this? Literally worked perfectly for my needs but that is the setback.

Gaming Rig Specifications: i9-10850k RTX 3090 32 GB DDR4 RAM

Streaming Rig Specifications: Ryzen 5 3600 RTX 3060Ti 16 GB DDR4 RAM

Both operating on Windows 11 Pro.

fzwoch commented 2 years ago

The delay when switching is probably due to #15. It feels like the best is to set everything and restart OBS ob the receiver side and try not to touch it. I don't how to fix this from a plugin's perspective. Seems some specific sync behavior on timestamp gaps on OBS side.

Well it does require some CPU. So I guess check if that is a bottleneck in your setup. Depends on OBS's frame rate and resolution also of course. I don't think the difference between desktop and a game makes much of a difference. Cannot really say more from a distance.

ItsVinnyX commented 2 years ago

The delay when switching is probably due to #15. It feels like the best is to set everything and restart OBS ob the receiver side and try not to touch it. I don't how to fix this from a plugin's perspective. Seems some specific sync behavior on timestamp gaps on OBS side.

Well it does require some CPU. So I guess check if that is a bottleneck in your setup. Depends on OBS's frame rate and resolution also of course. I don't think the difference between desktop and a game makes much of a difference. Cannot really say more from a distance.

Strange, I honestly do not think it's anything in relation with bottleneck but it could be. I'll try that refresh method but any clue for performance? This is quite the drop in FPS.

EDIT: Doing your restart method shot my frames up again! STRANGE! Any idea though? Still quite the performance hit but went up by 28 or 30 more.

I am sending 2K@60FPS should I make the sender side basically what I want to send to my stream then?

Huge increase after swapping settings in the sender end to like normal stream settings.

I also notice audio delay but the game capture is not delayed much at all. With another Teleport source for audio-only it works fine though any idea?

fzwoch commented 2 years ago

If you feel you can reproduce something that gives abnormal performance figures, feel free to reopen. I feel like current performance bottlenecks are simply bottlenecks. If the fps/resolution is too much for the target/destination machines it will will just fail. That is technical limitation, rather than a bug (unless you find some really odd behaviour).

YorVeX commented 2 years ago

Maybe it's still worth investigating what exactly is bottlenecking, it would help with optimizing the systems for Teleport.

In my test setup I send a preview of the final mixed stream out to a laptop with only a quality setting of 40 because it's shown there in a rather small window anyway and it's sufficient for the preview. In this setup the whole system has a CPU load of around 35%. But just for testing I cranked up the quality of this to 100 and surely I will get encoding lag from hell with lots of dropped frames due to it and something like 2 FPS on the receiver - but the CPU load only went up to 38% on the sender system.

This is on a Ryzen Threadripper 1950X, so its strength is in having 16 physical (32 logical) cores while the per-core performance is rather weak. Maybe Teleport only uses one CPU core for encoding? Or at least not all of them?

This would explain why people seem to have this mismatch between the performance they are used to get from their systems and what they can actually squeeze out using Teleport. And maybe also why running 2 OBS instances with 2 Teleport base streams each seems to perform better than only 1 OBS instance with one base stream and a separate stream through a filter (maybe that is then also run on the same core?).

Even if this is a limitation of OBS you cannot do anything about it would at least be good to know about this.

fzwoch commented 2 years ago

Make sure the network is not the bottleneck at 100%. Images should be encoded/decoded in parallel always. So it should spread across all cores.

YorVeX commented 2 years ago

Good point, will test again later.

YorVeX commented 2 years ago

OK, this is interesting. Sending a 900p stream with quality 100 to only a PC (2.5 GBit/s interface) doesn't lag, task manager says 430 MBit/s. Sending the same stream to only a laptop (1 GBit/s interface) is lagging and also showing lots of encoding lag on the sender side. Task manager says 430 MBit/s most of the time but with occasional dips down to 370 MBit/s.

I wonder why a receiver that doesn't perform well lags the sender. Is it because the sender waits for confirmations for each packet/frame/chunk/whatever unit from each receiver?

As a result of this behavior if the stream is sent to both the laptop and the PC also the stream on the PC lags. That means one "bad" receiver can also make other receivers lag that on their own would perform well. Interestingly even though the sender shows dropped frames due to encoding lag when I record the session in the sender OBS the lags aren't in the recording, everything looks good there.

Using Teleport in a bit bigger setups is really not trivial with all those rather counter-intuitive pitfalls 😛

While I have once more learned something new through this test I still don't know what the actual bottleneck is, the laptop is at 44% CPU and as I said has a 1 GBit/s interface when only 430 MBit/s are needed, also a speed test on the laptop shows that it can reach at least 950 MBit/s.

fzwoch commented 2 years ago

If you have 430mbps on one client but have two connected, you will end up with 860mbps on the sender. With some overhead and maybe not perfect implementation that gets close to max. And yes, one receiver can slow down the other if its not fast enough consuming.

YorVeX commented 2 years ago

Nah, the sender has a 10 GBit/s connection, the PC receiver 2.5 GBit/s and the laptop a 1 GBit/s connection so doubling for the sender shouldn't bottleneck at all (also with a measurement tool I can see that between sender and receiver PC the net speed it reaches is actually 2.37 GBit/s). And as I said, it's also lagging if only transmitting one stream from sender PC to the laptop and the second connection is not used.