Re: [PATCH] fragment: add fast path

Changli Gao
2010-06-14T10:15:50Z

On Mon, Jun 14, 2010 at 3:04 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
>
>
> Concept of 'fast path' has changed over years. It used to be cpu
> instructions and cycles, its now number of memory transactions.
>
> The only thing we need to address are the cache lines we must bring into
> cpu caches, and keep code short.
>
> These days, one cache line miss -> more than one hundred instructions
> that could be done during cpu stall. cpu cycles are cheap if code
> already in instruction cache.
>
> Adding a test to avoid entering a NULL loop (no fragment is stored yet)
> just bloats the code, making it larger than necessary.
>
> You dont need the else branch :
>
> if (prev) {
>        if (FRAG_CB(prev)->offset < offset) {
>                next = NULL;
>                goto found;
>        }
> else {
>        next = NULL;
>        goto found;
> }
>
> Just write :
>
> next = NULL;
> if (prev && FRAG_CB(prev)->offset < offset)
>        goto found;
>

Thanks:

I think the following code is better:

if (!prev || FRAG_CB(prev)->offset < offset) {
next = NULL;
goto found;
}

--
Regards,
Changli Gao(xiaosuo@gmail.com)