FAQ

On Fri, Apr 24, 2015 at 3:45 PM, E.B. wrote:
Interesting thread i started! Sorry if my question was too vague: -->
On Fri, 4/24/15, Joerg Schilling wrote:

The Bourne Shell is also much faster than bash. In special on platforms like
Cygwin, where Microsoft enforces extremly slow process creation.
This gets at what I was thinking. For scripts that are not run interactively, it
seems wasteful to load all of Bash autocomplete, command history and all
its rich features.

For running in high volume mail server for example, *short* scripts that take
a few input args and invoke another program. Or do a mysql update (but
it has been pointed out invoking mysql from a shell script is also inefficient
since mysql client is also very feature rich with command history and things).
Or take some arguments and make a curl HTTP request somewhere.

So my question is should I install ksh (I see it is available in yum centos
base repo) and use that? Or should we consider to rewrite these short
scripts to perl? I read on the web that perl with a few typical libraries is
far slower to start up than a shell script. ?? (no heavy computations)

I'd do some serious timing tests in your typical environment before
believing anything about this. The part that takes substantial time
is if you have to load code from disk. Anything already running
(loaded from the same inode, so including hard links to different
names) should run shared-text without loading a new copy (also saving
memory...). Anything that had been loaded recently but needs a new
copy should be reloaded quickly from cache. Loading a new instance of
some little used interpreter is going to hit the disk.


Your most likely win would be to consolidate operations into longer
scripts and use perl where it can do work that would involve several
other programs as shell commands. For example, I'd expect a single
perl program with several mysql operations to be much faster than a
shell script that needs to invoke mysql more than once - plus it is a
lot easier to access the data in a perl program.


--
    Les Mikesell
      lesmikesell at gmail.com

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

People

Translate

site design / logo © 2021 Grokbase