Messages in this thread | | | Subject | Re: [PATCH] lib/int_sqrt.c: Optimize square root function | From | Davidlohr Bueso <> | Date | Mon, 02 Feb 2015 20:47:23 -0800 |
| |
On Mon, 2015-02-02 at 11:00 -0800, Linus Torvalds wrote: > Hmm. I don't disagree, but would like some more feedback. > > Davidlohr - you were the person to touch this function last (commit > 30493cc9dddb: "lib/int_sqrt.c: optimize square root algorithm"), and > you did so for performance reasons. And in fact, when you did that, > you removed that initial loop: > > - one = 1UL << (BITS_PER_LONG - 2); > - while (one > op) > - one >>= 2; > > but I'm not sure that was actually all that conscious, I think the > real optimization was the changes inside the loop to make the final > real loop faster and simpler.
I missed that. And yes, the real optimization should be in the loop.
> > Also, you had performance numbers, so presumably a test harness for it > all. It probably depends a lot on the actual distribution of argument > values, of course, but it would be good to accompany the patch with > actual real numbers like lasty time.
Aha. In my case I recall I ran a usersapce program using each function from 1 to a million, and throwing perf at it for 10 times.
> (I'm also not entirely sure what uses int_sqrt() that ends up being so > performance-critical, so it would be good to document that too, since > that probably also matters for the "what's the normal argument range" > question..)
It's not a big deal afaik.
Thanks, Davidlohr
| |