Messages in this thread | | | Date | Mon, 2 Feb 2015 11:39:19 -0800 | Subject | Re: [PATCH] lib/int_sqrt.c: Optimize square root function | From | Linus Torvalds <> |
| |
On Mon, Feb 2, 2015 at 11:10 AM, Joe Perches <joe@perches.com> wrote: > > Perhaps removing the while and using fls(x) would be better.
No. fls is often slow, and you then do have to also round it down to an even bit number etc, so it gets somewhat complex too.
We *probably* have some argument range that we care more about, which is why I'd like to know what the profile is that triggered this optimization, and what the common argument range is.
For example, one user is the cpu frequency governor, which seems to try to predict the length of the next sleep. The values can probably be anything (it has protections for overflowing into "long long"), but presumably the onyl time we care about performance is when it's called very very often, in which case I'm going out on a limb and saying that the intervals will be short, and the standard deviation of those intervals will also be small. So *maybe* that function really only cares about performance when we have small arguments. I dunno.
Linus
| |