[ofw] [IPOIB_NDIS6_CM] enhance wc linking loop performance by removing array index calculations

Hefty, Sean sean.hefty at intel.com
Mon Aug 16 17:14:30 PDT 2010


> for( i = 0; i < MAX_SEND_WC; i++ )
>      wc[i].p_next = &wc[i + 1];
> wc[MAX_SEND_WC - 1].p_next = NULL;
> 
> for( p_free=wc; p_free < &wc[MAX_SEND_WC - 1]; p_free++ )
>      p_free->p_next = p_free + 1;
> p_free->p_next = NULL;
> 
> If the MS WDK compiler optimizations are really 'good', it might optimize the loops to basically the
> same instruction sequence.  I do not believe this to be the case.
> 
> The slightly faster execution time is based on the observation that the total number of instructions
> executed is reduced by skipping the array index arithmetic by use of pointers.

FWIW, out of curiosity, I ran a test on my desktop using the VS compiler to compare code that used the above loops.  I set MAX_SEND_WC to 100, then called each loop 10,000,000 times.  The results showed that the bottom loop was barely faster most of the time.  Sometimes the first loop ended up faster, but overall loop 2 won.

It wasn't a great test, since I had a bunch of junk running on my system, but it seemed good enough to me that this is worthwhile.  Though I agree with Tzachi that we should eventually just move to using arrays.  This is already there in user space.

- Sean



More information about the ofw mailing list