From: Richard Biener <richard.guenther@gmail.com>
To: "Yuan, Pengfei" <ypf@pku.edu.cn>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>, Jan Hubicka <hubicka@ucw.cz>
Subject: Re: [PATCH, 5.x/6.x/7.x] Be more conservative in early inliner if FDO is enabled
Date: Wed, 14 Sep 2016 10:35:00 -0000 [thread overview]
Message-ID: <CAFiYyc3MwD3B+B4rpgRzVejVMEuCQtUV9m2fBM92LPegJU+6mg@mail.gmail.com> (raw)
In-Reply-To: <58f49a76.4c20.15712b20e40.Coremail.ypf@pku.edu.cn>
On Sat, Sep 10, 2016 at 8:04 AM, Yuan, Pengfei <ypf@pku.edu.cn> wrote:
> Hi,
>
> Previously I have sent a patch on profile based option tuning:
> https://gcc.gnu.org/ml/gcc-patches/2014-07/msg01377.html
>
> According to Richard Biener's advice, I try investigating where the code size
> reduction comes from. After analyzing the dumped IL, I figure out that it is
> related to function inlining. Some cold functions are inlined regardless of
> profile feedback, which increases code size.
>
> The problem is with the early inliner. In want_early_inline_function_p, if the
> estimated edge growth > 0, want_inline depends on maybe_hot_p, which usually
> returns true unless optimize_size, since profile feedback is not available at
> this point. Some functions which may be cold according to profile feedback are
> inlined regardlessly, resulting in code size increase.
>
> At first, I come up with a solution that preloads some profile info before
> pass_early_inline. But it fails with numerous coverage-mismatch errors in
> pass_ipa_tree_profile. Therefore, the proposed patch prevents early inlining
> with positive code size growth if FDO is enabled.
>
> Experiment results are as follows:
>
> Setup
> Hardware Core i7-4770, 32GB RAM
> OS Debian sid amd64
> Compiler GCC 5.4.1 20160907
> Firefox source mozilla-central, cset 91c2b9d5c135
> Training workload css3test.com, html5test.com, Octane benchmark
>
> Vanilla GCC
> Code size (.text of libxul.so) 48708873
> Octane benchmark (score) 35828 36618 35847
> Kraken benchmark (time) 939.4ms 964.0ms 951.8ms
>
> Patched GCC
> Code size (.text of libxul.so) 44686265
> Octane benchmark (score) 36103 35740 35611
> Kraken benchmark (time) 928.9ms 949.1ms 938.7ms
>
> There is over 8% reduction in code size, while no obvious difference in
> performance. The experiment is conducted with GCC 5. There is segmentation
> fault when starting Firefox instrumented by GCC 6. GCC 7 encounters ICE when
> building Firefox.
I think the approach is reasonable though it might still have
interesting effects on
optimization for very small growth. So for further experimenting it
would be nice
to have a separate PARAM_EARLY_FDO_INLINING_INSNS or maybe simply
adjust the PARAM_EARLY_INLINING_INSNS default accordingly when FDO is
enabled?
I'll let Honza also double-check the condition detecting FDO (it looks
like we should
have some abstraction for that).
Thanks,
Richard.
> Regards,
>
> Yuan, Pengfei
>
>
> gcc/ChangeLog:
> * ipa-inline.c (want_early_inline_function_p): Be more conservative
> if FDO is enabled.
>
>
> diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c
> index 7097cf3..8266f97 100644
> --- a/gcc/ipa-inline.c
> +++ b/gcc/ipa-inline.c
> @@ -628,6 +628,20 @@ want_early_inline_function_p (struct cgraph_edge *e)
>
> if (growth <= 0)
> ;
> + /* Profile feedback is not available at this point.
> + Be more conservative if FDO is enabled. */
> + else if ((profile_arc_flag && !flag_test_coverage)
> + || (flag_branch_probabilities && !flag_auto_profile))
> + {
> + if (dump_file)
> + fprintf (dump_file, " will not early inline: %s/%i->%s/%i, "
> + "FDO is enabled and code would grow by %i\n",
> + xstrdup_for_dump (e->caller->name ()),
> + e->caller->order,
> + xstrdup_for_dump (callee->name ()), callee->order,
> + growth);
> + want_inline = false;
> + }
> else if (!e->maybe_hot_p ()
> && growth > 0)
> {
>
next prev parent reply other threads:[~2016-09-14 10:24 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-10 6:41 Yuan, Pengfei
2016-09-14 10:35 ` Richard Biener [this message]
2016-09-15 3:17 ` Yuan, Pengfei
2016-09-15 8:44 ` Richard Biener
2016-09-15 10:08 ` Yuan, Pengfei
2016-09-16 5:52 ` Yuan, Pengfei
2016-09-16 8:09 ` Jan Hubicka
2016-09-16 9:01 ` Yuan, Pengfei
2016-09-16 9:21 ` Richard Biener
2016-09-16 9:37 ` Jan Hubicka
2016-09-16 12:00 ` Yuan, Pengfei
2016-09-16 12:56 ` Jan Hubicka
2016-09-20 8:53 ` Yuan, Pengfei
2016-09-20 11:44 ` Richard Biener
2016-09-20 11:58 ` Richard Biener
2016-09-20 12:09 ` Yuan, Pengfei
2016-09-20 12:19 ` Richard Biener
2016-09-20 13:10 ` Yuan, Pengfei
2016-09-21 12:44 ` Yuan, Pengfei
2016-09-26 4:03 ` Yuan, Pengfei
2016-10-10 2:23 ` PING: [PATCH] " Yuan, Pengfei
2016-10-10 9:55 ` Richard Biener
2016-10-10 10:52 ` Yuan, Pengfei
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=CAFiYyc3MwD3B+B4rpgRzVejVMEuCQtUV9m2fBM92LPegJU+6mg@mail.gmail.com \
--to=richard.guenther@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=hubicka@ucw.cz \
--cc=ypf@pku.edu.cn \
/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).