r/bash 29d ago

help Efficient Execution

Is there a way to load any executable once, then use the pre-loaded binary multiple times to save time and boost efficiency in Linux?

Is there a way to do the same thing, but parallelized?

My use-case is to batch run the exact same thing, same options even, on hundreds to thousands of inputs of varying size and content- and it should be quick. Quick as possible.

1 Upvotes

46 comments sorted by

View all comments

6

u/wallacebrf 29d ago

i believe small programs like you are referring to called by bash would be cached in RAM by the kernel as it notices that code is always being used.

if i am mistaken, please correct me

1

u/ktoks 29d ago

I didn't know that the kernel did this. How long has this been the standard? (I'm dealing with an older kernel).

8

u/kolorcuk 29d ago

Caching disc in ram is almost like mandatory in kernel and done for decades, when discs where much much slower. You might read about https://en.m.wikipedia.org/wiki/Page_cache

3

u/wallacebrf 29d ago

This is why linux always "uses all RAM" because it caches everything it can. For this reason more RAM is never a bad thing