pcp
[Top] [All Lists]

Re: [pcp] python pmExtractValue segfault

To: Michele Baldessari <michele@xxxxxxxxxx>
Subject: Re: [pcp] python pmExtractValue segfault
From: Nathan Scott <nathans@xxxxxxxxxx>
Date: Wed, 28 May 2014 21:16:03 -0400 (EDT)
Cc: pcp@xxxxxxxxxxx
Delivered-to: pcp@xxxxxxxxxxx
In-reply-to: <20140528144433.GD4384@xxxxxxxxxxxxxxx>
References: <20140527223044.GC4384@xxxxxxxxxxxxxxx> <1135934547.16110444.1401239312938.JavaMail.zimbra@xxxxxxxxxx> <20140528144433.GD4384@xxxxxxxxxxxxxxx>
Reply-to: Nathan Scott <nathans@xxxxxxxxxx>
Thread-index: 999pcL/DhxFN8WDK3Cnz0WWjcw2WJg==
Thread-topic: python pmExtractValue segfault

----- Original Message -----
> Since pmNameInDomArchive was quite high up in my profiling
> I cached it in a dictionary so that indom_cache[(i, j)] = indom_name.

Nice.  If we look to begin merging these APIs, pcp.pmcc has a MetricCache
class, with by-name, by-PMID, and by-indom dictionaries, with the latter
providing the same optimisation you're describing here.

> This way I only look it up when the metric appears the first time, and
> I shave off 40% of the time needed to parse this (the rest is dominated
> by python casts and by pmExtractValue calls, for which there are less
> obvious ways to improve). Is this a safe thing to do? Am I guaranteed
> that the mapping (i, j)->indom_name will stay the same in an archive?
> 
> Somehow I assume that is not the case (pmcd restart with new PMDA, etc.),
> but maybe I'll get lucky ;)

Heh, yes and no.  PMDAs are required to make all efforts possible to
ensure that the instance-ID-to-name mapping is stable.  There's even
a series of APIs available - pmdaCache(3) - to allow them to persist
across PMDA restarted (even across reboots).

However, there's always the corner cases.  One example is per-process
metrics - these use PIDs as the instance ID, which of course can be
reused by the kernel and spring up afresh with a different process
behind them at some later time.

So, in general this is a good optimisation - but there are some cases
(exceptional cases, definitely not the norm) where PMDAs are unable to
come to the party.  There are a number of tools that do insist on the
stable mapping (or assume it), so its not a terrible thing on the part
of your tool if you choose to keep this optimisation.

cheers.

--
Nathan

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