pcp
[Top] [All Lists]

Re: [pcp] pcp update: fetchgroups v4: with event-field support

To: Nathan Scott <nathans@xxxxxxxxxx>, "Frank Ch. Eigler" <fche@xxxxxxxxxx>
Subject: Re: [pcp] pcp update: fetchgroups v4: with event-field support
From: Mark Goodwin <mgoodwin@xxxxxxxxxx>
Date: Thu, 21 Jan 2016 14:55:09 +1100
Cc: Marko Myllynen <myllynen@xxxxxxxxxx>, pcp@xxxxxxxxxxx
Delivered-to: pcp@xxxxxxxxxxx
In-reply-to: <152148245.11905438.1453332764634.JavaMail.zimbra@xxxxxxxxxx>
References: <20160102052522.GB13026@xxxxxxxxxx> <568FAC70.5040506@xxxxxxxxxx> <56931A33.8000603@xxxxxxxxxx> <1222601165.10793219.1453171955611.JavaMail.zimbra@xxxxxxxxxx> <20160119152928.GB13054@xxxxxxxxxx> <2039224745.11117897.1453237884814.JavaMail.zimbra@xxxxxxxxxx> <20160120174347.GA10695@xxxxxxxxxx> <152148245.11905438.1453332764634.JavaMail.zimbra@xxxxxxxxxx>
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0
On 01/21/2016 10:32 AM, Nathan Scott wrote:
...
2. Sentinel values

   I'm not so much against sentinels in the way Mark seemed to be, as
   it looks kinda handy, but the choice of zero as a sentinel integer
   value strikes me as questionable. [...prefer -1...]

OK, will look into that.  [...]

A second thought appears here.  We support unsigned integer types, for
whom a -1 sentinel becomes an inconveniently large number.  The
sentinel-checking logic would have to be metric-type specific and IMHO
unsightly, whereas zero is OK everywhere.

metric-type specific sentinels will lead us into a bowl of spaghetti


Except for double/float.  And Unsightly is trumped by Misleading.

Remember, the point of sentinel values is to be convenient for
computation & output, should the application *not care* about the
presence of errors.  (If the application cared about errors, it would
use individual status integers.)

applications should *always* care about errors. my 2c :)
So what matters is not how easily
the sentinel can be identified, but rather how smoothly an *unchecked*
sentinel value would mesh in with real values, with minimal disruption
of application data flow.

Firstly, reporting incorrect information is a big problem.  And zero
as a numeric value is so often of meaning & importance that no matter
how uncaring a tool author is about ENODATA, we cannot encourage it.

yep


Consider many values from the real world - swap.used, filesys.free,
mem.util.{free,dirty,...}, the many metrics that are indicate errors,
and on and on - zero really is the worst possible sentinel choice.

agree


Secondly, above rationale is the inconsistent with the approach taken
for double/float which generates NaN instead of 0.0.  We need to pick
one or the other, not half-and-half, and its important to not provide
potentially-very-misleading zero values as defaults.

It makes most sense to me to have the sentinel values as: empty string,
NaN (as you have), and all-bits-set for integers (ie -1).  Then perhaps
provide a helper to aid with this programmer inconvenience angle:


perhaps -2^31, which is kind of the same as a float NaN and better than zero 
IMO :

/* Not An Integer */
#define NAI (int)(0.0F/0.0F)
#define NAI2 (int)(-1 << 31)

void main(void) { printf ("%d %d 0x%08x\n", NAI, NAI2, NAI2); }

# ./a.out
-2147483648 -2147483648 0x80000000

Since we're dealing with already-rate-converted values, premature wrapped 
counters
shouldn't be an issue (?)

Cheers
-- Mark





<Prev in Thread] Current Thread [Next in Thread>