mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Andi Kleen <andi@firstfloor.org>, akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, davidlohr.bueso@hp.com,
	rafael.j.wysocki@intel.com, lenb@kernel.org,
	Andi Kleen <ak@linux.intel.com>,
	"anshul.g" <anshul.g@samsung.com>
Subject: Re: [PATCH] Optimize int_sqrt for small values for faster idle
Date: Thu, 28 Jan 2016 14:15:44 -0800	[thread overview]
Message-ID: <1454019344.10099.54.camel@perches.com> (raw)
In-Reply-To: <1454017365-8509-1-git-send-email-andi@firstfloor.org>

(adding Anshul Garg)

On Thu, 2016-01-28 at 13:42 -0800, Andi Kleen wrote:
> From: Andi Kleen <ak@linux.intel.com>
> 
> The menu cpuidle governor does at least two int_sqrt() each time
> we go into idle in get_typical_interval to compute stddev
> 
> int_sqrts take 100-120 cycles each. Short idle latency is important
> for many workloads.
> 
> I instrumented the function on my workstation and most values are
> 16bit only and most others 32bit (50% percentile is 122094,
> 75% is 3699533).
> 
> sqrt is implemented by starting with an initial estimation,
> and then iterating. int_sqrt currently only uses a fixed
> estimating which is good for 64bits worth of input.
> 
> This patch adds some checks at the beginning to start with
> a better estimate for values fitting in 8, 16bit and 32bit.
> This makes int_sqrt between 60+% faster for values in 16bit,
> and still somewhat faster (between 10 and 30%) for larger values
> upto 32bit. Full 64bit is slightly slower.
> 
> This optimizes the short idle calls and does not hurt the
> long sleep (which probably do not care) much.
> 
> An alternative would be a full table drive approach, or
> trying some inverted sqrt optimization, but this simple change
> already seems to have a good payoff.

This thread might be relevant:

https://lkml.org/lkml/2015/2/2/600

and perhaps using fls might still be a good approach.

  parent reply	other threads:[~2016-01-28 22:15 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-28 21:42 Andi Kleen
2016-01-28 22:04 ` kbuild test robot
2016-01-28 22:11 ` kbuild test robot
2016-01-28 22:15 ` Joe Perches [this message]
2016-01-28 22:40   ` Andi Kleen
2016-01-28 22:22 ` Joe Perches
2016-01-28 22:29 ` Eric Dumazet
2016-01-28 22:30 ` Andi Kleen
2016-01-29  3:59 ` Rafael J. Wysocki
2016-01-31  7:27 ` Thomas Rohwer
2016-02-01 21:25 ` Rasmus Villemoes
2016-02-01 21:36   ` Andi Kleen
2016-02-01 23:08     ` Rasmus Villemoes
2016-02-02  0:00       ` Andi Kleen
2016-02-02  0:36       ` Eric Dumazet
2016-02-02 20:46         ` Rasmus Villemoes
2016-02-02 21:30           ` Eric Dumazet
2017-07-20 10:10         ` Peter Zijlstra
2017-07-24 13:28           ` Eric Dumazet
2016-02-07 21:32     ` Rasmus Villemoes
2016-02-09 20:44       ` Andi Kleen
2016-02-10 13:31         ` Fengguang Wu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1454019344.10099.54.camel@perches.com \
    --to=joe@perches.com \
    --cc=ak@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=andi@firstfloor.org \
    --cc=anshul.g@samsung.com \
    --cc=davidlohr.bueso@hp.com \
    --cc=lenb@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome