From owner-svn-src-projects@FreeBSD.ORG Tue Feb 26 15:57:54 2013 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 75ABD39E; Tue, 26 Feb 2013 15:57:54 +0000 (UTC) (envelope-from mavbsd@gmail.com) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com [209.85.217.182]) by mx1.freebsd.org (Postfix) with ESMTP id 95F07C21; Tue, 26 Feb 2013 15:57:53 +0000 (UTC) Received: by mail-lb0-f182.google.com with SMTP id gg6so3257727lbb.27 for ; Tue, 26 Feb 2013 07:57:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=1nJfq/Z0yDnlNLcl0C0RSFNMkAUGos7OHPbToH+THLI=; b=GEWDI9osCuI6phxtmK+qjNqB3eP3CuQcpjqW/Qly3YPjz/zUxRHKzKP5A1KV2VBfOS aRlWmcgGMkfIyPxTptvQTUG/lOWZqnxxtVuTjN5AA6TXERXsQxJX/LTuJmWR2T6+cjYn xoBJEwJfIwDBPN7nkdaJQYialbW5mzZufBEGi1p9akCgb7eG21v+hd0sfnx1+326tmd5 bKaW0MfK5j+zTaqogo87ZK20LFA4IBl+ekZazVwcsn29LO/wu35cUGE8pgvICOyC1icZ wUZ95Bc0vtFqO7AmHknx6hPVaP4nE+97R0NnRTjGQ1Ri4KfhB3B2nwHuNAZ5O4Xk5NuN OOQQ== X-Received: by 10.112.101.130 with SMTP id fg2mr769515lbb.64.1361894272147; Tue, 26 Feb 2013 07:57:52 -0800 (PST) Received: from mavbook.mavhome.dp.ua (mavhome.mavhome.dp.ua. [213.227.240.37]) by mx.google.com with ESMTPS id hk10sm882507lab.4.2013.02.26.07.57.50 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 26 Feb 2013 07:57:51 -0800 (PST) Sender: Alexander Motin Message-ID: <512CDB7C.5050905@FreeBSD.org> Date: Tue, 26 Feb 2013 17:57:48 +0200 From: Alexander Motin User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:17.0) Gecko/20130125 Thunderbird/17.0.2 MIME-Version: 1.0 To: attilio@FreeBSD.org Subject: Re: svn commit: r247319 - in projects/calloutng/sys: kern sys References: <201302261525.r1QFPhLt058080@svn.freebsd.org> <512CD8D7.60306@FreeBSD.org> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: svn-src-projects@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Feb 2013 15:57:54 -0000 On 26.02.2013 17:49, Attilio Rao wrote: > On Tue, Feb 26, 2013 at 4:46 PM, Alexander Motin wrote: >> On 26.02.2013 17:28, Attilio Rao wrote: >>> On Tue, Feb 26, 2013 at 4:25 PM, Alexander Motin wrote: >>>> Author: mav >>>> Date: Tue Feb 26 15:25:43 2013 >>>> New Revision: 247319 >>>> URL: http://svnweb.freebsd.org/changeset/base/247319 >>>> >>>> Log: >>>> Optimize callout_process() to use less variables and less conditions to >>>> implement the same logic. Now it fits better into CPU registers, and >>>> according to PMC significntly reduces number of resource stalls, reducing >>>> consumed by it CPU time during usleep(1) benchmark by 30%. >>> >>> Is that all improved i-cache capacity and improved dynamic branch >>> prediction (hwpmc has counters for both FWIW)? >> >> I-cache capacity I think is not significant there as the loop is quite >> small. I believe it was branch misprediction, complicated by additional >> latency of memory accesses. I haven't analyzed cause deeper, as PMC man >> pages are not the most informative and easiest reading. > > Well, I-cache is really very small, so I think you may get some > improvement also for the function you were trying to optimize. > You can get all the counter description by doing: pmccontrol -L > From there you may find some hwpmc counter showing i-cache and dynamic > branch prediction misses statistics. I've noticed that even without any branching changes removal of one variable, allowing compiler to reuse the register (checked in assembler sources), gave measurable result. I think it would not happen if the cause was on instruction fetching side. But sure, I'll continue experiments with HWPMC. -- Alexander Motin