From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13912 invoked by alias); 6 Oct 2006 01:08:40 -0000 Received: (qmail 13904 invoked by uid 22791); 6 Oct 2006 01:08:39 -0000 X-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mga01.intel.com (HELO mga01.intel.com) (192.55.52.88) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 06 Oct 2006 01:08:37 +0000 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by mga01.intel.com with ESMTP; 05 Oct 2006 18:08:36 -0700 Received: from scsmsx332.sc.intel.com (HELO scsmsx332.amr.corp.intel.com) ([10.3.90.6]) by fmsmga002.fm.intel.com with ESMTP; 05 Oct 2006 18:08:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: i="4.09,267,1157353200"; d="scan'208"; a="1764703:sNHT22145958" Received: from scsmsx413.amr.corp.intel.com ([10.3.90.32]) by scsmsx332.amr.corp.intel.com with Microsoft SMTPSVC(6.0.3790.211); Thu, 5 Oct 2006 18:08:35 -0700 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: Fwd: Any way to find the network usage by a process? Date: Fri, 06 Oct 2006 01:08:00 -0000 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Fwd: Any way to find the network usage by a process? Thread-Index: Acbo2ncwlXw+GjFgSRaIN0gOxme41AABTSjw From: "Stone, Joshua I" To: "Frank Ch. Eigler" , "Mike Mason" Cc: X-OriginalArrivalTime: 06 Oct 2006 01:08:35.0581 (UTC) FILETIME=[F2D392D0:01C6E8E3] X-IsSubscribed: yes Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org X-SW-Source: 2006-q4/txt/msg00033.txt.bz2 On Thursday, October 05, 2006 5:00 PM, Frank Ch. Eigler wrote: > Hi - >=20 > On Thu, Oct 05, 2006 at 04:28:10PM -0700, Mike Mason wrote: >> [...] >> ERROR: empty aggregate near identifier 'execname' at nettop.stp:35:4 >> WARNING: Number of errors: 1, skipped probes: 0 >> Apparently using @sum on empty aggregates isn't allowed. I expected >> 0's to be returned. >=20 > As a judgement call, to be consistent with other extractors like @avg, > the @sum etc. of an empty set was deemed to be undefined. FWIW, Python allows you to take the sum of an empty list, even though other equivalent extractors fail: >>> sum([]) 0 >>> max([]) Traceback (most recent call last): File "", line 1, in ? ValueError: min() or max() arg is an empty sequence I'm just looking for precedence in other languages... >> The only way to avoid the error is use @sum only if @count > >> 0, which makes the printf too complex in my opinion. >=20 > Maybe so. It's worth considering some syntactic sugar to express a > undefined=3D>0 intent. One possibility is an optional second parameter to the extractor that gives a default value. We could require this to be a constant (usually 0), or maybe even allow a numeric expression. a <<< 1; del a // prepare an empty aggregate printf("%d\n", @sum(a)) // runtime error printf("%d\n", @sum(a, 0)) // prints 0 printf("%d\n", @sum(a, x)) // prints value of x This works for min, max, and avg as well. Or, instead of a default, it might be less confusing to consider the second parameter as an initializer -- so when 'a' isn't empty, @sum(a,x) =3D=3D x + @sum(a). Then min and max would effectively get an upper and lower bound, respectively. I'm not sure if avg works well this way though. Josh