Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monitor "Now playing" and move to cache? #20

Open
TheLinuxGuy opened this issue Aug 19, 2023 · 6 comments
Open

Monitor "Now playing" and move to cache? #20

TheLinuxGuy opened this issue Aug 19, 2023 · 6 comments

Comments

@TheLinuxGuy
Copy link

Could you consider adding a feature that monitors whatever media a user starts playing and have the script execute a copy to the unraid cache drive (effectively a copy)? then later purge the clone present in cache mount?

@bexem
Copy link
Owner

bexem commented Aug 23, 2023

Thank you for your suggestion. Let me make sure I understand your request:

  1. You'd like the script to detect when a user starts playing a specific media, say "movie1."
  2. If "movie1" isn't on the cache drive, the script should copy it there.
  3. Once playback ends, "movie1" should be removed from the cache.

If I've got that right, I have a few thoughts:

While I hope to implement active monitoring of the Plex server in the future, I'm not sure if this specific functionality would yield the desired improvements. When a media starts playing, Plex reads it from the array. If we initiate a copy to the cache at this point, Plex is unlikely to switch its read source midway. Moreover, copying might strain the disk performance, especially during playback.

The potential benefits might be more noticeable for larger files, like high-quality blue-ray rips, but for most content, I don't believe there'd be a significant improvement.

If I've misunderstood your request, please let me know!

@TheLinuxGuy
Copy link
Author

Hey @bexem - you have summarized the request well.

if we initiate a copy to the cache at this point, Plex is unlikely to switch its read source midway.

I vaguely recall some discussion on reddit mentioning the FUSE filesystem on unraid if configured as primary tier = cache, secondary = array - that fs reads get redirected to array but if the cache suddenly sees the same file with the same data that file operations may move to the cache seamlessly. I wish I had bookmarked it.

Consider playing a 3 hour movie only present in the array; an array hard drive spun-down would need to be active for the entire 3 hours plus some change. Where-as if this activity would work as noted above and FUSE did some invisible magic - the hdd could be spun down shortly after the copy to nvme cache is complete. Yielding 2.5+ hours of "hd idle"

@bexem
Copy link
Owner

bexem commented Aug 23, 2023

If it works like you said then it make absolutely sense implementing that, it would save some energy. Good idea!

I'll put it in my pipeline, if you don't mind looking for the source of your information or anything that could put me in the right direction I will appreciate it.

@TheLinuxGuy
Copy link
Author

TheLinuxGuy commented Aug 24, 2023

If it works like you said then it make absolutely sense implementing that, it would save some energy. Good idea!

I think I found where I read about it... "Because of shfs mechanism accessing a file from /mnt/user will read/write fro cache if it exists, then from array. Duplicate data are not a problem and globally speed up things."

Also "Edit 13-02-2020: yes, after checking with File Activity plugin, that's the case and its plex/transmission take the file on cache as soon as it is available!"

see https://forums.unraid.net/topic/92126-smart-caching-script/

@bexem
Copy link
Owner

bexem commented Aug 24, 2023

That is great news, thanks for the update! I will hopefully manage to implement this ☺️

@rozza591
Copy link

This would be a great addition if it ends up working on plex's end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants