[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

question for linux fags: how can i cache a file into memory.

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 21
Thread images: 1

File: judo.jpg (59KB, 800x531px) Image search: [Google]
judo.jpg
59KB, 800x531px
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 do
cat 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.
Thread posts: 21
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.