PMAREWRITEMETA(3)

πŸ“¦
version 7.2.2 Β· 4 versions
, in arch rolling, centos-stream 10, fedora 43, fedora 44, ubuntu resolute, ubuntu stonking

✨ pmaRewriteMeta ✨ (that's section 3 of the Library Functions Manual, bestie πŸ’…)

okay so like… this is a <pcp/libpcp.h> internal-zone situation and I'm obsessed 🫢 it lives in the Library Functions Manual, section 3, and it's giving very specific, very developer-only energy. let's get into it πŸ’–


🌸 NAME 🌸

pmaRewriteMeta β€” try to change the version of an archive metadata record πŸ¦‹


πŸ’œ C SYNOPSIS πŸ’œ

#include <pcp/pmapi.h>
#include <pcp/libpcp.h>
#include <pcp/archive.h>

int pmaRewriteMeta(__pmLogCtl *inlcp, __pmLogCtl *outlcp,
                   __int32_t *rbuf);

cc ... -lpcp_archive -lpcp

so you include all three of those headers, no skipsies, and you link against -lpcp_archive and -lpcp. both. periodt ✨


🚨 CAVEAT 🚨

bestie this is internal. like, for real.

This documentation is intended for internal Performance Co-Pilot (PCP) developer use. πŸ™ˆ

These interfaces are not part of the PCP APIs that are guaranteed to remain fixed across releases, and they may not work, or may provide different semantics at some point in the future. 😭 so don't build your whole personality on them, iykyk.


πŸŽ€ DESCRIPTION πŸŽ€

okay so here's the vibe πŸ’… A physical metadata record from the input archive identified by inlcp gets passed in via rbuf, and this function reformats it if required to produce the equivalent metadata record for the output archive identified by outlcp. slay πŸ¦‹

Combined with the input and output archive versions, the type of the metadata record (as extracted from rbuf) is used to decide if β€” because for some record types and version changes, no rewriting is required. so sometimes it just… doesn't do anything. iconic behavior honestly ✨

pmaRewriteMeta is intended to be used in cases where the archive version of inlcp and outlcp are different. The only sane choice of archive versions today is PM_LOG_VERS02 for inlcp and PM_LOG_VERS03 for outlcp, which would be requesting a rewrite from archive version 2 format to archive version 3 format (as only versions 2 and 3 are currently supported). so like, 2 ➑️ 3, that's the move, that's the only move πŸ‘‘

⚠️ the important bit, do not skip this one ⚠️ If rewriting takes place, the old rbuf will have been free'd and a new rbuf allocated with malloc(3). It is the caller's responsibility to make sure this potential free-and-allocate will be safe β€” e.g. no dangling references into the contents of rbuf, or pass in a copy of the record if it is precious. πŸ’€ do not let your pointers dangle, bestie, that's not the vibe.

πŸ”₯ DIAGNOSTICS AND RETURN VALUES πŸ”₯

In several places, fatal errors will trigger an error message and force the application to exit. 😳 like, it's not asking. the app is leaving.

If there is no defined translation for the versions of inlcp and outlcp then pmaRewriteMeta returns PM_ERR_APPVERSION (a slight perversion of this error code). πŸ’€ iconic honestly

If no rewrite is performed, the return value is 0. Otherwise, a return value of 1 indicates a rewrite has taken place and rbuf has been reallocated. so:

  1. 0 β€” no rewrite, nothing happened, we're chilling 🌸
  2. 1 β€” rewrite happened, rbuf got reallocated, check your pointers bestie 🫢
  3. PM_ERR_APPVERSION β€” no defined translation for those versions, rip πŸ’œ

πŸ‘€ SEE ALSO πŸ‘€


and that's the whole page, bestie πŸ’– this one came straight out of Performance Co-Pilot (that's PCP πŸŽ€) and it's dated PCP, filed under PMAREWRITEMETA(3) in the Library Functions Manual. go forth and rewrite those metadata records responsibly, mwah πŸ’…βœ¨

πŸ“¦ where this page comes from