[mythtv-users] Newbie

Daniel Kristjansson danielk at cuymedia.net
Mon Dec 5 21:41:08 UTC 2011


On Sat, 2011-12-03 at 15:16 -0800, Yeechang Lee wrote:
> John Pilkington <J.Pilk at tesco.net> says:
> > Yeechang Lee had a version of the threaded filewriter that didn't
> > use the 1-second sync; it was used in the 'bijou' builds on ATrpms
> > and I used it successfully for some time before going on to 0.24.
> 
> bijou only briefly patched out the 1-second forced sync. What it has
> had since the beginning is much larger buffers in
> ThreadedFileWriter.cpp:
> 
> -const uint ThreadedFileWriter::TFW_DEF_BUF_SIZE   = 2*1024*1024;
> -const uint ThreadedFileWriter::TFW_MAX_WRITE_SIZE = TFW_DEF_BUF_SIZE / 4;
> -const uint ThreadedFileWriter::TFW_MIN_WRITE_SIZE = TFW_DEF_BUF_SIZE / 32;
> +const uint ThreadedFileWriter::TFW_DEF_BUF_SIZE   = 64*1024*1024;
> +const uint ThreadedFileWriter::TFW_MAX_WRITE_SIZE = TFW_DEF_BUF_SIZE / 32;
> +const uint ThreadedFileWriter::TFW_MIN_WRITE_SIZE = TFW_DEF_BUF_SIZE / 256;
<snip>

MythTV trunk dynamically scales up the file writers buffer up
to 128 MB, so this wouldn't really be necessary there.

But there is still a sync about every second.* It is controlled
by ThreadedFileWriter::SyncLoop(). If you change your disk write
scheduler to the deadline scheduler and tune it to work well
you can comment out the "Sync();" line. We've never made it
user configurable without a recompile because the effort to
required to get an individual machine to work properly without
the sync dwarf the effort required to comment out that line of
code. The sync allows MythTV to work fairly well with any disk
write scheduler including CFQ.

BTW The sync is an fdatasync() or fsync() depending on the
system. So it will usually cause two seeks, one to write meta
data (file size) and another to write the data. It may possibly
cause a third seek to write the journal, depending on the file
system and the location of the journal.

*MythTV doesn't really sync every second... It syncs one second
after the previous sync completes. Which means that the syncs
get further and further apart the more writes are being made to
a particular file system and each sync takes longer. This is the
reason why things don't fall apart as soon as the recorder count
is 5x the volume count.

-- Daniel



More information about the mythtv-users mailing list