[apparmor] [patch] aa-decode performance tuning
John Johansen
john.johansen at canonical.com
Mon Nov 5 22:10:33 UTC 2012
On 11/01/2012 11:06 AM, Christian Boltz wrote:
> Hello,
>
> here's a patch that speeds up aa-decode - in my case from 1.9s to 0.3s
> (test log with about 900 lines, with 16 encoded lines)
>
> The trick is to use bash regex matching instead of calling egrep for
> each line.
>
> It would probably also be possible to replace the sed calls with bash
> regex matching, but the savings would be minimal because typically
> most lines are not encoded.
>
> BTW: Not having quotes arond the regex is intentional - with quotes
> added, bash wouldn't take it as regex.
>
So I am fine with this if we are going to drop more generic shell compat
and require bash. I know in the past we have tried to not require bash,
but I am unsure how important that is atm
>
> === modified file 'utils/aa-decode'
> --- utils/aa-decode 2012-10-15 22:19:49 +0000
> +++ utils/aa-decode 2012-11-01 17:57:33 +0000
> @@ -70,7 +70,7 @@
> while read line ; do
>
> # check if line contains encoded name= or profile=
> - if echo "$line" | egrep ' (name|profile)=[0-9a-fA-F]' >/dev/null ; then
> + if [[ "$line" =~ \ (name|profile)=[0-9a-fA-F] ]]; then
>
> # cut the encoded filename/profile name out of the line and decode it
> ne=`echo "$line" | sed 's/.* name=\([^ ]*\).*$/\\1/g'`
>
>
>
>
> Regards,
>
> Christian Boltz
>
More information about the AppArmor
mailing list