I want to utilize some of my very much underused RAM to create a RAM drive so that some software that's heavy on the system can get a little help from using that RAM.
I am specifically wanting to run Handbrake, preferably with the GUI. I have the relevant software and information on how to create the actual RAM drive, so i don't need help there, but I wanted to know if
can I set up Handbrake so that it favors the RAM drive over a temporary file directory when doing some calculations what may help with improvement, and if not...
is it possible to install my Handbrake somewhere specific (like on the actual RAM drive so that it would automatically just use it; I've noticed that Ubuntu never asks for a installation location, it just puts what it wants where it wants and we have little choice in the matter).
But I'd also like to know the answer to the "can I install anything on RAM drive, or can it only be used with things that have settings allowing you to force it to use the ram drive as its temp working drive, or is all software just installed where it is and that isn't changeable (from a layman point of view).
Handbrake does make my processor work very hard and it gets very warm, which was another reason that was chosen as the random example before.
Handbrake is a video conversion tool. Video conversion tools tends to be CPU/GPU-heavy, not IO-heavy.
Encoding on CPU, I typically get 25-100 frames per second. If you have a 50Mb/s 24fps film, this means that you have to ingest 200Mb/s, or 25MB/s. This is sequential read from a file, which is the easiest and most predictable IO. Even a spinning 5400RPM cheap laptop hard drive will have zero problems keeping up with that.
Even if you quadruple your encoding ratio, to 400fps, it's only 100MB/s. That's within reach of 7200rpm hard drives, and trivial for SSDs. You'll probably see zero improvement on encoding speeds by using RAM to cache data for video conversion, unless you have very specialized hardware for video encoding. In that case, the way to go is probably fast SSDs, which can easily handle gigabytes per second.
RAM only makes sense if disk IO is your bottleneck. To optimize, you should first identify the actual bottleneck, and then figure out what you can do to work around that bottleneck.
Additionally, dedicating RAM for a RAM drive may make things slower. Linux is pretty good at caching stuff in unused RAM. However, if you force it to cache some things by using a dedicated RAM drive, you risk that things that could benefit from being cached won't be cached.
There's certainly some situations in which you want to explicitly cache things in RAM...
You have to cache some input for processing, quickly. This may for instance be a burst of data from some external sensor, that delivers data for a brief period of time, at a rate that is faster than your disk. In this case, caching it before writing to disk is a good strategy.
You have a process, that is IO bound, that needs to store a data set temporarily.
You have (small) amounts of data that you don't care about, but you need temporarily. This may for instance be phpsession-files for a webserver.
In many cases, the second example may be replaced by pipes, so that no storage is needed. Storage would only be needed in cases where the complete data set has to be available at once.
In most other cases you will have to read or write the data to disk anyway. If you want to keep the result of a transcode, you have to move it to a disk. If you want to move a video to be transcoded to a RAM drive, you have to read it from disk first, and so forth...
Remember that the OS caches files in RAM by default. Whenever a file is read by the OS, it's cached in RAM. When a file is written, it's cached.
Usually, applications on Linux use the dedicated tmp directories, /tmp or /var/tmp, for their temporary files.
/tmp
allegedly is for quick short term use, whereas/var/tmp
should persist between boots. If your aim is to reduce tear and wear of an SSD disk, then moving /tmp to RAM will eliminate SSD disk activity when applications write to these temporary directories.You can move
/tmp
to RAM adding this line to your/etc/fstab
:The memory used by a tmpfs file system grows ans shrinks according to the needs. If memory is lacking, swap is used. By default, Ubuntu already uses tmpfs by default for directories like
/run
,/dev/shm
and others.Obviously, this is a generic answer. It will help you also for Handbrake provided that application also uses /tmp for its temporary files.