Re: [apparmor] [patch] aa-decode performance tuning
Hello, Am Montag, 5. November 2012 schrieb John Johansen: On 11/01/2012 11:06 AM, Christian Boltz wrote: 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 Well, I already made aa-decode bash-specific with my last patch by using bash replacement like ${foo/bar/baz} instead of sed, so the performance patch won't change anything ;-) I think it is safe to assume that bash is available on every linux system. Regards, Christian Boltz -- got a patch? -ENOTMYJOB [ Markus Rueckert and Bernhard Walle in opensuse-packaging] -- AppArmor mailing list AppArmor@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor
Re: [apparmor] [patch] aa-decode performance tuning
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 + +++ utils/aa-decode 2012-11-01 17:57:33 + @@ -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 -- AppArmor mailing list AppArmor@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor
Re: [apparmor] [patch] aa-decode performance tuning
Hey that's pretty awesome :) do you know which version of bash introduced regex? -Original Message- From: Christian Boltz appar...@cboltz.de Sender: apparmor-boun...@lists.ubuntu.com Date: Thu, 01 Nov 2012 19:06:21 To: apparmorapparmor@lists.ubuntu.com Subject: [apparmor] [patch] aa-decode performance tuning 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. === modified file 'utils/aa-decode' --- utils/aa-decode 2012-10-15 22:19:49 + +++ utils/aa-decode 2012-11-01 17:57:33 + @@ -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 -- I wonder how we ended up with baseurl and extra_url, now we are missing one with a - like data-dir to violate consistency and the principle of least surprise in all possible ways. [Duncan Mac-Vicar Prett in bnc#449842] -- AppArmor mailing list AppArmor@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor -- AppArmor mailing list AppArmor@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor
Re: [apparmor] [patch] aa-decode performance tuning
Hello, Am Donnerstag, 1. November 2012 schrieb Seth Arnold: Hey that's pretty awesome :) do you know which version of bash introduced regex? http://www.linuxjournal.com/content/bash-regular-expressions says: Since version 3 of bash (released in 2004) there is another option: bash's built-in regular expression comparison operator =~. I'd assume that's old enough to be available on everyone's system ;-) Regards, Christian Boltz -- I forgot to mention: The default language will of course be English! In UTF-8 or latin1? [ Christoph Thiel and Marcus Meissner] -- AppArmor mailing list AppArmor@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor