bug-gperf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gperf] large lengths


From: Bruno Haible
Subject: Re: [bug-gperf] large lengths
Date: Thu, 05 Sep 2019 02:05:59 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-159-generic; KDE/5.18.0; x86_64; ; )

Hello Mark,

> THIRD SUGGESTION ( EASY )
> 
>  The short version: when len is too large, use the value of len in the 
> function
> "hash" to avoid accessing the array.

What would be the point? The function 'hash' is only used by the
generated function 'in_word_set', which already contains a shortcut
test for len > MAX_WORD_LENGTH.

>   An if statement uses far fewer CPU cycles than loading a cache
> line (which is usually a 64 byte chunk of memory) into the CPU.

On the other hand, a conditional jump ('if') also takes a long time,
because today's CPUs have a long pipeline of prepared instructions.
A mis-predicted conditional jump effectively empties the pipeline.

Bruno




reply via email to

[Prev in Thread] Current Thread [Next in Thread]