← Back to Pull requests

swift-clusterd PoC which serves as seed node #1155

Open
unknown opened this pull request with 256 lines diff across 3 files
View on GitHub
unknown unknown commented on Jun 14, 2024 07:42 UTC
Author

Quick PoC how a clusterd daemon could look like.

Usage in practice would be to just ensure we start the daemon OR if ANY of the nodes is using daemon discovery make sure one of them spawns it or something like that.

This way nodes can join without hardcoding discovery of peer nodes when playing around locally.
This is inspired by https://forums.swift.org/t/beginner-advice-for-distributed-distributedcluster-modules/72391/11 and erlang's shortnames + https://www.erlang.org/docs/25/man/epmd

---

Creating a few nodes in a system would literarily be:

``bash

TODO: rename this to swift-clusterd, now it's called ClusterD in the PR


swift-clusterd & # or as a system-service - which is a binary we'd prepare and basically just does

`
this basically just does:
//     await ClusterSystem.startClusterDaemon()

This is the same as epmd, it has to be running somewhere.

EPMD is an external program, implemented in C. Whilst net_kernel:start/1 takes care of creating the net_sup supervisor, it does not actually trigger the EPMD daemon, which has to be started explicitely. I had a look at how EPMD is started when the -sname option is specified in the erl command and - surprise, surprise - I discovered that the epmd program is started via a system() C call.

And applications just do:

    let system = await ClusterSystem(name) { settings in
      settings.discovery = .clusterd
    }

and you're done:

> myapp --name first
> myapp --name second

they'll join eachother.

Follow up here:

  • ClusterD should be a "HIDDEN" member in the membership

  • Maybe we should call it swift-clusterd` (the cluster daemon for the swift distributed cluster)
  • resolves https://github.com/apple/swift-distributed-actors/issues/1152

    Diff: 256 lines (+192 / -64) across 3 files Reviewer: akbashev Review duration: 1217132m
    All Vouch review confidence checks passed
    Residual risk 0.26 = Change Risk (0.46) × (1 − Review Confidence (0.45)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.46 · 256 lines diff across 3 files
    0.46
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    44%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.332
    Real PR Conversation Timeline
    1 comments
    "Review active on #1155"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 44.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 46.1% (MEDIUM) · Higher = larger blast radius
    46.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 44.7% · Lower = rushed or shallow review
    44.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 25.5% · Safe to merge
    25.5%