PMCONVSCALE(3)
π NAME π
pmConvScale β rescale a performance metric value β¨
π«Ά C SYNOPSIS π«Ά
#include <pcp/pmapi.h>
int pmConvScale(int type, const pmAtomValue *ival, const pmUnits *iunit,
pmAtomValue *oval, const pmUnits *ounit);
cc ... -lpcp
πΈ DESCRIPTION πΈ
okay so first things first, bestie: every single performance metric value out there can be packed into a pmAtomValue union, and it looks exactly like this π
typedef union {
__int32_t l; /* 32-bit signed */
__uint32_t ul; /* 32-bit unsigned */
__int64_t ll; /* 64-bit signed */
__uint64_t ull; /* 64-bit unsigned */
float f; /* 32-bit floating point */
double d; /* 64-bit floating point */
char *cp; /* char ptr */
pmValueBlock *vbp; /* pmValueBlock ptr */
} pmAtomValue;
and the way a performance metric's dimensionality and scale get encoded? that's a pmUnits structure, no cap. go peek at pmLookupDesc(3) for the whole tea β
so here's the vibe: you hand over a performance metric value pointed to by ival, it gets multiplied by a scale factor, and the glow-up lands in oval π
the scaling happens from the units defined by iunit into the units defined by ounit.
π¨ real talk: both the input and the output units have to have the same dimensionality. like, each of the fieldsdimSpace,dimTime,dimCountandextraUnitmust have the same value in bothiunitandounit. no matching dimensionality, no conversion. periodt.
the performance metric type for both the input and the output values is determined by type, and that value is typically extracted from a pmDesc structure, following a call to pmLookupDesc(3) for a particular performance metric. so like, you already have it lying around usually π
pmConvScale is most useful when values returned via pmFetch(3), (and possibly extracted using pmExtractValue(3)) need to be normalized into some canonical scale and units for the purposes of computation. it's giving "let's all agree on one unit before we do math" and honestly? iconic.
and now for the special case that lives rent free in my head: if all components of the dimension are zero, then this is treated as synonymous with a count dimension of one, and so the count scale components determine the relative scaling π₯ this accommodates the case where performance metrics are dimensionless, without special case handling on the part of the caller. meaning you don't have to write that if-branch yourself. you're welcome π«Ά
π DIAGNOSTICS π
PM_ERR_CONVβiunitandounithave different dimensionality, or have inappropriate type πPM_ERR_UNITβ Inappropriateiunitorounitparameter π
π₯ SEE ALSO π₯
PMAPI(3), pmAtomStr(3), pmExtractValue(3), pmFetch(3), pmLookupDesc(3), pmPrintValue(3), pmTypeStr(3) and pmUnitsStr(3).
and that's the whole page, bestie!! this lil masterpiece comes to you from Performance Co-Pilot, aka PCP, and it lives its life under the name PMCONVSCALE(3) π go forth and convert those units responsibly, mwah πβ¨
π¦ where this page comes from
- arch rolling: pcp 7.2.2-2 Β· GPL-2.0-or-later AND LGPL-2.1-or-later AND CC-BY-3.0
- fedora 43: pcp-doc 7.2.1-1.fc43
- fedora 43: pcp-doc 7.2.2-1.fc43
- fedora 43: pcp-doc 7.2.2-2.fc43 Β· GPL-2.0-or-later AND CC-BY-3.0
- fedora 44: pcp-doc 7.2.1-1.fc44
- fedora 44: pcp-doc 7.2.2-1.fc44
- fedora 44: pcp-doc 7.2.2-2.fc44 Β· GPL-2.0-or-later AND CC-BY-3.0
- ubuntu stonking: libpcp4-dev 7.2.1-2build1
- Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms