janbar / cppmyth

C++ MythTV client library
https://janbar.github.io/cppmyth
8 stars 5 forks source link

Transfer speeds in higher latency networks #13

Open pjokinen opened 9 months ago

pjokinen commented 9 months ago

Hi!

I have been using MythTV via the Kodi plugin from local network and remote locations (with VPN connections) and I'd like to share my observations about transfer speeds in higher latency networks. For the most part, MythTV and the plugin have been working great, but live tv and recordings have been unusable in certain networks due to constant buffering. Recording stream bitrates are about 10 Mbps and network speeds are about 100 Mbps, so the network speed should not be the issue.

After finally looking into this issue, I found out that part of the problem stems from the small transfer buffers used in this library. The problematic networks are the ones with higher latency, so small buffers are limiting transfer speeds quite badly. I patched the Kodi MythTV plugin to use larger receive buffer and it fixed the issue. I have not observed any negative effects from this change.

I also modified livetvdemo into small test program to test and demonstrate the issue. Using it, I obtained following results:

Local network over WIFI (~3ms latency, ~120Mbps transfer speed)

default receive buffer (~64k):

[SPEED-TEST] transferred 47141000 bytes in 8.37 seconds (44.02 Mbps)

256k receive buffer:

[SPEED-TEST] transferred 47141000 bytes in 3.59 seconds (102.58 Mbps)

Remote network over VPN (~25ms latency, 100Mbps transfer speed)

default receive buffer (~64k):

[SPEED-TEST] transferred 47141000 bytes in 51.34 seconds (7.17 Mbps)

256k receive buffer:

[SPEED-TEST] transferred 47141000 bytes in 15.07 seconds (24.44 Mbps)

It appears that buffers bigger than 256k do not increase transfer speeds any further in these networks. For some reason, speed over VPN connection is still quite far from network speed, but with this modification the Kodi plugin is now usable in all locations.

bigger-buffer.patch.txt speed-test.cpp.txt

janbar commented 9 months ago

Hi, thanks for testing and report this. So yes it is an enhancement. As soon as possible I will include your patch.

pjokinen commented 9 months ago

Great, thanks!