Tip: Running Plex transcoding on RAMdisc

DLNA, AirPlay, Chromecast, PS3, XBOX, iTunes, & other media players
Locked
TomWoB
New here
Posts: 3
Joined: Sun Feb 06, 2011 11:35 pm

Tip: Running Plex transcoding on RAMdisc

Post by TomWoB »

Hi all,

last week I found something out, which may be interesting for other Plex users too: a way to force Plex to store the "temp transcoding files" in the memory and not physically on the discs. Btw: I'm not often checking this forum and maybe this is written already somewhere else ... I don't know ... anyway, here are my explanations:

First of all, I have a TS-251+ with 8GB RAM, which is OK for transcoding up to 720p. I have less Apps installed, the two relevants are:
  • CodexPack
  • Plex
OK, after login on my NAS with SSH and executing "df" I saw the following:

[~] # df
Filesystem Size Used Available Use% Mounted on
none 200.0M 175.3M 24.7M 88% /
devtmpfs 3.8G 8.0k 3.8G 0% /dev
...
tmpfs 3.8G 0 3.8G 0% /share/MD0_DATA/.qpkg/CodexPack/run
...

WOW, it looks like that there are 3.8G available on tmpfs (=RAMdisk). So I configured the "Transcoder temporary directory" in the settings of my Plex server to the folder "/share/MD0_DATA/.qpkg/CodexPack/run". Then I tested it with "an old 3.2 GB DVD MPEG-2 movie". So, after starting watching the movie on my Apple-TV 4, I was continuously checking the file creation and RAM usage on my NAS with my PC and SSH:
  • Plex generated a subfolder "plex-transcode-7874D2BE-E4D2-431C-B115-181BDB6A1CEF-79634c99-442d-445d-b474-fe6c6cd8fab7/" in the configured folder "/share/MD0_DATA/.qpkg/CodexPack/run"
  • a lot of "temp transcoding files" are generated in this folder ... at the end there were 986 files: media-00000.ts - media-00985.ts (size up to 4 MB)
  • this temp files were generated "during watching the movie", and the RAM usage increased parallel to the size of these temp files
  • at the end: tmpfs 3.8G 2.2G 1.6G 58% /share/MD0_DATA/.qpkg/CodexPack/run
  • -> 986 temp files with 2.2 GB !
  • after stopping the movie and jumping back to the "overview page of my movies", the Plex transconding temp folder "plex-transcode-787..." was deleted and the RAMdisk was cleaned up
I personally like to know that these approx 1000 temp files are created/deleted in RAM and not on my RAID1 system, performance on a RAMdisk is anyway much better ...

I just want o share this finding with all of you ... maybe you like it !
User avatar
Spider99
Experience counts
Posts: 1951
Joined: Fri Oct 21, 2011 11:14 pm
Location: UK

Re: Tip: Running Plex transcoding on RAMdisc

Post by Spider99 »

Nice catch :)

I dont use Plex but can think of a few other things i could use this for :)
Tim

TS-853A(16GB): - 4.3.4.0483 - Static volume - Raid5 - 8 x 4TB HGST Deskstar NAS
Windows Server + StableBit Drivepool and Scanner ~115 TB Backup Server
TS-412 & TS-459 Pro II: Retired
Clients: 3 x Windows 10 Pro(64bit)
321liftoff
Know my way around
Posts: 214
Joined: Sat Oct 22, 2011 6:54 pm

Re: Tip: Running Plex transcoding on RAMdisc

Post by 321liftoff »

I've been looking at the same. I have a TS-453Be with 10GB isntalled (2GB + 8GB). I don't have CodexPack installed, but looking at the output of "df", I saw the following tmpfs lines:

Code: Select all

[/] # df | grep tmpfs  
devtmpfs                  4.8G      8.0K      4.8G   0% /dev
tmpfs                    64.0M      1.8M     62.2M   3% /tmp
tmpfs                     4.8G     10.6M      4.8G   0% /dev/shm
tmpfs                    16.0M         0     16.0M   0% /share
tmpfs                    16.0M         0     16.0M   0% /mnt/snapshot/export
tmpfs                     1.0M         0      1.0M   0% /mnt/rf/nd
tmpfs                    64.0M      1.9M     62.1M   3% /samba
tmpfs                    16.0M    100.0K     15.9M   1% /share/CACHEDEV1_DATA/.samba/lock/msg.lock
tmpfs                    16.0M         0     16.0M   0% /mnt/ext/opt/samba/private/msg.sock
I changed my Plex server to use the "/dev/shm", which I understand is a shared memory mount for RAM. It's working the same as OP outlined.

Anyone know how to increase the size of the /dev/shm mount, also so the size change stays the same after reboot?
User avatar
OneCD
Guru
Posts: 12039
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: Tip: Running Plex transcoding on RAMdisc

Post by OneCD »

321liftoff wrote:Anyone know how to increase the size of the /dev/shm mount, also so the size change stays the same after reboot?
To resize the existing tmpfs to 6GB:

Code: Select all

mount -o remount,size=6G tmpfs /dev/shm
It won't be persistent, so add this command to your autorun script. Please note: this device can be resized (up or down) at any time by QTS.

Or, you can make your own. Here's how to create a new 4GB RAM-disk.

Create a filesystem mount-point:

Code: Select all

mkdir /plex.transcoding.tmp
... then create a RAM disk and mount it at that location:

Code: Select all

mount -t tmpfs -o size=4G tmpfs /plex.transcoding.tmp
When you're done, use:

Code: Select all

umount /plex.transcoding.tmp
... to free that RAM for use.

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
chakrit
First post
Posts: 1
Joined: Sat Dec 26, 2020 10:57 pm

Re: Tip: Running Plex transcoding on RAMdisc

Post by chakrit »

looks interesting... thank you TomWoB, 321liftoff and OneCD.
so i think i could make use of this for qBit temp to avoid wearing my ssd
Locked

Return to “Media Streaming”