From owner-freebsd-arch@freebsd.org Sun Nov 22 10:50:37 2015 Return-Path: Delivered-To: freebsd-arch@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0048CA357EC for ; Sun, 22 Nov 2015 10:50:37 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from zxy.spb.ru (zxy.spb.ru [195.70.199.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B38821949; Sun, 22 Nov 2015 10:50:36 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from slw by zxy.spb.ru with local (Exim 4.86 (FreeBSD)) (envelope-from ) id 1a0SE3-000JyS-Vh; Sun, 22 Nov 2015 13:50:32 +0300 Date: Sun, 22 Nov 2015 13:50:31 +0300 From: Slawa Olhovchenkov To: Mark Johnston Cc: freebsd-arch@FreeBSD.org Subject: Re: zero-cost SDT probes Message-ID: <20151122105031.GP48728@zxy.spb.ru> References: <20151122024542.GA44664@wkstn-mjohnston.west.isilon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151122024542.GA44664@wkstn-mjohnston.west.isilon.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: slw@zxy.spb.ru X-SA-Exim-Scanned: No (on zxy.spb.ru); SAEximRunCond expanded to false X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Nov 2015 10:50:37 -0000 On Sat, Nov 21, 2015 at 06:45:42PM -0800, Mark Johnston wrote: > Hi, > > For the past while I've been experimenting with various ways to > implement "zero-cost" SDT DTrace probes. Basically, at the moment an SDT > probe site expands to this: > > if (func_ptr != NULL) > func_ptr(); > > When the probe is enabled, func_ptr is set to dtrace_probe(); otherwise > it's NULL. With zero-cost probes, the SDT_PROBE macros expand to > > func(); I am experimenting with overhead DTrace probes in userspace. Total executing time program w/o any probes 3% less then program with not enabled probes. With enabled probes (conditional probes too) -- each probe add about 0.7us. I am place DTrace probe inside inner loop, worst case. ===== #include #include "probes.h" long primes[1000000] = { 3 }; long primecount = 1; int main(int argc, char **argv) { long divisor = 0; long currentprime = 5; long isprime = 1; while (currentprime < 1000000) { isprime = 1; PRIMES_PRIMECALC_START(currentprime); for(divisor=0;divisor