[Sugar-devel] SoaS on XO bootcharts

Bobby Powers bobbypowers at gmail.com
Wed Mar 4 20:54:11 EST 2009


On Wed, Mar 4, 2009 at 11:04 AM,  <pgf at laptop.org> wrote:
> wade wrote:
>  > These charts are really interesting (and nice looking!).  The whole thing
>  > probably requires a lot of analysis to make real gains though.  I wonder
>  > what all those calls to 'cat' are in the first chart.  I also wonder if it
>
> i did some looking, and while i don't think i've found the
> real culprit, i have found a _lot_ of usage of this idiom in the
> scripts:
>
>    [A]
>        cmdline=$(cat /proc/cmdline)
>
> or
>
>    [B]
>        if [ `cat /proc/sys/net/ipv4/ip_forward` != 0 ]; then
>            action $"Disabling IPv4 packet forwarding: " sysctl -w >
>        fi
>
> or
>
>    [C]
>        mfgtag () {
>                cat $MFG_DATA/$1 | tr -d '\000' 2>/dev/null
>        }
>
>
> in every case, the "cat" process is completely unnecessary.
>
> if i thought bash was a good idea, i'd point out:
>    $(< file)
> which returns the contents of "file".  but even without
> bash (which is probably appropriate if you're looking for
> efficiency), you can do:
>
>    [A]
>        read cmdline < /proc/cmdline
>
> and this, which preserves the look of the code a bit more:
>
>    [B]
>        firstline()
>        {
>            read __line < $1;  echo "$__line"
>        }
>
>        if [ `firstline /proc/sys/net/ipv4/ip_forward` != 0 ]; then
>            action $"Disabling IPv4 packet forwarding: " sysctl -w >
>        fi
>
> and finally this:
>
>    [C]
>        mfgtag () {
>                tr -d '\000' < $MFG_DATA/$1  2>/dev/null
>        }
>
> or even:
>
>    [C]
>        mfgtag () {
>                tr -d '\000' $MFG_DATA/$1  2>/dev/null
>        }
>
> the shell is really pretty fast, if you can keep the number for
> spawned processes to a minimum.

this sounds like a super headache to get upstream, but with a possibly
significant payoff.  are the scripts you're talking about the ones in
/etc/init.d/ ?  it could be interesting to 'correct' the scripts and
see what the performance difference is.

Bobby

> paul
> =---------------------
>  paul fox, pgf at laptop.org
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
>


More information about the Sugar-devel mailing list