You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by Rocky Olsen <ro...@mindphone.org> on 2005/04/22 00:47:57 UTC

Meta Rule Evaluation Order?

I'm wondering what the order of evaluation is for the following scenario.

body __sub_meta_a  some-not-costly-eval
body __sub_meta_b  a-costly-eval

meta meta_rule  (__sub_meta_a && __sub_meta_b)


under this example, which of the following happen?

a)  __sub_meta_a AND __sub_meta_b are evaluated first, followed by
meta_rule being evaluated.

b) meta_rule is checked first, then if __sub_meta_a evaluates to true,
__sub_meta_b is also evaluated, else if __sub_meta_a evals to false
__sub_meta_b isn't eval'ed.



I'm guessing the answer is probably a), but i wanted to check anyway.

-Rocky

-- 
______________________________________________________________________


what's with today, today?

Email:	rocky@mindphone.org
PGP:	http://rocky.mindphone.org/rocky_mindphone.org.gpg

Re: Meta Rule Evaluation Order?

Posted by Theo Van Dinter <fe...@kluge.net>.
On Thu, Apr 21, 2005 at 07:05:40PM -0400, Matt Kettler wrote:
> >body __sub_meta_a  some-not-costly-eval
> >body __sub_meta_b  a-costly-eval
> >meta meta_rule  (__sub_meta_a && __sub_meta_b)
> >
> >under this example, which of the following happen?
> >
> >a)  __sub_meta_a AND __sub_meta_b are evaluated first, followed by
> >meta_rule being evaluated.

Yep.

> AFAIK all rules beginning with __ are always executed. There's no
> optimization of meta sub-parts. Even completely unreferenced sub-parts
> will be executed.

Yes, mostly.  Just for clarification:  Rules beginning with __ are simply
rules, so they execute like any other rules.  The only difference is
that by default they don't contribute to the message score.  You can do
"score __RULE 0" and disable it if you want to.

So based on this, assuming the __sub_meta* rules aren't disabled, the non-meta
rules run first, then the meta rules are run, so there's no short circuiting
of evals possible with the current code.

You could fake this, however, by manually manipulating things ala:

body __sub_meta_a  some-not-costly-eval
body __sub_meta_b  a-costly-eval
priority __sub_meta_a -1000
# __sub_meta_b stays at default priority of 0

Then in the eval (assuming code here, not just RE,) for __sub_meta_b,
check to see whether __sub_meta_a has triggered, since by specifying
the priority, you're guaranteed that it will run first.  If it didn't
trigger, return 0 immediately.  Otherwise, proceed with the code.


To answer the next possible question, BTW:

meta __meta_a __sub_meta_a && __sub_meta_b
meta __meta_b __sub_meta_c && __sub_meta_d
meta RULE __meta_a || __meta_b

The SA code determines that RULE has 2 other meta rule dependencies and will
schedule that to run after the __meta_* rules which have 0 other meta rule
dependencies. :)

-- 
Randomly Generated Tagline:
Always remember that you're representing our country.  I guess what I'm
 saying is, don't mess up France the way you messed up your room.
 
 		-- Homer Simpson
 		   The Crepes of Wrath

Re: Meta Rule Evaluation Order?

Posted by Matt Kettler <mk...@evi-inc.com>.
Rocky Olsen wrote:

>I'm wondering what the order of evaluation is for the following scenario.
>
>body __sub_meta_a  some-not-costly-eval
>body __sub_meta_b  a-costly-eval
>
>meta meta_rule  (__sub_meta_a && __sub_meta_b)
>
>
>under this example, which of the following happen?
>
>a)  __sub_meta_a AND __sub_meta_b are evaluated first, followed by
>meta_rule being evaluated.
>
>b) meta_rule is checked first, then if __sub_meta_a evaluates to true,
>__sub_meta_b is also evaluated, else if __sub_meta_a evals to false
>__sub_meta_b isn't eval'ed.
>
>
>
>I'm guessing the answer is probably a), but i wanted to check anyway.
>
>  
>

The answer is a. 

AFAIK all rules beginning with __ are always executed. There's no
optimization of meta sub-parts. Even completely unreferenced sub-parts
will be executed.

A lot of this probably has the same reason why the old "abort scanning
when score is over threshold" feature is no longer around. Doing that
correctly forced SA to order it's rules in a sub-optimal way, and the
performance hit of doing that was much worse than the gain from skipping
some rules.