public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: "Amker.Cheng" <amker.cheng@gmail.com>
Cc: Andi Kleen <ak@linux.intel.com>,
	bin.cheng@linux.alibaba.com,
		GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH AutoFDO]Restoring indirect call value profile transformation
Date: Wed, 19 Dec 2018 09:36:00 -0000	[thread overview]
Message-ID: <CAFiYyc22ApfZ5Wvk6U2+rAP6a0WhvioWaSg9PvbA=tJLfCLwpQ@mail.gmail.com> (raw)
In-Reply-To: <CAHFci2_7Nh=ZrHLpT4KpBHdN-HQL+uD9XzjPWkCO4D4JrjwXNA@mail.gmail.com>

On Wed, Dec 19, 2018 at 5:08 AM Bin.Cheng <amker.cheng@gmail.com> wrote:
>
> On Wed, Dec 19, 2018 at 12:00 PM Andi Kleen <ak@linux.intel.com> wrote:
> >
> > On Wed, Dec 19, 2018 at 10:01:15AM +0800, Bin.Cheng wrote:
> > > On Tue, Dec 18, 2018 at 7:15 PM Bin.Cheng <amker.cheng@gmail.com> wrote:
> > > >
> > > > On Sun, Dec 16, 2018 at 9:11 AM Andi Kleen <ak@linux.intel.com> wrote:
> > > > >
> > > > > "bin.cheng" <bin.cheng@linux.alibaba.com> writes:
> > > > >
> > > > > > Hi,
> > > > > >
> > > > > > Due to ICE and mal-functional bugs, indirect call value profile transformation
> > > > > > is disabled on GCC-7/8/trunk.  This patch restores the transformation.  The
> > > > > > main issue is AutoFDO should store cgraph_node's profile_id of callee func in
> > > > > > the first histogram value's counter, rather than pointer to callee's name string
> > > > > > as it is now.
> > > > > > With the patch, some "Indirect call -> direct call" tests pass with autofdo, while
> > > > > > others are unstable.  I think the instability is caused by poor perf data collected
> > > > > > during regrets run, and can confirm these tests pass if good perf data could be
> > > > > > collected in manual experiments.
> > > > >
> > > > > Would be good to make the tests stable, otherwise we'll just have
> > > > > regressions in the future again.
> > > > >
> > > > > The problem is that the tests don't run long enough and don't get enough samples?
> > > > Yes, take g++.dg/tree-prof/morefunc.C as an example:
> > > > -  int i;
> > > > -  for (i = 0; i < 1000; i++)
> > > > +  int i, j;
> > > > +  for (i = 0; i < 1000000; i++)
> > > > +    for (j = 0; j < 50; j++)
> > > >       g += tc->foo();
> > > >     if (g<100) g++;
> > > >  }
> > > > @@ -27,8 +28,9 @@ void test1 (A *tc)
> > > >  static __attribute__((always_inline))
> > > >  void test2 (B *tc)
> > > >  {
> > > > -  int i;
> > > > +  int i, j;
> > > >    for (i = 0; i < 1000000; i++)
> > > > +    for (j = 0; j < 50; j++)
> > > >
> > > > I have to increase loop count like this to get stable pass on my
> > > > machine.  The original count (1000) is too small to be sampled.
> > > >
> > > > >
> > > > > Could add some loop?
> > > > > Or possibly increase the sampling frequency in perf (-F or -c)?
> > > > Maybe, I will have a try.
> > > Turned out all "Indirect call" test can be resolved by adding -c 100
> > > to perf command line:
> > > diff --git a/gcc/config/i386/gcc-auto-profile b/gcc/config/i386/gcc-auto-profile
> > > ...
> > > -exec perf record -e $E -b "$@"
> > > +exec perf record -e $E -c 100 -b "$@"
> > >
> > > Is 100 too small here?  Or is it fine for all scenarios?
> >
> > -c 100 is risky because it can cause perf throttling, which
> > makes it lose data.
> Right, it looks suspicious to me too.
>
> >
> > perf has a limiter that if the PMU handler uses too much CPU
> > time it stops measuring for some time. A PMI is 10k+ cycles,
> > so doing one every 100 branches is a lot of CPU time.
> >
> > I wouldn't go down that low. It is better to increase the
> > iteration count.
> We can combine the two together, increasing iteration count and
> decreasing perf count at the same time.  What count would you suggest
> from your experience?

Can we instead for the tests where we want to test profile use/merge
elide the profiling step and supply the "raw" data in an testsuite alternate
file instead?

Richard.

> Thanks,
> bin
> >
> > -Andi

  reply	other threads:[~2018-12-19  9:36 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-13  3:51 bin.cheng
2018-12-13 18:48 ` Jeff Law
2018-12-16  1:11 ` Andi Kleen
2018-12-18 11:16   ` Bin.Cheng
2018-12-18 21:27     ` Andi Kleen
2018-12-19  1:27       ` Bin.Cheng
2018-12-19  3:58         ` Andi Kleen
2018-12-21 22:13       ` Hans-Peter Nilsson
2018-12-19  2:01     ` Bin.Cheng
2018-12-19  4:00       ` Andi Kleen
2018-12-19  4:08         ` Bin.Cheng
2018-12-19  9:36           ` Richard Biener [this message]
2018-12-19 15:41             ` Andi Kleen
2018-12-19 17:28               ` Richard Biener
2018-12-19 17:43                 ` Andi Kleen
2018-12-19 17:11           ` Andi Kleen
2019-01-14  8:07     ` Andi Kleen
2019-01-14  8:15       ` Bin.Cheng
2019-01-14 17:10         ` Andi Kleen
2019-02-01  4:12           ` Bin.Cheng

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='CAFiYyc22ApfZ5Wvk6U2+rAP6a0WhvioWaSg9PvbA=tJLfCLwpQ@mail.gmail.com' \
    --to=richard.guenther@gmail.com \
    --cc=ak@linux.intel.com \
    --cc=amker.cheng@gmail.com \
    --cc=bin.cheng@linux.alibaba.com \
    --cc=gcc-patches@gcc.gnu.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).