From patchwork Mon Nov 19 22:43:51 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Teresa Johnson X-Patchwork-Id: 200209 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 0B0ED2C0079 for ; Tue, 20 Nov 2012 09:44:13 +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=1353969854; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Received:To:Subject:Message-Id:Date:From: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=1Tvl/xEpHddl3c2L1v4m 0Fgc11Q=; b=wjrT9hf4M301PvW3LB7UtUC9hBI2bwD1u9Wa+/2D3HNLKgZ1h5e9 vf6ZW5e+zJSEwdbWYg/rEn+dQvGWOZm8AmCiEXDDY1gHOYOYmlcwT3VNkRZwAiZ0 Gzy4tNUg0vE7wKgNN4U3Eb8IOKb03uZNHF1akUYOrKB7Qx3j79c8JQg= 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:X-Google-DKIM-Signature:Received:Received:Received:Received:To:Subject:Message-Id:Date:From:X-Gm-Message-State:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=yYZRuVILJuvDLJVnL7fEW2gZ0hpGD1NRYaPZKRUFY3GX+WPqMLmmRWiXdHYhm9 +MKiQ7Aq50aeMRn27KIPhjsZYsQ8OcejwlaVPL7j58bcRQzkLTLDuPgmWT63X/My N9uSUJdtAUmFvUrNm8f4LAdU1iHum7/tnzZchzGYJ+4xQ=; Received: (qmail 4862 invoked by alias); 19 Nov 2012 22:44:00 -0000 Received: (qmail 4779 invoked by uid 22791); 19 Nov 2012 22:43:58 -0000 X-SWARE-Spam-Status: No, hits=-4.7 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-wi0-f201.google.com (HELO mail-wi0-f201.google.com) (209.85.212.201) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 19 Nov 2012 22:43:54 +0000 Received: by mail-wi0-f201.google.com with SMTP id hm2so27577wib.2 for ; Mon, 19 Nov 2012 14:43:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=to:subject:message-id:date:from:x-gm-message-state; bh=+E3n8S0WwZncXSFnAkyruPdoprL2ZUw/PbpgGIgPuDw=; b=Ogn47HLzrx6xuHKCTo5pHod8AF3ideA4PqSmQ4FkWstiRJ8H2xIynBjHmnqTYoaljM Wi0XSuEDMhNHRfwMkjZa/26ydwh4Xj5xe2/5sL7RSg20VKmMOgXoEs6qvTVTBGSk0XwW +CCKst/AMrIZNCbHxNl5S8mvc0xw6WbFyhgaBzQwWGiWzqvNLswR96fLm2MGmoNYUOE+ 2CMTeJ2XDq2Rp/2Jq3lkffTExElHqozwZZBc4GDgrM9FOVd+9iZh3IPaIgy2yZdQYj3x aG8tMP4UEs+1O/H5tPj6RWEF1XoKrLf5XNTSN/RF+0Ll1g/YfbPugZpm21HQ8zmHtrAO TyxQ== Received: by 10.14.204.3 with SMTP id g3mr9029613eeo.7.1353365033045; Mon, 19 Nov 2012 14:43:53 -0800 (PST) Received: from hpza10.eem.corp.google.com ([74.125.121.33]) by gmr-mx.google.com with ESMTPS id u8si2779376een.1.2012.11.19.14.43.52 (version=TLSv1/SSLv3 cipher=AES128-SHA); Mon, 19 Nov 2012 14:43:53 -0800 (PST) Received: from tjsboxrox.mtv.corp.google.com (tjsboxrox.mtv.corp.google.com [172.17.129.49]) by hpza10.eem.corp.google.com (Postfix) with ESMTP id 9C2DF200059; Mon, 19 Nov 2012 14:43:52 -0800 (PST) Received: by tjsboxrox.mtv.corp.google.com (Postfix, from userid 147431) id C9D2161425; Mon, 19 Nov 2012 14:43:51 -0800 (PST) To: reply@codereview.appspotmail.com,hubicka@ucw.cz,gcc-patches@gcc.gnu.org Subject: [PATCH] Use working set profile info to determine hotness (issue6852069) Message-Id: <20121119224351.C9D2161425@tjsboxrox.mtv.corp.google.com> Date: Mon, 19 Nov 2012 14:43:51 -0800 (PST) From: tejohnson@google.com (Teresa Johnson) X-Gm-Message-State: ALoCoQn3SxjLRHXOxCqrIGsPn0v+78sq47d/M6F31W7KxfTOEyGlyjA0b4hhz8JpsXSFE46tuYycS7jKF4z/OsGbADjCf79hwWbw5vJllCc9F59tH9FWvg89kiYj7XAqrLDHVIHwHp4Tygrl8b/KhXSkgGfJqraIPfDgtO5cpSJ1boiv7AA6okcMh/sZHn/TNWkJna+7RIKO X-IsSubscribed: yes 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 This patch uses the new working set information from the profile to select the hot count threshold for an application instead of using a hard cutoff. Currently the threshold is set by default to the minimum counter value needed to reach 99.9% of the profiled execution time, but I have added a parameter to control this. I saw a couple improvements in SPEC2006 on a Westmere, such as xalancbmk by a few percent. Bootstrapped and tested on x86_64-unknown-linux-gnu. Ok for trunk? Thanks, Teresa 2012-11-19 Teresa Johnson * 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_PERCENT): New parameter. --- This patch is available for review at http://codereview.appspot.com/6852069 Index: predict.c =================================================================== --- predict.c (revision 193614) +++ predict.c (working copy) @@ -134,13 +134,15 @@ maybe_hot_frequency_p (struct function *fun, int f static inline bool maybe_hot_count_p (struct function *fun, gcov_type count) { + gcov_working_set_t *ws; if (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)); + ws = find_working_set (PARAM_VALUE (HOT_BB_COUNT_WS_PERCENT)); + gcc_assert (ws); + return (count >= ws->min_counter); } /* Return true in case BB can be CPU intensive and should be optimized @@ -161,8 +163,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 (DECL_STRUCT_FUNCTION (edge->caller->symbol.decl), + edge->count)) return false; if (edge->caller->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED || (edge->callee Index: params.def =================================================================== --- params.def (revision 193614) +++ params.def (working copy) @@ -365,10 +365,11 @@ DEFPARAM(PARAM_SMS_LOOP_AVERAGE_COUNT_THRESHOLD, "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_PERCENT, + "hot-bb-count-ws-percent", + "A basic block profile count is considered hot if it contributes to " + "the given percentage (times ten) 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,