Skip to content

Conversation

tobz
Copy link
Member

@tobz tobz commented Apr 21, 2025

Summary

This PR introduces a new runtime system in saluki-core modeled after Erlang/OTP's supervision trees, a powerful design pattern for building fault-tolerant systems composed of many interdependent "processes" in a way that they can recover from failure.

Supervision trees are explained succinctly by the Erlang/OTP documentation, but generally: we have a collection of processes (asynchronous tasks) that have some level of fallibility, and we want to -- where possible -- maximize their resilience by allowing them to be restarted if they fail. Supervision trees approach this from the perspective of declaring a "specification" that describes how to create the process (in our case, building the Future that is spawned) and then adding those specifications to a supervisor, which is responsible for managing those processes, restarting them when die, giving up if certain restart limits are hit, and so on.

While we lack a lot of the power of Erlang itself, in terms of what Erlang/OTP's supervisors can build on top of, even having the basics provides us a lot of leeway for building things in a more fault-tolerant way:

  • restarting crashed topology components, or arbitrary background tasks, in a uniform and consistent way
  • providing the scaffolding to track all active tasks and how they're nested
  • ordered shutdown for everything instead of just the topology

We're intentionally only implementing many of the basics here -- worker specification, restart strategy, nested supervisors, orderly shutdown, etc -- but will add enhanced capabilities in future iterations, such as runtime telemetry/introspection, dynamic workers, and more.

Change Type

  • Bug fix
  • New feature
  • Non-functional (chore, refactoring, docs)
  • Performance

How did you test this PR?

N/A

References

AGTMETRICS-233

@github-actions github-actions bot added the area/core Core functionality, event model, etc. label Apr 21, 2025
@tobz tobz changed the title experiment: Erlang/OTP-style supervisor system [AGTMETRICS-184] experiment: Erlang/OTP-style supervisor system Apr 23, 2025
@tobz tobz force-pushed the tobz/erlang-otp-style-supervisor-system branch from dc6c05f to 343860d Compare May 8, 2025 18:40
@tobz tobz force-pushed the tobz/erlang-otp-style-supervisor-system branch from 343860d to 9840350 Compare May 25, 2025 13:04
@tobz tobz force-pushed the tobz/erlang-otp-style-supervisor-system branch 2 times, most recently from ed00477 to 74574e9 Compare June 16, 2025 23:46
@github-actions github-actions bot added area/io General I/O and networking. area/config Configuration. area/components Sources, transforms, and destinations. area/ci CI/CD, automated testing, etc. source/dogstatsd DogStatsD source. transform/aggregate Aggregate transform. destination/datadog-metrics Datadog Metrics destination. destination/prometheus Prometheus Scrape destination. destination/datadog Common Datadog destination code. labels Jun 16, 2025
@tobz tobz force-pushed the tobz/erlang-otp-style-supervisor-system branch from e2c007a to feb74bb Compare June 17, 2025 13:41
@github-actions github-actions bot removed area/io General I/O and networking. area/config Configuration. area/components Sources, transforms, and destinations. source/dogstatsd DogStatsD source. transform/aggregate Aggregate transform. destination/datadog-metrics Datadog Metrics destination. destination/prometheus Prometheus Scrape destination. destination/datadog Common Datadog destination code. labels Jun 17, 2025
@tobz tobz force-pushed the tobz/erlang-otp-style-supervisor-system branch from feb74bb to 125372c Compare September 12, 2025 19:21
@tobz tobz force-pushed the tobz/erlang-otp-style-supervisor-system branch from 125372c to 4a63c4e Compare September 23, 2025 14:46
@github-actions github-actions bot added area/io General I/O and networking. area/config Configuration. area/components Sources, transforms, and destinations. area/memory Memory bounds and memory management. labels Sep 23, 2025
@github-actions github-actions bot removed transform/host-tags Host Tags synchronous transform. source/checks Checks source. destination/datadog-service-checks Datadog Service Checks destination. area/docs Reference documentation. labels Sep 28, 2025
@tobz tobz force-pushed the tobz/erlang-otp-style-supervisor-system branch from 581b0f6 to bf3527b Compare September 29, 2025 20:10
@github-actions github-actions bot removed the area/ci CI/CD, automated testing, etc. label Sep 29, 2025
@github-actions github-actions bot removed the area/test All things testing: unit/integration, correctness, SMP regression, etc. label Sep 29, 2025
@github-actions github-actions bot removed area/components Sources, transforms, and destinations. transform/preaggregation-filter Preaggregation Filter synchronous transform. labels Sep 29, 2025
@tobz tobz marked this pull request as ready for review September 29, 2025 20:20
@tobz tobz requested a review from a team as a code owner September 29, 2025 20:20
@tobz tobz added the type/enhancement An enhancement in functionality or support. label Sep 29, 2025
@tobz tobz changed the title [AGTMETRICS-184] experiment: Erlang/OTP-style supervisor system enhancement(core): Erlang/OTP-style supervisor system Sep 29, 2025
@DataDog DataDog deleted a comment from datadog-datadog-prod-us1 bot Sep 30, 2025
@DataDog DataDog deleted a comment from pr-commenter bot Sep 30, 2025
@DataDog DataDog deleted a comment from pr-commenter bot Sep 30, 2025
@DataDog DataDog deleted a comment from pr-commenter bot Sep 30, 2025
@DataDog DataDog deleted a comment from pr-commenter bot Sep 30, 2025
@DataDog DataDog deleted a comment from pr-commenter bot Sep 30, 2025
@DataDog DataDog deleted a comment from pr-commenter bot Sep 30, 2025
@pr-commenter
Copy link

pr-commenter bot commented Sep 30, 2025

Regression Detector (Agent Data Plane)

Regression Detector Results

Run ID: 0546c77b-62eb-48c2-825b-d04173cd8996

Baseline: 0957bb3
Comparison: e09fddb
Diff

Optimization Goals: ✅ No significant changes detected

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI trials links
quality_gates_rss_dsd_medium memory utilization +0.30 [+0.12, +0.47] 1
quality_gates_rss_dsd_heavy memory utilization +0.29 [+0.19, +0.38] 1
quality_gates_rss_idle memory utilization +0.17 [+0.15, +0.19] 1
dsd_uds_10mb_3k_contexts_throughput ingress throughput +0.03 [-0.02, +0.08] 1
dsd_uds_512kb_3k_contexts_throughput ingress throughput +0.00 [-0.01, +0.02] 1
quality_gates_rss_dsd_ultraheavy ingress throughput +0.00 [-0.04, +0.04] 1
dsd_uds_1mb_3k_contexts_throughput ingress throughput -0.00 [-0.02, +0.01] 1
dsd_uds_100mb_3k_contexts_throughput ingress throughput -0.01 [-0.08, +0.06] 1
quality_gates_rss_dsd_low memory utilization -0.07 [-0.22, +0.07] 1
dsd_uds_500mb_3k_contexts_throughput ingress throughput -3.41 [-3.54, -3.27] 1

Bounds Checks: ✅ Passed

perf experiment bounds_check_name replicates_passed links
quality_gates_rss_dsd_heavy memory_usage 10/10
quality_gates_rss_dsd_low memory_usage 10/10
quality_gates_rss_dsd_medium memory_usage 10/10
quality_gates_rss_dsd_ultraheavy memory_usage 10/10
quality_gates_rss_idle memory_usage 10/10

Explanation

Confidence level: 90.00%
Effect size tolerance: |Δ mean %| ≥ 5.00%

Performance changes are noted in the perf column of each table:

  • ✅ = significantly better comparison variant performance
  • ❌ = significantly worse comparison variant performance
  • ➖ = no significant change in performance

A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".

For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:

  1. Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.

  2. Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.

  3. Its configuration does not mark it "erratic".

@pr-commenter
Copy link

pr-commenter bot commented Sep 30, 2025

Regression Detector (Agent Data Plane w/ Checks)

Regression Detector Results

Run ID: 9136ff2d-887d-4d14-b93e-b9227939eed7

Baseline: 0957bb3
Comparison: e09fddb
Diff

Optimization Goals: ✅ No significant changes detected

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI trials links
quality_gates_rss_idle memory utilization +0.02 [+0.01, +0.04] 1
quality_gates_rss_basic memory utilization -0.14 [-0.16, -0.13] 1

Bounds Checks: ✅ Passed

perf experiment bounds_check_name replicates_passed links
quality_gates_rss_basic memory_usage 10/10
quality_gates_rss_idle memory_usage 10/10

Explanation

Confidence level: 90.00%
Effect size tolerance: |Δ mean %| ≥ 5.00%

Performance changes are noted in the perf column of each table:

  • ✅ = significantly better comparison variant performance
  • ❌ = significantly worse comparison variant performance
  • ➖ = no significant change in performance

A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".

For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:

  1. Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.

  2. Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.

  3. Its configuration does not mark it "erratic".

@pr-commenter
Copy link

pr-commenter bot commented Sep 30, 2025

Regression Detector Links

ADP Experiment Result Links

experiment link(s)
dsd_uds_100mb_3k_contexts_throughput [Profiling] [SMP Dashboard]
dsd_uds_10mb_3k_contexts_throughput [Profiling] [SMP Dashboard]
dsd_uds_1mb_3k_contexts_throughput [Profiling] [SMP Dashboard]
dsd_uds_500mb_3k_contexts_throughput [Profiling] [SMP Dashboard]
dsd_uds_512kb_3k_contexts_throughput [Profiling] [SMP Dashboard]
quality_gates_rss_dsd_heavy [Profiling] [SMP Dashboard]
quality_gates_rss_dsd_low [Profiling] [SMP Dashboard]
quality_gates_rss_dsd_medium [Profiling] [SMP Dashboard]
quality_gates_rss_dsd_ultraheavy [Profiling] [SMP Dashboard]
quality_gates_rss_idle [Profiling] [SMP Dashboard]

ADP && Checks Experiment Result Links

experiment link(s)
quality_gates_rss_basic [Profiling] [SMP Dashboard]
quality_gates_rss_idle [Profiling] [SMP Dashboard]

Comment on lines +20 to +25
//! Processes have a few key attributes and invariants:
//!
//! - every process is a future that runs as an independent asynchronous task on a Tokio runtime
//! - every process has a unique numerical identifier and a semi-unique name
//!
//! Processes cannot run by themselves, however. They must be _supervised_.
Copy link
Contributor

Choose a reason for hiding this comment

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

Confirming, unlike Erlang processes saluki-core processes do not have a mailbox / input queue associated for message passing?

Copy link
Contributor

Choose a reason for hiding this comment

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

Confirmed later, no mailbox. Probably worth adding this to the documentation in case someone -- like myself -- comes along with an Erlang mental model inappropriately.

Comment on lines +44 to +45
/// Process names will be sanitized if they contain invalid characters, such as hyphens or spaces. Invalid characters
/// will be replaced with underscores.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not opposed, just curious why we don't reject invalid names outright? Haven't confirmed yet, it's possible the intention here is for process names to arrive via user config, in which case this does make some sense.

Comment on lines +298 to +301
// TODO: Erlang/OTP defaults to always trying to restart a process, even if it doesn't terminate due to a
// legitimate failure. It does allow configuring this behavior on a per-process basis, however. We don't
// support dynamically adding child processes, which is the only real use case I can think of for having
// non-long-lived child processes... so I think for now, we're OK just always try to restart.
Copy link
Contributor

Choose a reason for hiding this comment

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

+1

@@ -0,0 +1,175 @@
use std::time::Duration;
Copy link
Contributor

Choose a reason for hiding this comment

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

I like how the API works. Probably worth developing a lint or something to confirm that processes actually check their shutdown signal properly. Shame we don't have the ability to preempt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Core functionality, event model, etc. type/enhancement An enhancement in functionality or support.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants