[mythtv-users] Running mythcommflag on another PC?

Stephen Worthington stephen_agent at jsw.gen.nz
Sun Mar 3 00:01:36 UTC 2024

On Sat, 2 Mar 2024 22:46:04 +0000, you wrote:

>On 02/03/2024 18:48, Ian Evans wrote:
>> On Sat, Mar 2, 2024, 12:09?p.m. Jan Ceuleers <jan.ceuleers at gmail.com> wrote:
>>> On 02/03/2024 17:35, Ian Evans wrote:
>>>> Just drinking coffee and a random mythtv musing struck me: is it
>>>> possible to run mythcommflag on another PC so as not to bog down a PC
>>>> doing multiple recordings.
>>>> Say you have your main mythbox with its recording drives, but you
>>>> archive older recordings to a NAS with storage directories. And you
>>>> have a small computer on your network that does odd jobs like DNS,
>>>> Home Assistant, etc. Could you run mythcommflag on just the archived
>>>> recordings on that pc at a relaxed pace? :)
>>>> Again, random coffee musing. Maybe the answer is "a X Gen intel/amd
>>>> won't break a sweat mythcommflagging dozens of recordings, just limit
>>>> the time to overnight."
>>> Yes.
>>> Run a slave backend on the other computer. It doesn't need any tuners,
>>> but it does need access to the recording drives. You can configure the
>>> kinds of jobs it is capable of running, how many of them at the same
>>> time etc. If you want commflagging to run only on that other machine
>>> then disallow commflagging on the main backend.
>>> Thanks. I see that it can be run with a - -file input. So I'm assuming if
>> you run it from a script against just the files in the archive storage it
>> finds the recording in the database that way? Is there also a way a script
>> can detect if a file has already been Flagged? (Barring that, I guess the
>> script could always move files from /storagedirunflagged to
>> /storagedirflagged.
>You wouldn't need to move actual files from one directory to another. All you need do is for your
>script to touch a new file somewhere or append a line to a file - that can be easily searched
>for/tested and doesn't involve direct database access and also saves large video files being
>shuffled around, possibly while myth is trying to record something else!

Moving a file from one directory to another on the same partition is
virtually instantaneous - only the filesystem pointer is changed, the
actual file does not get moved.  This does depend on the particular
filesystem though - I know this to be true for ext[234] and JFS.  I
would be less sure for ZFS though, as I have never used that and it is
more complicated than most filesystems.  So having two directories
side by side and moving the files from one to the other is actually a
good solution, as long as both directories are in a storage group.  I
believe that such "rename only" moves are also atomic at the
filesystem level, so they should not have any impact on MythTV.

As for mythcommflag performance, for processors 10 years old or
younger and not the super cheap variety, then they can normally do
commflagging on one recording per CPU core/thread in real time.  So
for a 4 core dual threaded CPU, you could do 8 mythcommflag processes
simultaneously in real time as 8 recordings happen together.  The
trick with real time commflagging is that it gets done in RAM, on the
buffered recording data before it gets written to disk.  Once the data
has been written to disk, reading it back again slows down
commflagging, as there is then the problem of contention for the disk,
with the heads having to move between recordings.  So you also need
enough RAM, as well as the CPU resources.

I gave up doing commflagging a long time ago as here in New Zealand,
it never gave useful results.  So I have not tried commflagging with
the current generations of CPU, which are much faster again than 10
year old ones.  They may well be able to do more than one mythcommflag
operation per CPU thread, maybe even three or four.

I would recommend a starting position of one commflag operation per
CPU core/thread being run on the main recording box, starting the
commflagging when the recording starts.  Then just let any more
simultaneous recordings that go over that limit have their
commflagging queued to be done later.  There should not be any need to
have another box doing commflagging unless you are recording 20 things
at once all day.

More information about the mythtv-users mailing list