by hamandcheese · 2y ago · 0 comments
I have a somewhat large zfs array and it makes consistent noise as I stream videos from it. The streaming is basically a steady trickle compared to what the array is capable of. I'd rather incur all the noise up front, as fast as possible, then continue the stream from a silent SSD.
You may be interested in checking out bcache[1] or bcachefs[2].
[1] https://www.kernel.org/doc/html/latest/admin-guide/bcache.ht...
https://github.com/45Drives/autotier is exactly what they were asking for as well
Worked well enough on the small scale, but sadly haven't had the time or hardware to test it in a more production-like environment.
Also, it was starting to feel a bit like a Jenga tower, increasing the chances of bugs and other weird issues to strike.
You can do all sorts of really neat things. You can define pools of drives at different cache levels. You can have a bunch of mechanical drives for deep storage, some for hot storage, SSD to cache recently read files, then write-through from the SSD down to mechanical drives, either immediately or after a delay.
It's pretty much everything I could wish for from a filesystem, though I haven't actually taken the time to try it out yet. AFAIK it's still somewhat experimental, more or less in beta.
Edit: or maybe it was some drama over userspace tooling, I can't remember tbh.
https://jonathancarter.org/2024/08/29/orphaning-bcachefs-too...
Additionally, ZFS supports using SSDs to supplement the cache.
http://jolly.jinx.de/teclog/2012.10.31.02-fusion-drive-loose...
ZFS has caching for writes (SLOG)[0][1] and reads (L2ARC),[2][3] which was introduced many years ago when HDDs were cheap and flash was still very, very expensive:
* https://www.brendangregg.com/blog/2009-10-08/hybrid-storage-...
[0] https://openzfs.github.io/openzfs-docs/man/master/7/zpoolcon...
[1] https://openzfs.github.io/openzfs-docs/man/master/8/zpool-cr...
[2] https://openzfs.github.io/openzfs-docs/man/master/7/zpoolcon...
[3] https://openzfs.github.io/openzfs-docs/man/master/8/zpool-ad...
Also, the L2ARC is great, but does still have RAM overhead. There are also useful tunables. I had a workload on a RAM limited machine where directory walking was common, but data reads were fairly random and a L2ARC configured for metadata only speed it up by a large amount.
Not really.
It will accumulate synchronous writes into the ZIL, and you put the ZIL on a fast SLOG vdev. But it will only do so for a limited amount of time/space, and is not meant as a proper write-back cache but rather as a means to quickly service synchronous writes.
By default asynchronous writes do not use the ZIL, and hence SLOG vdev at all. You can force it to, but that can also be a bad idea unless you have Optane drives as you're then bottlenecked by the ZIL/SLOG.
A SLOG needs to have: good throughput and low latency at a queue depth of 1.
Edit: demuxer-max-bytes=2147483647
Another much simpler filesystem-agnostic alternative would be to copy it over to the SSD with a script and commence streaming from there. You'll have to wait for the entire file to copy for the stream to start, though. I think some streaming servers may actually support this natively if you mount /var and/or /var/tmp on the faster drive and configure it to utilize it as a "cache".
As a sibling says, ZFS should support this pretty transparently.
blockdev --setra <num_sectors> /dev/sdX
But I feel like there was a sysctl for this too in the past. I used it back in the day to make the HDD in my laptop spin down immediately after a new song started playing in rhythmbox by setting it to 16MB.I'm unsure if they ship any macs with these anymore. I guess not since the Apple Sillicon iMacs don't have spinning hard drives?
cat filename > /dev/null
Reads the entire file into the OS buffer. cache=yes
demuxer-max-bytes=5G
demuxer-max-back-bytes=5GI'm using Jellyfin server and Infuse on Apple TV, so I don't have a great way to force-slurp a file on first read, at least not without patching Jellyfin. And I'm not super eager to learn C#.
Even if I were streaming to mpv, most of my lan is only gigabit which is much less than what my storage array can put out.
Maybe there is some combination of settings that will get it to cache more aggressively; just saying that it's not a given that it will do so.
/sys/module/zfs/parameters/zfs_arc_max
or setting the module e.g. in /etc/modporbe.d/zfs.conf
to something like this options zfs zfs_arc_max=<size in bytes>
). But be careful, as the ZFS ARC does not play that nice with the OOM killer.have a ssd ie mounted in /tmp/movies
and create a script in .bin/ (or whatever)
#!/bin/sh
tmp_m="/tmp/movies/$(mktemp -d)"
cp "$@" $tmp_m
mpv $tmp_m
rm $tmp_m
please note i have not tried the script but it probably works