Skip to content

compute: add ComputeRuntimeRole and role-labeled metrics#37884

Open
antiguru wants to merge 1 commit into
MaterializeInc:mainfrom
antiguru:mh/compute-runtime-role
Open

compute: add ComputeRuntimeRole and role-labeled metrics#37884
antiguru wants to merge 1 commit into
MaterializeInc:mainfrom
antiguru:mh/compute-runtime-role

Conversation

@antiguru

Copy link
Copy Markdown
Member

Motivation

The two-runtime read-isolation work (#37770) runs two compute runtimes in a
single clusterd process, sharing one metrics registry. Without per-runtime
labels the two runtimes register the same metric series and collide. This PR
adds the role concept and the metric labeling on its own, so that the
two-runtime PR is left with only the runtime wiring.

Description

Introduce ComputeRuntimeRole (Solo, Maintenance, Interactive) in
mz_compute::server and thread a role through serve into
ComputeMetrics::register_with. Each named role stamps a distinct role
const label on its metrics, so two runtimes sharing one process registry
register distinct series rather than colliding. The whole-registry
workload_class postprocessor is gated on the globals-owning role so it is
installed exactly once.

Solo is the single-runtime default and is behaviorally identical to compute
before a second runtime existed: it emits no role label, so exact-match
dashboards and alerts are byte-unchanged, and it owns the process globals as
the sole runtime always has. Every call site passes Solo here.

Two unit tests assert the two halves of the contract: Solo metrics carry no
role label, and the two named roles carry distinct labels so they coexist on
one registry.

Context

Prerequisite for #37770, which flips the call sites to Maintenance and
Interactive and adds the runtimes that use them. Independent of the other
#37770 prerequisites (#37880, #37881).

Verification

cargo check -p mz-compute -p mz-clusterd passes with no new warnings. The two
new metrics::tests pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CY7GHdrTBfAG4tgvSgPGJ9

Introduce `ComputeRuntimeRole` (Solo, Maintenance, Interactive) and thread a
role through `serve` into `ComputeMetrics::register_with`. Each named role
stamps a distinct `role` const label on its metrics so that two compute
runtimes sharing one process registry register distinct series rather than
colliding, and gates the whole-registry `workload_class` postprocessor on the
globals-owning role so it is installed exactly once.

`Solo` is the single-runtime default and is behaviorally identical to compute
before a second runtime existed: it emits no `role` label, so exact-match
dashboards and alerts are byte-unchanged, and it owns the process globals as
the sole runtime always has. Every call site passes `Solo` here. The
maintenance and interactive runtimes that use the other roles arrive with the
two-runtime work that builds on this.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CY7GHdrTBfAG4tgvSgPGJ9
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