From patchwork Fri Nov 23 14:13:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 201328 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id CE6FA2C0081 for ; Sat, 24 Nov 2012 01:14:15 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1354284856; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Date: From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To:User-Agent: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=y19rDJxAFabcxcxfJKgC vg2fp/U=; b=ubwahlTsqPktjMxPJ77ApCysH9ktgHjpVrjlwDz8a97vNQHNlq5r NKKkhV9LrLxWeTUWLrVQDzO0vEInGKCq2UdFyJMUitsnwpPJh2pY3358lCmR8clZ pAlQsJGsvQ7tpUT0N6XzDPUKbj6uUMmg6FPahQeoSAXsnBFW9xRpAOE= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Date:From:To:Cc:Subject:Message-ID:References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To:User-Agent:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=sXNooX/HIZe23MoZQdXjVEHSD1zXBOSFRtYkBiQ53x8pP60ooOlug9eZZEyCFL KFx3XxgDShjifIXLqWLVDQM0kTFJ3E9NJ+F/TZZjeC6GBvOXslcQDKNTVbyjtAwj LYU6jc9amt3bguk/UMuCj03Tf/pn4GtkmV4vDXSTZ5c80=; Received: (qmail 21914 invoked by alias); 23 Nov 2012 14:13:33 -0000 Received: (qmail 21822 invoked by uid 22791); 23 Nov 2012 14:13:29 -0000 X-SWARE-Spam-Status: No, hits=-4.1 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 23 Nov 2012 14:13:02 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id C04895440F6; Fri, 23 Nov 2012 15:13:00 +0100 (CET) Date: Fri, 23 Nov 2012 15:13:00 +0100 From: Jan Hubicka To: Teresa Johnson , gcc-patches@gcc.gnu.org Cc: Jan Hubicka Subject: Re: [PATCH] Use working set profile info to determine hotness (issue6852069) Message-ID: <20121123141300.GA14227@kam.mff.cuni.cz> References: <20121119224351.C9D2161425@tjsboxrox.mtv.corp.google.com> <20121121124730.GA18509@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org > Sounds good. I am travelling the rest of the week so I'll get the revised > patch ready by Mon. Thanks, Teresa Hi, I updated the patch, so we make progress on the heuristic retunning. There was a segfault during profiledbootstrap trying to fetch DECL_STRUCT_FUNCTION of calle of indirect call and I renamed percents to permilles since they are in 0...1000 range. Bootstrapped/regtested x86_64-linux, comitted. Honza 2012-11-19 Teresa Johnson Jan Hubicka * predict.c (maybe_hot_count_p): Use threshold from profiled working set instead of hard limit. (cgraph_maybe_hot_edge_p): Invoke maybe_hot_count_p() instead of directly checking limit. * params.def (HOT_BB_COUNT_FRACTION): Remove. (HOT_BB_COUNT_WS_PERMILLE): New parameter. * invoke.texi (hot-bb-count-fraction): Remove. (hot-bb-count-ws-permille): Document. Index: predict.c =================================================================== --- predict.c (revision 193696) +++ predict.c (working copy) @@ -134,13 +134,20 @@ maybe_hot_frequency_p (struct function * static inline bool maybe_hot_count_p (struct function *fun, gcov_type count) { - if (profile_status_for_function (fun) != PROFILE_READ) + gcov_working_set_t *ws; + static gcov_type min_count = -1; + if (fun && profile_status_for_function (fun) != PROFILE_READ) return true; /* Code executed at most once is not hot. */ if (profile_info->runs >= count) return false; - return (count - > profile_info->sum_max / PARAM_VALUE (HOT_BB_COUNT_FRACTION)); + if (min_count == -1) + { + ws = find_working_set (PARAM_VALUE (HOT_BB_COUNT_WS_PERMILLE)); + gcc_assert (ws); + min_count = ws->min_counter; + } + return (count >= min_count); } /* Return true in case BB can be CPU intensive and should be optimized @@ -161,8 +168,8 @@ bool cgraph_maybe_hot_edge_p (struct cgraph_edge *edge) { if (profile_info && flag_branch_probabilities - && (edge->count - <= profile_info->sum_max / PARAM_VALUE (HOT_BB_COUNT_FRACTION))) + && !maybe_hot_count_p (NULL, + edge->count)) return false; if (edge->caller->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED || (edge->callee Index: params.def =================================================================== --- params.def (revision 193696) +++ params.def (working copy) @@ -365,10 +365,11 @@ DEFPARAM(PARAM_SMS_LOOP_AVERAGE_COUNT_TH "A threshold on the average loop count considered by the swing modulo scheduler", 0, 0, 0) -DEFPARAM(HOT_BB_COUNT_FRACTION, - "hot-bb-count-fraction", - "Select fraction of the maximal count of repetitions of basic block in program given basic block needs to have to be considered hot", - 10000, 0, 0) +DEFPARAM(HOT_BB_COUNT_WS_PERMILLE, + "hot-bb-count-ws-permille", + "A basic block profile count is considered hot if it contributes to " + "the given permillage of the entire profiled execution", + 999, 0, 1000) DEFPARAM(HOT_BB_FREQUENCY_FRACTION, "hot-bb-frequency-fraction", "Select fraction of the maximal frequency of executions of basic block in function given basic block needs to have to be considered hot", @@ -392,7 +393,7 @@ DEFPARAM (PARAM_ALIGN_LOOP_ITERATIONS, flatten the profile. We need to cut the maximal predicted iterations to large enough iterations - so the loop appears important, but safely within HOT_BB_COUNT_FRACTION + so the loop appears important, but safely within maximum hotness range. */ DEFPARAM(PARAM_MAX_PREDICTED_ITERATIONS, Index: doc/invoke.texi =================================================================== --- doc/invoke.texi (revision 193696) +++ doc/invoke.texi (working copy) @@ -9216,9 +9216,9 @@ doing loop versioning for alias in the v The maximum number of iterations of a loop the brute-force algorithm for analysis of the number of iterations of the loop tries to evaluate. -@item hot-bb-count-fraction -Select fraction of the maximal count of repetitions of basic block in program -given basic block needs to have to be considered hot. +@item hot-bb-count-ws-permille +A basic block profile count is considered hot if it contributes to +the given permillage (i.e. 0...1000) of the entire profiled execution. @item hot-bb-frequency-fraction Select fraction of the entry block frequency of executions of basic block in