From owner-freebsd-dtrace@FreeBSD.ORG Wed Jun 17 21:59:51 2015 Return-Path: Delivered-To: freebsd-dtrace@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A4E0841E for ; Wed, 17 Jun 2015 21:59:51 +0000 (UTC) (envelope-from abhya007@gmail.com) Received: from mail-pa0-x235.google.com (mail-pa0-x235.google.com [IPv6:2607:f8b0:400e:c03::235]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7565FCA7 for ; Wed, 17 Jun 2015 21:59:51 +0000 (UTC) (envelope-from abhya007@gmail.com) Received: by paceq1 with SMTP id eq1so21136772pac.3 for ; Wed, 17 Jun 2015 14:59:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=zarGeoGAW6IF6tMkmCxu90jUdPZWZXFeXJwEolzeAV8=; b=SN2T23fyS0Vf2vcd6nNOVmfRT2MmWbL8038ZZ0+LF4L7w5CX/AvHUkGKOaRQkQ9jN2 swJOkp5hxe9Hx+CimKm6y/oHopcdZegA6gl7bQcNhQreN4sZ9lksR1uUfoydAMRm4JKe iNwndU/9FlmnIx8SmSjjj7HEJ0fkhnlSTc6s7+Alpzv2FbJivBghSRyYU54gvLlvlVBG UMSrA/Gpr3a2vmdNLGyrVzAPAxFsyaRyWjiyr8prpWzVSpoaW01SbWwaPT/HZxZ8EV9Y iRi0C5cHrgEZPtKtY+BrGet8sYRzbYAa1txwXYAgR/DQkQZ0d/VZoKeE5SSB2PXZg2/v ruaQ== MIME-Version: 1.0 X-Received: by 10.66.217.161 with SMTP id oz1mr14951351pac.56.1434578390734; Wed, 17 Jun 2015 14:59:50 -0700 (PDT) Received: by 10.70.46.99 with HTTP; Wed, 17 Jun 2015 14:59:50 -0700 (PDT) Date: Wed, 17 Jun 2015 14:59:50 -0700 Message-ID: Subject: Aggregation in Dtrace Script Causing performance issues From: abhishek kulkarni To: freebsd-dtrace@freebsd.org Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.20 X-BeenThere: freebsd-dtrace@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "A discussion list for developers working on DTrace in FreeBSD." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Jun 2015 21:59:51 -0000 Hello All, Iam Working on a Dtrace Script for the ping utility. The purpose is to measure the CPU time for the current thread which is PING.We tried doing it using an aggregation function and once while avoiding it.We observed the times for a ping response, for both scripts. The response was roughly taking thrice the time ( around 3.519 ms ) when an aggregation function was used as against a script not using aggregation ( which took around 0.219 ms ) . Could this be explained in detail.I believe, Dtrace , being considered a lightweight tool shouldnt affect the performance upto such an extent. Here are the 2 scripts : *Not using an aggregate function* : BEGIN { times = 0; } sched:::on-cpu /execname == "ping"/ { /* thread entering CPU */ start[execname] = timestamp; } sched:::off-cpu /start[execname] != 0/ { /* Thread leaving CPU */ times += timestamp - start[execname]; start[execname] = 0 ; } END { printf("The delta is : %d", (times/1000000)); times =0; } *Using an aggregate function "SUM"* sched:::on-cpu /execname == "ping"/ { self->ts = timestamp; } sched:::off-cpu /self->ts != 0/ { @delta[execname] = sum((timestamp - self-.ts)/1000000); self->ts =0; }