From a161175686d52347391868d67540677f64a53319 Mon Sep 17 00:00:00 2001 From: Richard Mortier Date: Wed, 27 Sep 2023 18:31:14 +0200 Subject: [PATCH 1/2] model: add a simple OCaml model of edgeless --- model/.ocamlformat | 1 + model/edgeless.ml | 128 +++++++++++++++++++++++++++++++++++++++++++++ model/edgeless.mli | 0 3 files changed, 129 insertions(+) create mode 100644 model/.ocamlformat create mode 100644 model/edgeless.ml create mode 100644 model/edgeless.mli diff --git a/model/.ocamlformat b/model/.ocamlformat new file mode 100644 index 00000000..ed7d4b31 --- /dev/null +++ b/model/.ocamlformat @@ -0,0 +1 @@ +version = 0.26.0 diff --git a/model/edgeless.ml b/model/edgeless.ml new file mode 100644 index 00000000..92191a21 --- /dev/null +++ b/model/edgeless.ml @@ -0,0 +1,128 @@ +(** Entity identifiers. *) + +type nid = int (* Nodes *) +type wid = int (* Workflows *) +type fid = int (* Functions*) + +(** Forwarding tables. + +A forwarding table is a list of forwarding table entries, each of which +maps a specific function instance in a specific workflow to one or more +function instances on other nodes with some priority for load balancing. +*) + +type prio = int (* Entry priority, for load balancing *) +type fwde = (wid * fid) * ((nid * fid) * prio) list +(* Forwarding table entries, the list of postential destination function + instances with associated priorities corresponding to a function i + nstance on this node *) + +type fwdt = fwde list (* Forwarding table, a list of entries *) + +(** Resources. + +A node has some resources: CPU and memory are mandatory while others are +optional and may be absent. +*) + +type cpu = int (* milli-vCPUs *) +type memory = int (* MB *) +type tee = Sgx | Trustzone (* Different types of TEE *) +type gpu = Cuda | Nvidia (* Different types of GPU *) +type resource = Tee of tee | Gpu of gpu (* Discrete resources *) + +(** Runtimes. + +A node has a runtime which is able to host functions of a specific +target based on the node's architecture. +*) + +type runtime = Wasm | Container | X86_64 (* What this node can host *) + +(** Functions. + +A function is an identified entity within a function repository. +*) + +module Function : sig + type t +end = struct + type t = { + fid : fid; + runtime : runtime; + repository : string; + } +end + + +(** Workflows. + +A workflow is an identified sequence of function calls. +*) + +module Workflow : sig + type t +end = struct + type t = { + wid : wid; + chain : Function.t list; + } +end + +(** Nodes. + +Nodes are identified entities that use resources and a runtime to host +functions, using a forwarding table to determine where to send the +output of a function according to the workflow to which the fnuction +belongs. +*) +module Node : sig + type t +end = struct + type t = { + nid : nid; + resources : cpu * memory * resource list; + runtime : runtime; + fwdt : fwdt; + } +end + +(** Orchestrators. + +An orchestrator -- e-orc -- is an ingress node plus a list of nodes that +can host functions. Ther eis one orchestrator per cluster of nodes. +*) + +module Orchestrator : sig + type t + + val start : t -> wid * Function.t -> t * (nid * fid) list + val stop : t -> nid * fid -> t + val update : t -> (nid * fwdt) list -> t +end = struct + type t = Ingress of fwdt * Node.t list + + let start eorc workflow_functions = (eorc, []) + let stop eorc node_id = eorc + let update eorc node_forwarding_tables = eorc +end + +(** Controllers. + +A controller -- e-con -- is an administrative domain contaiing a list of +orchestrators. Controllers process workflows, making requests of +orchestrators for the fnuctions required by a workflow to be +instantiated. +*) + +module Controller : sig + type t + + val start : t -> Workflow.t -> t * wid + val stop : t -> wid -> t +end = struct + type t = Orchestrator.t list + + let start econ workflow = (econ, -1) + let stop econ workflow_id = econ +end diff --git a/model/edgeless.mli b/model/edgeless.mli new file mode 100644 index 00000000..e69de29b From ae2fe5ae03637df25177d9b09b6df2c7ee92e755 Mon Sep 17 00:00:00 2001 From: Richard Mortier Date: Wed, 27 Sep 2023 18:53:15 +0200 Subject: [PATCH 2/2] model: fixing some things --- model/edgeless.ml | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/model/edgeless.ml b/model/edgeless.ml index 92191a21..54c75c6c 100644 --- a/model/edgeless.ml +++ b/model/edgeless.ml @@ -2,7 +2,9 @@ type nid = int (* Nodes *) type wid = int (* Workflows *) -type fid = int (* Functions*) +type fid = int (* Instantiated functions*) +type rid = string (* Repository identified *) +type alias = string (* Naming things *) (** Forwarding tables. @@ -12,7 +14,8 @@ function instances on other nodes with some priority for load balancing. *) type prio = int (* Entry priority, for load balancing *) -type fwde = (wid * fid) * ((nid * fid) * prio) list +type target = nid * fid (* Target for a function output *) +type fwde = (wid * fid) * (target * prio) list (* Forwarding table entries, the list of postential destination function instances with associated priorities corresponding to a function i nstance on this node *) @@ -40,32 +43,46 @@ target based on the node's architecture. type runtime = Wasm | Container | X86_64 (* What this node can host *) (** Functions. - -A function is an identified entity within a function repository. + +A function is a named entity within a function repository targeting a +particular runtime. *) module Function : sig type t +end = struct + type t = { repository : rid; alias : alias; runtime : runtime } +end + + +(** Function invocations. + +A function invocation is a named stage in a Workflow that may invoke one +or more output callbacks. + +*) +module Invocation : sig + type t end = struct type t = { - fid : fid; - runtime : runtime; - repository : string; + alias : alias; + func : Function.t; + outputs : Function.t list; } end (** Workflows. -A workflow is an identified sequence of function calls. +A workflow is a named list of function invocations, representing a DAG. *) module Workflow : sig type t end = struct type t = { - wid : wid; - chain : Function.t list; + alias: string; + functions: Invocation.t list; } end @@ -80,7 +97,6 @@ module Node : sig type t end = struct type t = { - nid : nid; resources : cpu * memory * resource list; runtime : runtime; fwdt : fwdt; @@ -123,6 +139,6 @@ module Controller : sig end = struct type t = Orchestrator.t list - let start econ workflow = (econ, -1) + let start econ workflow : t * wid = (econ, -1) let stop econ workflow_id = econ end