help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Keep sed to be in cache ram memory within a execution


From: Greg Wooledge
Subject: Re: Keep sed to be in cache ram memory within a execution
Date: Mon, 2 Nov 2020 08:10:56 -0500
User-agent: Mutt/1.10.1 (2018-07-13)

On Sat, Oct 31, 2020 at 10:11:11AM +0700, Budi wrote:
> How to make/keep sed to be in cache ram memory within execution of
> Bash script/function invoking it repeatedly as a complete loop for
> sake of efficiency

For starters, your operating system will cache files (including programs)
in memory automatically.  You don't need to do anything special.

However, the bigger issue is that you should not be calling sed
repeatedly in a tight loop.  Even without disk I/O, there is still
a tremendous overhead involved in forking a new process every time
you iterate.

Try, if at all possible, to call sed *one* time on the entire input,
and then read sed's output in your script.  Or, replace the transformation
you're doing with sed with some kind of string manipulation that can
be done within bash itself.

Telling us more about what you're doing would help us help you.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]