Skip to content

feat(control_plane): plumb per-metric sample_p from workload to agent emit - #339

Merged
zzylol merged 1 commit into
mainfrom
feat/sample-p-control-plane
May 25, 2026
Merged

zzylol merged 1 commit into
mainfrom
feat/sample-p-control-plane

Conversation

@zzylol

@zzylol zzylol commented May 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Add an optional per-metric sketch sampling probability p so an operator can turn on the warm-sketch sampling per metric from the control plane.

  • WorkloadEntry gains a sample_p field (workload YAML, default 1.0 = sampling disabled).
  • The planner threads it into EdgeStageConfig.metric_to_sample_p via a new collect_metric_to_sample_p collector — wired in both the bootstrap (main::emit_bootstrap_typed) and replan (replan.rs) paths, mirroring the existing metric_to_grouping_labels / cumulative_counter_metrics stitch.
  • The L5 edge emitter writes a sample_p knob onto the CMS / HLL sketch-processor block in build_edge_processor_block (and the fused asap_edge per-metric entries), via a shared insert_sample_p helper guarded so it is only emitted when p < 1.

Full path (file:func at each hop)

  1. control_plane/src/workload.rs — WorkloadEntry::sample_p (operator field, default 1.0).
  2. control_plane/src/emit/mod.rs — collect_metric_to_sample_p() (validates (0,1], skips 1.0/out-of-range).
  3. control_plane/src/main.rs::emit_bootstrap_typed + replan.rs — stitch into EdgeStageConfig.metric_to_sample_p.
  4. control_plane/src/physical/colored_dag/emitter.rs — EdgeStageConfig::metric_to_sample_p field.
  5. control_plane/src/emit/stage_config.rs::build_edge_processor_block → insert_sample_p — emits sample_p: on the CMS/HLL agent YAML block.
  6. → agent countminsketchprocessor/hllprocessor Config.SampleP → sketchlib-go WithSampleP (companion agent PR).

Default 1.0 everywhere keeps the map empty and emits no sample_p key ⇒ byte-identical agent config when unset.

Test plan

  • cargo build + cargo test green (775 lib + 28 integration).
  • Tests: WorkloadEntry.sample_p default/parse; a configured p<1 reaches the emitted agent YAML for CMS + HLL; 1.0/unset emits nothing.
  • No shared-type-by-literal break introduced. cargo check --bin data_plane is currently red in this checkout due to a pre-existing asap-precompute-rs vs asap_sketchlib proto skew (missing sample_p/registers_sparse in regenerated proto, plus renamed sketch types) — asap-precompute-rs fails standalone, independent of this PR. This change is additive control-plane-internal types; cargo build -p control_plane (what data_plane's control_plane dep needs) is green.

Merge order

Merge the agent PR first: ProjectASAP/ASAPCollector#441 (CMS/HLL processor sample_p + precompute WithSampleP). This PR emits that agent config.

Out of scope / follow-up

Dynamic, optimizer-driven p (tuned online from runtime samples against an accuracy/bandwidth budget) — this PR ships only the static per-metric knob.

🤖 Generated with Claude Code

… emit

Add an optional per-metric sketch sampling probability so an operator can
turn on the warm-sketch sampling per metric. WorkloadEntry gains a
sample_p field (default 1.0, sampling disabled). The planner threads it
into EdgeStageConfig.metric_to_sample_p via collect_metric_to_sample_p
(mirroring the metric_to_grouping_labels / cumulative_counter_metrics
stitch in both the bootstrap and replan paths), and the L5 edge emitter
writes a sample_p knob onto the CMS / HLL sketch-processor block in
build_edge_processor_block (and the fused asap_edge per-metric entries),
guarded so it is only emitted when p < 1.

Default 1.0 everywhere keeps the map empty and emits no sample_p key, so
the agent config is byte-identical to today when unset; out-of-range
values are validated (logged and skipped) at collection and re-guarded at
emit. Tests cover the workload field default/parse and that a configured
p<1 reaches the emitted agent YAML for CMS + HLL while 1.0/unset emits
nothing.

This is a static operator-set knob; an optimizer-driven dynamic p is a
follow-up. Requires the agent-side sample_p support (CMS/HLL processor +
precompute WithSampleP) to be merged first.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@zzylol
zzylol merged commit 0ed0c75 into main May 25, 2026
@zzylol
zzylol deleted the feat/sample-p-control-plane branch July 17, 2026 20:05
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