Nicolas Palix wrote:
> On Wednesday 13 January 2010 12:10:20 Michael Stefaniuc wrote:
>> Nicolas Palix wrote:
>>> On Saturday 09 January 2010 17:26:37 Michael Stefaniuc wrote:
>>>> coccinelle 0.1.11 introduced regexp support for meta-identifier/function 
>>>> and constant. The release notes says it's an OCaml regexp and points to 
>>>> "man Str" for details but I don
>>>>
>>>> I tried to make use of grouping and alternatives but I get errors like:
>>>> identifier SPAM ~= "\(WINE_\)?\(ERR\|FIXME\|WARN\)";
>>>>    Fatal error: exception Lexer_cocci.Lexical("unrecognised symbol:\(")
>>>> identifier SPAM ~= "ERR\|FIXME\|WARN";
>>>>    Fatal error: exception Lexer_cocci.Lexical("unrecognised symbol:\|")
>>>>
>>>> Is this a known limitation or just a bug?
>>> The following patch will fix this bug.
>> thanks for the fix; I have tried coccinelle 0.2.0 and it works fine.
>> Using the coccinelle/OCaml regexp seems to be way faster than just using
>> "identifier SPAM;" and filtering it later on in python. For my script on
>> a Wine C file it's the difference between finishing in 12 minutes or
>> killing the spatch process after 90+ minutes of burned CPU time (though
>> the python variant was timed with coccinelle 0.2.0-rc1).
>>
> 
> You're welcome.
> 
> Have you tried to inline your SPAM identifier in the matching part
> of the semantic patch? It is maybe faster than using regexp but I haven't 
> checked.
> Indeed, as you're matching the regexp (~=), and not it's negation, you may 
> replace
> 
> ====================================
> @@
> identifier SPAM ~= "ERR\|FIXME"
> @@
> 
> SPAM
> 
> ====================================
> 
> by
> 
> ====================================
> @@
> @@
> 
>   \(ERR\|FIXME\)
> ====================================
> 
> Please, could you report any performance improvement/degradation if you try 
> this?
Heh, I tried it already but I need to know the type of "SPAM" aka if
it's an ERR or FIXME or WARN. I've done \(e...@p\|fi...@p\|w...@p\) and
the last element matched is stored in p but that seems to be the
function name and not the element to which p is attached.

I have also tried to create separate rules for ERR, FIXME and WARN
messages; that has given me 3 SmPL rules + 2 python rules per spam type
for a total of 15 rules ... I have killed that process after it burned
60+ minutes of CPU time without finishing. I've run those scripts also
with -debug and it doesn't look like an infinite loop as there was some
new debug output now and then.

What I've ended up doing is to split out the rules into 3 cocci files:
one for ERR (~5:30 minutes), one for FIXME (~50 s) and one for WARN (~25
s) and that has given me the best performance. The solution with the
OCaml regexp didn't fare that bad being only 75% slower but wins on the
code maintenance side.

thanks
bye
        michael
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to