Re: [PATCH 2/3] netfilter : 3 patches to boost ip_tables performance

From: Willy Tarreau
Date: Fri Sep 23 2005 - 06:37:07 EST


On Fri, Sep 23, 2005 at 07:14:24AM +0200, Eric Dumazet wrote:

> Even without CMOV support, the suggested patch helps :
>
> Here is the code generated with gcc-3.4.4 on a pentium4 (i686) for :
>
> /********************/
> bool1 = ((ip->saddr&ipinfo->smsk.s_addr) != ipinfo->src.s_addr);
> bool1 ^= !!(ipinfo->invflags & IPT_INV_SRCIP);
>
> bool2 = ((ip->daddr&ipinfo->dmsk.s_addr) != ipinfo->dst.s_addr);
> bool2 ^= !!(ipinfo->invflags & IPT_INV_DSTIP);
>
> if ((bool1 | bool2) != 0) {
>
> /********************/

(...)

I totally agree with your demonstration. It would be interesting to compare
she same code on an architecture with more registers (eg: sparc). One of
the reasons of bad optimization of such constructs on x86 seems to be the
lack of registers for the number of variables and intermediate results.
When you write the code like above, you show the workflow to the compiler
(and I often use the same technique).

Regards,
Willy

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/