This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Making /bin/sh == bash. Has the time come?


A long time ago, in a Cygwin release prior to B20.1, someone made the
decision to use "ash" as the standard /bin/sh for Cygwin.  The sole
reason for doing this was that ash was faster than bash.

Later, at one point, I implemented a sorta-wannabe version of vfork, and
commissioned one of the people who worked for me to modify ash to use
vfork.  This made ash even faster than it was before.

Recently, after too many hours hacking at vfork corner cases, I came to
the conclusion that getting vfork working correctly was too difficult
so, I turned off vfork in cygwin and asked Corinna to modify ash to use
/bin/sh again.

So, that leaves us with an ash which is still faster.  For example:

  e:\>time ash -c "i=0; while [ $i -lt 1000 ]; do i=$(expr $i + 1); done"
  32.24user 9.72system 0:12.85elapsed 326%CPU (0avgtext+0avgdata 11677696maxresident)k
  0inputs+0outputs (730699major+0minor)pagefaults 0swaps

  e:\>time bash -c "i=0; while [ $i -lt 1000 ]; do i=$(expr $i + 1); done"
  49.86user 16.51system 0:23.04elapsed 288%CPU (0avgtext+0avgdata 20525056maxresident)k
  0inputs+0outputs (1284873major+0minor)pagefaults 0swaps

i.e., bash is twice as slow as ash.  However:

  e:\>time bash -c "i=0; while [ $i -lt 1000 ]; do i=$(($i + 1)); done"
  0.14user 0.01system 0:00.15elapsed 101%CPU (0avgtext+0avgdata 15712maxresident)k
  0inputs+0outputs (982major+0minor)pagefaults 0swaps

So, there are some constructs available in bash which, if you assume that
bash == /bin/sh, will result in much faster shell script execution.

And, anyone who reads this list regularly will know that we get a lot of
complaints about the differences between bash and ash, which cause
people to eventually copy bash to /bin/sh.

So, in conversation with Corinna, I think that we're starting to lean
towards making /bin/sh == bash sometime soon.  We won't get rid of ash
and will point to it when people send the inevitable "Cygwin is slow!"
message here.

I was thinking that we should have something like linux's "alternatives"
command which would allow us to set up /bin/sh to whatever a user
decides is best for them, defaulting to /bin/bash.  This is, of course,
trickier to do right on cygwin since you can't use a cygwin symbolic
link to do a 'ln -s /bin/bash /bin/sh' but you could still do something
with a copy, recording preferences in a file.

Anyway, I wanted to get people's feelings on making this change.  Is
anyone actually relying on ash for some reason?

cgf

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]