question for linux fags: how can i cache a file into memory. i would like to run time a hash function to find out how it performs without disk i/o bottleneck. something like...
> $ time sha256sum file.dat
but from memory, not from disk
Mount a ramfs and copy your file to it, then use that copy.
>>58571675
thx. will try it.
mount -t tmpfs -o size=[insert size in mebibytes here]m,nodev,exec,mode=1777
I just added a line to my fstab to do this. Whenever I watch videos or movies from my HDD, I copy them to the ram first. Because I'm a sperg.
Also, do yourself a favor and google 'ramfs vs tmpfs'. You will want to use one of these instead of the other. Which one you want is a matter of preference and what you're doing.
>>58571750
Use ramfs.
There's no guarantee the data will be in ram otherwise. ramfs uses only ram. tmpfs will use both ram and swap.
>>58571750
>Whenever I watch videos or movies from my HDD, I copy them to the ram first.
WUT
What if you no longer want to watch the movie, you'd have read it all from the disk for nothing.
>>58571665
nigger just copy it to /tmp
>>58571750
You realize HDD are perfectly suited to reading 8k video fast enough without copying to RAM or SSD, right?
>>58571750
I like tmpfs a lot. But make sure you know what it does (and that you've got swap!)
It stores the files in RAM if and only if there is RAM not in use by anything else, including drive caching. Otherwise, it stores them on swap.
This is great for long term things like on a server, but for one-off jobs where you need it in RAM, not so much.
>>OP
There is a readahead service standard in most distros, even if it's not enabled by default. This can be used to load your file into RAM without playing with RAM drives.
You can also tweak the sysctls to be more aggressive at using memory or file and drive caching.
>>58571665
>I have 65GB of ram when i boot up my computer it loads all basic components into ram, also it loads some porn to just in case I need a quick fap
>>58571665
you could just docat file.dat > /dev/null
as reading a file also puts it in page cache if there is enough free memory available
>>58571665
>Mfw 3rd Kyu / All green belt in Judo
>>58571815
Yeah this.
>>58571665
mpv should never cut from streaming from disk. If it does, increase your "cache" (actually buffer) size in mpv.
>>58573723
getting the whole movie to ram however allows the hdd to spindown for the duration of the movie. (using a tmpfs for this is however idiotic as the same could be archived with just tweaking the caching settings)
>>58571665
Check out fincore from linux-ftools.
>>58571750
>all this cryptic shit just to open a file on linux
Year of the Linux desktop
txh for all the advice
op
>>58574345
why are the technically illiterate still allowed in here?
Copy the file to /dev/shm
>>58574919
better question is why are people who failed reading comprehension for dummies allowed here.