Backend on Pi 4

For discussion of topics specific to MythTV on Raspberry Pi devices
jfabernathy
Senior
Posts: 175
Joined: Wed Feb 18, 2015 2:37 pm
United States of America

Re: Backend on Pi 4

Post by jfabernathy » Mon Mar 09, 2020 5:09 pm

I'm very sorry for the noise yesterday. Bottom line is the updated pi-mythtv helper script that uses fixes/31 works fine with mythtv-light v30.

My confusion was trying to use the mythfrontend Setup Wizard to make sure I had audio and video right.

So the correct process is to install mythtv-light, then use the latest pi-mythbackend-helper.sh script to setup everything else.
Then make sure you have .asoundrc setup per the Mythtv Wiki on raspberry pi.
In mythfrontend setup audio using the mythtv device that .asoundrc created and then use OpenMax for video.

Again sorry for forgetting about the Setup Wizard not being a good method for RPI frontend testing.

knappster
Junior
Posts: 25
Joined: Wed Aug 01, 2018 1:42 am
United States of America

Re: Backend on Pi 4

Post by knappster » Wed Mar 18, 2020 10:19 am

FYI, I'm planning to try a 4GB Pi4 this weekend as a backend and if successful, I will report back how well commflagging works (or doesn't work).

biggus
Newcomer
Posts: 7
Joined: Fri Mar 20, 2020 4:09 pm
United States of America

Re: Backend on Pi 4

Post by biggus » Fri Mar 20, 2020 4:41 pm

First of all, thanks to MikeB2013 for an excellent setup script.

I've got RPi4 with 4 Gbytes of memory. Rhaspian Buster 2020-02-13. I wish to use it as both backend-frontend combo.

But I've got some problems.

First problem is after running about 10 minutes on live TV, the backend craps out. Sometimes cryptic error messages, sometimes with the clue that my disk drive is too slow. OK, let's work on disk drive performance.

I've got a somewhat aged Samsung 840 250G SSD connected to USB3 via a StarTech_com SATA to USB3 adapter. See attached performance chart. Seems like 250MB/S ought to be enough, but maybe not.

The key question is, what is working for others? So I can get the right thing.

My other problem may self inflicted. In order to maintain uniform Unix UIDs and GIDs across my network, I hand edited /etc/passwd and /etc/group and replaced "pi" with my usual username. Then I added my usual name to groups mythtv, video. I may need to add myself to some more groups?

Anyway, the big problem is that the xmltv-ids are not populating. I do run mythtv-setup as superuser. I could populate the xmltv-ids by hand, but that's a bother.

Thanks in advance for any advice.
Attachments
Capture.JPG
Capture.JPG (31.33 KiB) Viewed 514 times

biggus
Newcomer
Posts: 7
Joined: Fri Mar 20, 2020 4:09 pm
United States of America

Re: Backend on Pi 4

Post by biggus » Fri Mar 20, 2020 5:53 pm

An update to my USB3/SATA disk performance query.

I tried it on a low res station and it seems to work fine. Almost certainly a disk performance issue.

MikeB2013
Senior
Posts: 490
Joined: Mon Jul 25, 2016 4:16 pm
Great Britain

Re: Backend on Pi 4

Post by MikeB2013 » Fri Mar 20, 2020 6:04 pm

Just in case, there are issues with some USB3 SATA converters which adversely affect disk performance on Pi4.
See https://www.raspberrypi.org/forums/view ... &hilit=uas

I have assumed that rootfs is running on the SSD not the microSD card.

That SSD should be fine, as would almost any other SSD.

There are two basic tests I run, but first stop mythtv-backend if it is running.

Code: Select all

sudo systemctl stop mythtv-backend
1. Write Speed, creates 8GB file

Code: Select all

dd if=/dev/zero of=test1 bs=4k count=2000k conv=fsync status=progress
2. Read Speed, reads back 8GB file

Code: Select all

dd if=test1 of=/dev/null bs=4k status=progress
Now tidy up

Code: Select all

rm test1
As far as results go here are mine for a PNY CS900 240GB SSD, I ran the tests in /srv/mythtv/

Code: Select all

pi@pi4-20200317:/srv/mythtv $ dd if=/dev/zero of=test1 bs=4k count=2000k conv=fsync status=progress
8308260864 bytes (8.3 GB, 7.7 GiB) copied, 50 s, 166 MB/s
2048000+0 records in
2048000+0 records out
8388608000 bytes (8.4 GB, 7.8 GiB) copied, 50.7171 s, 165 MB/s

Code: Select all

pi@pi4-20200317:/srv/mythtv $ dd if=test1 of=/dev/null bs=4k status=progress
8072310784 bytes (8.1 GB, 7.5 GiB) copied, 28 s, 288 MB/s
2048000+0 records in
2048000+0 records out
8388608000 bytes (8.4 GB, 7.8 GiB) copied, 28.4778 s, 295 MB/s
If you are getting write or read speed much below 100 MB/s, there is a problem.

biggus
Newcomer
Posts: 7
Joined: Fri Mar 20, 2020 4:09 pm
United States of America

Re: Backend on Pi 4

Post by biggus » Fri Mar 20, 2020 11:30 pm

Fun and games!

Reads are 300 or more Mbytes/S. Writes.... well it varies... but maybe 3-4 Mbytes/S sustained. Starts big and then declines.

Need to isolate on the SSD versus the USB3-SATA adapter.

Apparently the OS buffer cache is write through and not write back. And there's some complex behavior around how much buffer is allowed to be dirty and how much memory is allowed to be used by the buffer cache.

What I think I'm seeing is an initial burst that fills the allowed dirty in the buffer cache at high speed, then a long period where write speed is limited by the buffer cache write through to the disk. Which seems to be about 3-4 Mbytes/S. And then the max buffer cache limit comes to play and there's a dip in writes out to disk while the OS does whatever malarkey it needs to do.

I think probably the OS malarkey dip is when MythTV chokes.

I noticed that during live TV playback, there is no read traffic to the SSD. Its all coming out of the buffer cache. Kudos to the buffer cache! If we were only worried about live TV playback we really wouldn't need to write to disk and write back would be the way to go. Don't know if there is some way to mark a filesystem as write back?? But even if you can mark a filesystem as write-back, this breaks for recording and the Live-TV buffer.

Back to the important question... SSD versus USB3-SATA. I did an echo 1 > /proc/sys/vm/drop_caches, and then the read. The read result is therefore coming from the SSD which means at least the USB3-SATA read path works well. The write and read paths are not identical, but likely the read path and the write path have similar performance through the USB3-SATA adapter.

Claim of 250MBits/S sequential write for the Samsung SSD 840... doesn't look good. No detail on how that was measured, especially with respect to the transfer length. Probably some beady eyed marketing guys fudged the test work load to get this result.

So, looks to me like its the SSD that's limiting the write speed. Fine. So how to confidently buy and SSD with sufficient performance?

Blah... blah... blah. Maybe just buy a PNY CS900GB SSD and be done with it?

MikeB2013
Senior
Posts: 490
Joined: Mon Jul 25, 2016 4:16 pm
Great Britain

Re: Backend on Pi 4

Post by MikeB2013 » Sat Mar 21, 2020 8:26 am

SSD write 3-4 MB/s is definitely a problem, and might need usb-quirk in /boot/cmdline.txt for the USB SATA converter on Raspberry Pi4, assuming the SSD is not faulty.

If you have another machine with USB 3 port e.g. laptop running linux, try the same tests and see if write speed improves (if the drive gets automounted, you will need sudo infront of the commands). The Pi4 is very picky about the USB3 SATA converters.

I also use a free utility HDSentinel see https://www.hdsentinel.com/hard_disk_sentinel_linux.php
This has versions for 32/64bit and Raspberry Pi and provides lots of detail about the disk.

I have a number of different SSDs, from Samsung, Crucial, PNY, Sandisk all of which work fine with Pi4, with usb-quirk for my various USB3 SATA adapters.

jfabernathy
Senior
Posts: 175
Joined: Wed Feb 18, 2015 2:37 pm
United States of America

Re: Backend on Pi 4

Post by jfabernathy » Sat Mar 21, 2020 10:01 am

biggus wrote:
Fri Mar 20, 2020 4:41 pm
First of all, thanks to MikeB2013 for an excellent setup script.

I've got RPi4 with 4 Gbytes of memory. Rhaspian Buster 2020-02-13. I wish to use it as both backend-frontend combo.

But I've got some problems.

First problem is after running about 10 minutes on live TV, the backend craps out. Sometimes cryptic error messages, sometimes with the clue that my disk drive is too slow. OK, let's work on disk drive performance.

I've got a somewhat aged Samsung 840 250G SSD connected to USB3 via a StarTech_com SATA to USB3 adapter. See attached performance chart. Seems like 250MB/S ought to be enough, but maybe not.

The key question is, what is working for others? So I can get the right thing.

My other problem may self inflicted. In order to maintain uniform Unix UIDs and GIDs across my network, I hand edited /etc/passwd and /etc/group and replaced "pi" with my usual username. Then I added my usual name to groups mythtv, video. I may need to add myself to some more groups?

Anyway, the big problem is that the xmltv-ids are not populating. I do run mythtv-setup as superuser. I could populate the xmltv-ids by hand, but that's a bother.

Thanks in advance for any advice.
I have my RPi4 Combo FE/BE running V30 and it had run for over a month without issues on recording OTA ATSC HD programs 1080i/720p. Very stable. I have the hardware uses and my instructions for install here: https://mythtv-rp4.blogspot.com/2019/12 ... -pi-4.html
Disk performance has not been an issue for me. My biggest test has been to record 4 HD programs at the same time while watching a previously recorded program on the RP4.

EDIT: My test were on new RP4 4G but using the same SSD and USB3 to SATA III converter. My numbers are lower but still no issues with disk performance running Mythtv.

Code: Select all

pi@raspberrypi:/srv/mythtv $ dd if=/dev/zero of=test1 bs=4k count=2000k conv=fsync status=progress
8381145088 bytes (8.4 GB, 7.8 GiB) copied, 116 s, 72.3 MB/s
2048000+0 records in
2048000+0 records out
8388608000 bytes (8.4 GB, 7.8 GiB) copied, 116.841 s, 71.8 MB/s
pi@raspberrypi:/srv/mythtv $ dd if=test1 of=/dev/null bs=4k status=progress
8129798144 bytes (8.1 GB, 7.6 GiB) copied, 38 s, 214 MB/s
2048000+0 records in
2048000+0 records out
8388608000 bytes (8.4 GB, 7.8 GiB) copied, 38.9971 s, 215 MB/s
pi@raspberrypi:/srv/mythtv $ 
EDIT: the numbers above were on my RP4 using the SATA SSD as a rootfs. NO Quirks setup.
The numbers below are the same RP4 using the SATA SSD as a standard USB3 drive but with Quirks added to the cmdline.txt

Code: Select all

pi@raspberrypi:/media/pi/rootfs/srv/mythtv $ sudo dd if=/dev/zero of=test1 bs=4k count=2000k conv=fsync status=progress
8374562816 bytes (8.4 GB, 7.8 GiB) copied, 54 s, 155 MB/s
2048000+0 records in
2048000+0 records out
8388608000 bytes (8.4 GB, 7.8 GiB) copied, 55.5918 s, 151 MB/s
pi@raspberrypi:/media/pi/rootfs/srv/mythtv $ sudo dd if=test1 of=/dev/null bs=4k status=progress
8165658624 bytes (8.2 GB, 7.6 GiB) copied, 28 s, 292 MB/s
2048000+0 records in
2048000+0 records out
8388608000 bytes (8.4 GB, 7.8 GiB) copied, 28.931 s, 290 MB/s
pi@raspberrypi:/media/pi/rootfs/srv/mythtv $ 
Quirks makes a big difference which I was not aware of until this discussion.

Thanks, Mike.

knappster
Junior
Posts: 25
Joined: Wed Aug 01, 2018 1:42 am
United States of America

Re: Backend on Pi 4

Post by knappster » Sat Mar 21, 2020 11:13 am

I've just configured the 4 GB pi4 with a 1 TB USB 3.0 HDD (not even sure of the rpm) that is powered over the USB port (HDTB410XK3AA). It is concurrently recording 3 HD streams while concurrently producing an HD live tv stream to Kodi on an Nvidia Shield. I am not noticing any stuttering. top cpu usage was around 50-60% in the beginning for mythbackend but it appears to be in the 60-70% range now 10 minutes in.

I did try running a commercial flagging job, but it errored out with error code 140 (according to mythweb). I am trying to work out if that is a configuration issue or something else. The database was migrated from a standalone combined fe/be, so I expect there to be some (more) teething issues as I continue to use it. I do have a fan cooled case for it and the cpu temp is 35C.

MikeB2013
Senior
Posts: 490
Joined: Mon Jul 25, 2016 4:16 pm
Great Britain

Re: Backend on Pi 4

Post by MikeB2013 » Sat Mar 21, 2020 1:40 pm

For commercial flagging there is an open ticket https://code.mythtv.org/trac/ticket/13476

Mike

biggus
Newcomer
Posts: 7
Joined: Fri Mar 20, 2020 4:09 pm
United States of America

Re: Backend on Pi 4

Post by biggus » Sun Mar 22, 2020 6:52 pm

Did a bunch of measurements on an x86 Centos 7 system and concluded that both my Startech USB3-SATA adapter and Evo 840 SSD were slow.

Read this: https://www.raspberrypi.org/forums/view ... &hilit=uas My x86 Centos 7 labeled the Startech USB3-SATA adapter as blacklisted. Rhaspbian Buster did not (I think this is a bug in Rhaspbian). Added usb quirks to the kernel command line. Write BW a little more than doubled to may 5-6 GB/S. Still pretty low.

Bought a new Samsung EVO 860 from Best Buy (ordered on line and they brought it to my car!). With the usb-quirks still on the kernel command line I now get about 200 MB/S for writes and about 250 for reads. Good enough.

I've seen several articles on line claiming the Startech USB3-SATA adapter is great. I beg to differ. My Startech USB3-SATA adapter reports idVendor=174c and idProduct=55aa. Beware.

Even though I think performance is acceptable without UAS mode, I would consider replacing the Startech. But I don't know of a USB3-SATA I can trust. All of the adapters I've seen are off brands.

jfabernathy
Senior
Posts: 175
Joined: Wed Feb 18, 2015 2:37 pm
United States of America

Re: Backend on Pi 4

Post by jfabernathy » Sun Mar 22, 2020 8:06 pm

biggus wrote:
Sun Mar 22, 2020 6:52 pm
...
I've seen several articles on line claiming the Startech USB3-SATA adapter is great. I beg to differ. My Startech USB3-SATA adapter reports idVendor=174c and idProduct=55aa. Beware.

Even though I think performance is acceptable without UAS mode, I would consider replacing the Startech. But I don't know of a USB3-SATA I can trust. All of the adapters I've seen are off brands.
I have a Startch USB3-SATA adapter and my numbers were good and got better when I added the Quirks stuff. I got this on Amazon https://www.amazon.com/gp/product/B00HJ ... UTF8&psc=1 lsusb shows this:

Code: Select all

Bus 002 Device 002: ID 174c:55aa ASMedia Technology Inc. Name: ASM1051E SATA 6Gb/s bridge, ASM1053E SATA 6Gb/s bridge, ASM1153 SATA 3Gb/s bridge, ASM1153E SATA 6Gb/s bridge
my cmdline.txt is:

Code: Select all

usb-storage.quirks=174c:55aa:u console=serial0,115200 console=tty1 root=PARTUUID=fdab419f-e547-4850-8fe1-c64715d4d902 rootdelay=5  rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles
My performance number as listed above are:

Code: Select all

pi@raspberrypi:/media/pi/rootfs/srv/mythtv $ sudo dd if=/dev/zero of=test1 bs=4k count=2000k conv=fsync status=progress
8374562816 bytes (8.4 GB, 7.8 GiB) copied, 54 s, 155 MB/s
2048000+0 records in
2048000+0 records out
8388608000 bytes (8.4 GB, 7.8 GiB) copied, 55.5918 s, 151 MB/s
pi@raspberrypi:/media/pi/rootfs/srv/mythtv $ sudo dd if=test1 of=/dev/null bs=4k status=progress
8165658624 bytes (8.2 GB, 7.6 GiB) copied, 28 s, 292 MB/s
2048000+0 records in
2048000+0 records out
8388608000 bytes (8.4 GB, 7.8 GiB) copied, 28.931 s, 290 MB/s
pi@raspberrypi:/media/pi/rootfs/srv/mythtv $ 
Just make sure it's in one of those Blue USB3 ports.

knappster
Junior
Posts: 25
Joined: Wed Aug 01, 2018 1:42 am
United States of America

Re: Backend on Pi 4

Post by knappster » Tue Mar 24, 2020 12:05 pm

MikeB2013 wrote:
Sat Mar 21, 2020 1:40 pm
For commercial flagging there is an open ticket https://code.mythtv.org/trac/ticket/13476

Mike
Thanks for the heads up. Out of curiosity is this because the pi4 doesn't have hardware mpeg2 decoding? I have a pi3 with the mpeg2 license, so if I configure it as a slave backend, would it be able to run the commercial flagging or is it broken across the board on pis?

MikeB2013
Senior
Posts: 490
Joined: Mon Jul 25, 2016 4:16 pm
Great Britain

Re: Backend on Pi 4

Post by MikeB2013 » Tue Mar 24, 2020 5:52 pm

knappster wrote:
Tue Mar 24, 2020 12:05 pm
MikeB2013 wrote:
Sat Mar 21, 2020 1:40 pm
For commercial flagging there is an open ticket https://code.mythtv.org/trac/ticket/13476

Mike
Thanks for the heads up. Out of curiosity is this because the pi4 doesn't have hardware mpeg2 decoding? I have a pi3 with the mpeg2 license, so if I configure it as a slave backend, would it be able to run the commercial flagging or is it broken across the board on pis?
As far as I know it affects all Pi's. The trac ticket includes pi3 on mythtv-light 30 (I am not aware of any significant changes to commercial flagging between mythtv 30 and 31)

Mike

Post Reply