[Debian-eeepc-devel] How to deal with the freeze?

Cristian Ionescu-Idbohrn cristian.ionescu-idbohrn at axis.com
Mon Nov 8 15:20:01 UTC 2010


On Mon, 8 Nov 2010, Luca Niccoli wrote:
>
> We extract just 2 characters, the :4:5 was just a mistake.

Alright.

> This is going to be fine until 2.6.99, I think that's plenty.
> We just don't care about extraversion.
>
> >        LINUX_MINOR_REV=${LINUX_FULL_VER:4:5}
>
> The bashism (and bug) has been cleared in git.
>
> > than this way:
> >
> >        LINUX_FULL_VER=$(uname -r)
> >        LINUX_MINOR_MAYBE_XTRA=${LINUX_FULL_VER#*.}
> >        LINUX_MINOR_MAYBE_XTRA=${LINUX_MINOR_MAYBE_XTRA#*.}
> >        [ ${#LINUX_MINOR_MAYBE_XTRA} -le 5 ] || {
> >                slak=${LINUX_MINOR_MAYBE_XTRA#?????}
> >                LINUX_MINOR_MAYBE_XTRA=${LINUX_MINOR_MAYBE_XTRA%$slak}
> >        }
>
> You're saying that you'd prefer this against:
> LINUX_MINOR_REV=`uname -r | cut -c 5,6`

Except, what would not be MINOR_REV, but only MINOR.

Yes, as it has some advantages over hardcoded string positions '5,6':
* removes VERSION and PATCHLEVEL, as it knows how to parse that
* does not need a fork (cut) and a pipe
* uses shell builtins

That can also be done even without forking 'uname'.  LINUX_FULL_VER is
word nr. 3 in /proc/version, and that can be picked up with:

	read dummy dummy LINUX_FULL_VER rest </proc/version

Chop of MINOR is faster done with parameter expansion.

I did try even earlier to get the message over, and I'll try one more
time.  The shell scripts used in various *acpi-* packages are
terribly slow, as they use BIG canons (like sed, awk, etc) to kill
small flies (edit simple strings, read 1-line files, and so on).

Extensive use of shell builtins can improve (in certain cases)
performance by a factor 20; I'm guessing (after reading enough of
those scripts) an overall average factor 5.  And performance _is_
important in that context.  Inefficient constructs like:

	cat file | grep string | sed 's/string/otherstring/'

are not unusual either.


Cheers,

-- 
Cristian



More information about the Debian-eeepc-devel mailing list