From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 122249 invoked by alias); 16 Sep 2016 05:10:17 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 122225 invoked by uid 89); 16 Sep 2016 05:10:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=H*UA:Coremail, H*x:Coremail, 1.00, 007 X-HELO: pku.edu.cn Received: from mx9.pku.edu.cn (HELO pku.edu.cn) (162.105.129.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 16 Sep 2016 05:10:13 +0000 Received: by ajax-webmail-mailfront01 (Coremail) ; Fri, 16 Sep 2016 13:10:02 +0800 (GMT+08:00) Date: Fri, 16 Sep 2016 05:52:00 -0000 X-CM-HeaderCharset: UTF-8 From: "Yuan, Pengfei" To: "Richard Biener" Cc: "GCC Patches" , "Jan Hubicka" Subject: Re: [PATCH, 5.x/6.x/7.x] Be more conservative in early inliner if FDO is enabled In-Reply-To: References: <58f49a76.4c20.15712b20e40.Coremail.ypf@pku.edu.cn> <392727ce.b9c7.1572b385ece.Coremail.ypf@pku.edu.cn> X-SendMailWithSms: false Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=UTF-8 MIME-Version: 1.0 Message-ID: <339617a6.8f06.1573166cbaf.Coremail.ypf@pku.edu.cn> X-Coremail-Locale: zh_CN X-CM-TRANSID:x4FpogD3VoiqfttXXEAgAA--.4668W X-CM-SenderInfo: yrsqiiarrtilo6sn3hxhgxhubq/1tbiAgAAD1Py7az5dwACsh X-Coremail-Antispam: 1Ur529EdanIXcx71UUUUU7IcSsGvfJ3iIAIbVAYjsxI4VWxJw CS07vEb4IE77IF4wCS07vE1I0E4x80FVAKz4kxMIAIbVAFxVCaYxvI4VCIwcAKzIAtYxBI daVFxhVjvjDU= X-SW-Source: 2016-09/txt/msg00991.txt.bz2 > > Setting PARAM_EARLY_INLINING_INSNS to 0 when FDO is enabled should be > > equivalent to my patch. > > Yes. This means it's easy to experiment with other values than zero. Basically > early inlining is supposed to remove abstraction penalty to > > a) reduce FDO instrumentation overhead > b) get more realistic size estimates for the inliner > > a) was particularly important back in time for tramp3d, reducing > profiling runtime > 1000-fold. b) is generally important. > > PARAM_EARLY_INLINING_INSNS is supposed to be a reasonable value to > get abstraction removed but IIRC we increased it quite a bit to also get more > early optimization (to get more accurate inliner estimates). > > What I am saying is that reducing PARAM_EARLY_INLINING_INSNS makes > sense for FDO but reducing it to zero is probably a bit much. > > Can you do your measurements with values between zero and the current > default of 14 (wow, 14 ... didn't know it's _that_ high currently ;)). > What's the > value that crosses the boundary of diminishing returns regarding to code-size > improvements for you? > > Richard. Here are the results: Param Size (GCC5) Time (GCC5) Time (GCC7) 0 44686265 (-8.26%) 58.772s 66.332s 1 45692793 (-6.19%) 40.684s 39.220s 2 45556185 (-6.47%) 35.292s 34.328s 3 46251049 (-5.05%) 28.820s 27.136s 4 47028873 (-3.45%) 24.616s 22.200s 5 47495641 (-2.49%) 20.160s 17.800s 6 47520153 (-2.44%) 16.444s 15.656s 14 48708873 5.620s 5.556s Param: value of PARAM_EARLY_INLINING_INSNS Size: code size (.text) of optimized libxul.so Time: execution time of instrumented tramp3d (-n 25) To balance between size reduction of optimized binary and speed penalty of instrumented binary, I set param=6 as baseline and compare: Param Size score Time score Total 0 3.39 -3.57 -0.18 1 2.54 -2.47 0.07 2 2.65 -2.15 0.50 3 2.07 -1.75 0.32 4 1.41 -1.50 -0.09 5 1.02 -1.23 -0.21 6 1.00 -1.00 0.00 14 0.00 -0.34 -0.34 Therefore, I think param=2 is the best choice. Is the attached patch OK? Regards, Yuan, Pengfei gcc/ChangeLog * opts.c (finish_options): Adjust PARAM_EARLY_INLINING_INSNS when FDO is enabled. diff --git a/gcc/opts.c b/gcc/opts.c index 39c190d..b59c700 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -826,8 +826,14 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set, maybe_set_param_value (PARAM_STACK_FRAME_GROWTH, 40, opts->x_param_values, opts_set->x_param_values); } + /* Adjust PARAM_EARLY_INLINING_INSNS when FDO is enabled. */ + if ((opts->x_profile_arc_flag && !opts->x_flag_test_coverage) + || (opts->x_flag_branch_probabilities && !opts->x_flag_auto_profile)) + maybe_set_param_value (PARAM_EARLY_INLINING_INSNS, 2, + opts->x_param_values, opts_set->x_param_values); + if (opts->x_flag_lto) { #ifdef ENABLE_LTO opts->x_flag_generate_lto = 1;