Skip to content

ENT-14329: Store only in-use measurement slots#21

Draft
nickanderson wants to merge 4 commits into
CFE-612-increase-monitor-slotsfrom
ENT-14329-storage-on-use
Draft

ENT-14329: Store only in-use measurement slots#21
nickanderson wants to merge 4 commits into
CFE-612-increase-monitor-slotsfrom
ENT-14329-storage-on-use

Conversation

@nickanderson

@nickanderson nickanderson commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Stacked on the bump (cfengine#6239 / ENT-6511). Draft, unsigned — for review.

  1. Store only in-use measurement slots — write up to the highest in-use slot instead of a full record every time: ~2.6 KB/record with no custom measurements vs 9.6 KB; ~22.8 MB/host vs ~84 MB.
  2. Report spare observables instead of padding the tableGetObservable() synthesizes "spare", so constants.c drops 300 → 72 rows.

Ticket: ENT-14329

~80 of the 100 slots are consumed by default measurements, leaving little
room for custom ones. Raise the limit to 300.

Kept in sync: CF_OBSERVABLES and the two cf-check copies of the on-disk
struct, plus the OBSERVABLES name table (GetObservable() indexes it for
unregistered slots, so a short table crashes cf-monitord). cf-check dump now
tolerates the shorter records and ts_key a pre-upgrade agent leaves behind.

Ticket: ENT-6511
Changelog: Increased the maximum number of cf-monitord measurement slots (CF_OBSERVABLES) from 100 to 300
@nickanderson
nickanderson force-pushed the CFE-612-increase-monitor-slots branch from 50d4f8a to 2fbdc3d Compare July 20, 2026 15:29
* The number of bytes of an Averages record that are actually in use. The
* built-in observables (indices 0..ob_spare-1) are always present; the custom
* slots above them are used only where a measurement is registered. cf-monitord
* writes only this many bytes per timekey, so unused trailing slots (up to 200

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment should be more concise.

@nickanderson
nickanderson force-pushed the ENT-14329-storage-on-use branch from 2abe0c7 to 4cddccf Compare July 20, 2026 15:55
Raising CF_OBSERVABLES enlarges the fixed-size Averages record, so records
written by an older agent are shorter than the current struct. Added a
migration (modelled on dbm_migration_lastseen.c) that rewrites old records to
the current size, zero-filling the new slots, registered for the observations
and history DBs. This replaces the cf-check dump leniency with a one-time
on-disk migration; dump only needs to know the new "version" key.

Ticket: ENT-6511
Changelog: None
@nickanderson
nickanderson force-pushed the ENT-14329-storage-on-use branch 2 times, most recently from b5b397b to def8421 Compare July 21, 2026 16:19
cf-monitord wrote a full Averages record per timekey regardless of use, so the
raised CF_OBSERVABLES cost ~56 MB/host even with no custom measurements. Write
only up to the highest in-use slot (AveragesUsedSize); readers zero-and-clamp,
so the unused tail reads back as zero.

Ticket: ENT-14329
Changelog: cf-monitord stores only in-use measurement slots
GetObservable() returns "spare"/"unused" for unregistered slots instead of
indexing the OBSERVABLES table beyond its named entries, so the table no longer
needs a {"spare","unused"} row per slot.

Ticket: ENT-14329
Changelog: None
@nickanderson
nickanderson force-pushed the ENT-14329-storage-on-use branch from def8421 to cdee340 Compare July 21, 2026 16:30
@nickanderson
nickanderson force-pushed the CFE-612-increase-monitor-slots branch 2 times, most recently from fa550dd to d278e7e Compare July 22, 2026 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant