Ash, Bash, Dash

Regarding the move to Dash by some distros, we need to ask just what is Dash? Well, it is basically Ash, and we have always had Ash in Puppy! See this URL:

http://www.in-ulm.de/~mascheck/various/ash/

The Ash shell is provided by Busybox. In a script, you put this at the top:
#!/bin/ash

With Busybox, if you link /bin/sh to the busybox executable (it is normally linked to bash), then this will also run Ash (depending on how Busybox is configured):
#!/bin/sh

Now this is very interesting. Running Puppy 4.1.2 on my laptop, locale en_AU, my speed-test script gives 33 seconds. Change over to Ash and I get 26 seconds.

However it gets more exciting.... if I first run 'export LANG=C' then using Bash the script takes 22 seconds, using Ash takes just 17 seconds!

Very old versions of Puppy did not have Bash, just Busybox Ash. I don't recall what version that Bash got introduced, but I think it was back in the Puppy1 series. The reason was improved compatibility with all the scripts out there, but oh boy I never realised right until now, what a speed penalty we have paid!

Then I wondered about Busybox in the initial ramdisk in Puppy, where we use Ash to run the 'init' script. I configured Busybox with this:
# CONFIG_LOCALE_SUPPORT is not set

On the other hand, Busybox in the main Puppy filesystem is configured with:
CONFIG_LOCALE_SUPPORT=y

I tested with the static busybox from the initial ramdisk, and was surprised that I got 26 seconds, then when set LANG=C I got 17 seconds. Huh, locale is supposed to be disabled! This is weird.

Final thought:
I am writing here about scripts, but doesn't the speed penalty of the locale setting also apply to compiled applications? Should do, as they also call libc functions. It would be interesting to create a simple C 'speed-test' application.

Posted on 32 Jan 2009, 8:56


Comments:

Posted on 1 Feb 2009, 17:28 by Bm
Ash Bash Dash
Nice to know there is a 32 of january.
Special for Australia? ;-)


Posted on 1 Feb 2009, 18:53 by 01micko
32=1
Beem, yes, different whatzisphere you know.
Barry, POSIX compliance is what 'amigo' pointed me to, which dash is, and moreso ash than bash, lucky there's no hash.


Posted on 1 Feb 2009, 19:12 by Dougal
dash vs. ash
No, dash is not exactly the same as Busybox ash.
dash is really just the bare minimum, while Busybox ash includes some bashisms (the "let" command is one I'm aware of) and I suspect dash might be faster, as the Debian folk are probably interested in it (busybox is optimized for size).

Note that just move to using dash, in case any of your scripts include bashisms... I've been planning to do so for a while and have already changed a few of my scripts to explicitly state "/bin/bash" if they do (rc.network is one of them). You can always get rid of bashisms, but I'm not sure the extra subshells etc. that it will require won't actually lose any speed improvements...


Posted on 23 Aug 2010, 22:36 by linuxcbon
ash
Can you put
#!/bin/ash

export LANG="C"

In many scripts ?