Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 Nov 2015 13:50:31 +0300
From:      Slawa Olhovchenkov <slw@zxy.spb.ru>
To:        Mark Johnston <markj@FreeBSD.org>
Cc:        freebsd-arch@FreeBSD.org
Subject:   Re: zero-cost SDT probes
Message-ID:  <20151122105031.GP48728@zxy.spb.ru>
In-Reply-To: <20151122024542.GA44664@wkstn-mjohnston.west.isilon.com>
References:  <20151122024542.GA44664@wkstn-mjohnston.west.isilon.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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(<probe args>);
> 
> 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(<probe args>);

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 <stdio.h>
#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<primecount;divisor++)
                {
                        PRIMES_PRIMECALC_ITER(divisor);
                        if (currentprime % primes[divisor] == 0)
                        {
                                isprime = 0;
                                break;
                        }
                }
                PRIMES_PRIMECALC_DONE(currentprime,isprime);
                if (isprime)
                {
                        primes[primecount++] = currentprime;
                        PRIMES_PRIMECALC_TABLESIZE(primecount);
                        // printf("%d is a prime\n",currentprime);
                }
                currentprime = currentprime + 2;
        }
        printf("Total %ld primes\n", primecount);

}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20151122105031.GP48728>