linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nix <nix@esperi.org.uk>
To: Ram Ramesh <rramesh2400@gmail.com>
Cc: antlists <antlists@youngman.org.uk>,
	"R. Ramesh" <rramesh@verizon.net>,
	Linux Raid <linux-raid@vger.kernel.org>
Subject: Re: Best way to add caching to a new raid setup.
Date: Mon, 31 Aug 2020 20:20:54 +0100	[thread overview]
Message-ID: <87sgc2mxk9.fsf@esperi.org.uk> (raw)
In-Reply-To: <694be035-4317-26fd-5eaf-8fdc20019d9b@gmail.com> (Ram Ramesh's message of "Fri, 28 Aug 2020 17:40:18 -0500")

On 28 Aug 2020, Ram Ramesh verbalised:
> Mythtv is a sever client DVR system. I have a client next to each of
> my TVs and one backend with large disk (this will have RAID with
> cache). At any time many clients will be accessing different programs
> and any scheduled recording will also be going on in parallel. So you
> will see a lot of seeks, but still all will be based on limited
> threads (I only have 3 TVs and may be one other PC acting as a client)
> So lots of IOs, mostly sequential, across small number of threads. I
> think most cache algorithms should be able to benefit from random
> access to blocks in SSD.

FYI: bcache documents how its caching works. Assuming you ignore the
write cache (which I recommend, since nearly all the data corruption and
starvation bugs in bcache have been in the write caching code, and it
doesn't look like write caching would benefit your use case anyway:
if you want an ssd write cache, just use RAID journalling), bcache is
very hard to break: if by some mischance the cache does become corrupted
you can decouple it from the backing RAID array and just keep using it
until you recreate the cache device and reattach it.

bcache tracks the "sequentiality" of recent reads and avoids caching big
sequential I/O on the grounds that it's a likely waste of SSD lifetime
to do so: HDDs can do contiguous reads quite fast: what you want to
cache is seeky reads. This means that your mythtv reads will only be
cached when there are multiple contending reads going on. This doesn't
seem terribly useful, since for a media player any given contending read
is probably not going to be of metadata and is probably not going to be
repeated for a very long time (unless you particularly like repeatedly
rewatching the same things). So you won't get much of a speedup or
reduction in contention.

Where caches like bcache and the LVM cache help is when small seeky
reads are likely to be repeated, which is very common with filesystem
metadata and a lot of other workloads, but not common at all for media
files in my experience.

(FYI: my setup is spinning rust <- md-raid6 <- bcache <- LVM PV, with
one LVM PV omitting the bcache layer and both combined into one VG. My
bulk media storage is on the non-bcached PV. The filesystems are almost
all xfs, some of them with cryptsetups in the way too. One warning:
bcache works by stuffing a header onto the data, and does *not* pass
through RAID stripe size info etc: you'll need to pass in a suitable
--data-offset to make-bcache to ensure that I/O is RAID-aligned, and
pass in the stripe size etc to the underlying oeprations. I did this by
mkfsing everything and then doing a blktrace of the underlying RAID
devices while I did some simple I/Os to make sure the RAID layer was
doing nice stripe-aligned I/O. This is probably total overkill for a
media server, but this was my do-everything server, so I cared very much
about small random I/O performance. This was particularly fun given that
one LVM PV had a bcache header and the other one didn't, and I wanted
the filesystems to have suitable alignment for *both* of them at once...
it was distinctly fiddly to get right.)

  parent reply	other threads:[~2020-08-31 19:21 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <16cee7f2-38d9-13c8-4342-4562be68930b.ref@verizon.net>
2020-08-28  2:31 ` Best way to add caching to a new raid setup R. Ramesh
2020-08-28  3:05   ` Peter Grandi
2020-08-28  3:19     ` Ram Ramesh
2020-08-28 15:26   ` antlists
2020-08-28 17:25     ` Ram Ramesh
2020-08-28 22:12       ` antlists
2020-08-28 22:40         ` Ram Ramesh
2020-08-28 22:59           ` antlists
2020-08-29  3:08             ` R. Ramesh
2020-08-29  5:02               ` Roman Mamedov
2020-08-29 20:48                 ` Ram Ramesh
2020-08-29 21:26                   ` Roger Heflin
2020-08-30  0:56                     ` Ram Ramesh
2020-08-30 15:42                       ` Roger Heflin
2020-08-30 17:19                         ` Ram Ramesh
2020-09-11 18:39                         ` R. Ramesh
2020-09-11 20:37                           ` Roger Heflin
2020-09-11 22:41                             ` Ram Ramesh
2020-08-29  0:01           ` Roger Heflin
2020-08-29  3:12             ` R. Ramesh
2020-08-29 22:36               ` Drew
2020-09-01 16:12                 ` Ram Ramesh
2020-09-01 17:01                   ` Kai Stian Olstad
2020-09-02 18:17                     ` Ram Ramesh
2020-09-14 11:40                   ` Nix
2020-09-14 14:32                     ` Ram Ramesh
2020-09-14 14:48                       ` Roger Heflin
2020-09-14 15:08                         ` Wols Lists
2020-08-31 19:20           ` Nix [this message]
2020-08-28 17:46   ` Roman Mamedov
2020-08-28 20:39     ` Ram Ramesh
2020-08-29 15:34       ` antlists
2020-08-29 15:57         ` Roman Mamedov
2020-08-29 16:26           ` Roger Heflin
2020-08-29 20:45             ` Ram Ramesh
2020-08-30 22:16       ` Michal Soltys

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sgc2mxk9.fsf@esperi.org.uk \
    --to=nix@esperi.org.uk \
    --cc=antlists@youngman.org.uk \
    --cc=linux-raid@vger.kernel.org \
    --cc=rramesh2400@gmail.com \
    --cc=rramesh@verizon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).