From owner-freebsd-hackers@FreeBSD.ORG Thu Apr 3 15:48:41 2014 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D5278A19; Thu, 3 Apr 2014 15:48:41 +0000 (UTC) Received: from mail.iXsystems.com (newknight.ixsystems.com [206.40.55.70]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id ACC54CC2; Thu, 3 Apr 2014 15:48:41 +0000 (UTC) Received: from localhost (mail.ixsystems.com [10.2.55.1]) by mail.iXsystems.com (Postfix) with ESMTP id 53F7D73C5C; Thu, 3 Apr 2014 08:48:40 -0700 (PDT) Received: from mail.iXsystems.com ([10.2.55.1]) by localhost (mail.ixsystems.com [10.2.55.1]) (maiad, port 10024) with ESMTP id 98736-04; Thu, 3 Apr 2014 08:48:40 -0700 (PDT) Received: from [192.168.3.178] (unknown [124.195.210.70]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mail.iXsystems.com (Postfix) with ESMTPSA id 3219773C55; Thu, 3 Apr 2014 08:48:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=ixsystems.com; s=newknight0; t=1396540120; bh=Wq/QfKojUaGI82sZwc3g4hzG3G+TIRmDphan79te8YY=; h=Subject:From:In-Reply-To:Date:Cc:References:To; b=kB7w8+0YnPOAvIAVRaNEpZpRQt7kcIy5Q3sLUKVkuwdfk1UQ72NeYHTCqrdv/ztDV HAmIb8XWSGUqo7N+XHD2uqHnhCO6KvsHQezWHgt4bWv2oq9Wwg4AG2/bzZjxH78DC9 uDD4Kuvzj6DZ0O4wo6ZQ7u7z+kIP8L9xVJvQWUG0= Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 7.2 \(1874\)) Subject: Re: Power Efficiency (was Re: Leaving the Desktop Market) From: Jordan Hubbard In-Reply-To: Date: Thu, 3 Apr 2014 20:48:17 +0500 Content-Transfer-Encoding: quoted-printable Message-Id: <7C720BEE-7440-4678-9322-988F68E6754F@ixsystems.com> References: <3F7430D7-3C0F-43E1-8EBD-8AA4F701497C@FreeBSD.org> <20140403034150.GA78653@regency.nsu.ru> <89A553DC-199A-47E3-B352-34A4CDCAC4E4@ixsystems.com> To: Alan Somers X-Mailer: Apple Mail (2.1874) Cc: Alexey Dokuchaev , "freebsd-hackers@freebsd.org" , David Chisnall , Eitan Adler X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Apr 2014 15:48:41 -0000 On Apr 3, 2014, at 7:50 PM, Alan Somers wrote: > Instead of reinventing the wheel, how about porting powertop to > FreeBSD? It's already got several output modes, and it's designed to > monitor the same kind of hardware that FreeBSD users have. The only > downside is that it relies on Linux's sysfs, and possibly some other > Linux-specific APIs as well. Still, I think it would be easier for us > to add a few sysctls and port powertop to use a sysctl interface than > it would be to rewrite everything from scratch. I don=92t think this is re-inventing the wheel as much as you might = think, and here=92s why: 1. A comprehensive monitoring framework, such as I described, does a lot = more than tell you that a device or a process is using X joules of = power. That kind of information just by itself is actually not = particularly useful, since it doesn=92t tell you where specifically in = the code that power is actually being consumed or what external events = to correlate against it (the code itself may be innocuous but only = become pathological in the presence of other factors). To use a microscope analogy, what powertop gives you is essentially the = lowest magnification factor. It=92s nice for the first level of =93hmmm, = that=92s weird!=94 deduction, but then you'll immediately want to =93zoom = in=94 and figure out what parts of the code are actually hot and/or what = kernel services are being called the most often by the offending process = or device driver, at which point you'll then want to zoom in again on = that part of the kernel to see what it=92s doing. That=92s why you really want to think of the telemetry problem from the = bottom up. A tool like top(1) (or Activity Monitor, if you want to get = all graphical about it) is, no pun intended, at the top of the stack. = It=92s where the highest level of summarization takes place, but all the = data it uses also needs to be readily available to the various analysis = tools which will actually ultimately lead you to one or more lines of = code that need changing, an exercise that often isn=92t as = straight-forward as looking at raw profiling counters but requires a = fair amount of cross-correlation between seemingly unrelated activities. 2. If you look at the powertop code (and I have - version 2.5 to be = specific) you=92ll quickly see that there=92s really not much there. = It=92s leveraging a lot of work that=92s already been done in the linux = kernel to provide the interrupt/timer/wakeup statistics and the = device-specific information, work which would all need to be = re-implimented (or impedance matched to powertop) in FreeBSD=92s own = kernel. The resulting powertop code base would bear so little = resemblance to the linux original you would have indeed reinvented the = wheel almost entirely at the end, and suffered the consequences of = starting with someone else=92s specs for a wheel rather than your own. In any case, even if powertop had already been ported to FreeBSD and was = running with full functionality, I would still want to start with a = thorough examination of the problem and what kinds of telemetry data we = wanted rather than coming straight at this with an existing solution and = trying to, in effect, short-circuit the whole analysis phase first. = That=92s usually a bad idea, and I don=92t think we=92ve examined the = problem we want to solve in enough detail to be casting around for = solutions just yet. We=92ll have plenty of time for that later, once = we=92re all sure we=92re on the same page about what we want. Believe = me, I=92ve been through this whole exercise once before (for both mobile = and desktop devices) and it=92s nowhere near as straight-forward as it = first seems! - Jordan