1/* @ajax/mesh-sched-score: Nomad-style feasibility, then score (sched.rs). `msc_filter` gives the
2 * executor a program would run on at a member, or the first reason it cannot run there;
3 * `msc_score_terms` the weighted terms of running it there: the processor share it would get times
4 * its measured speed, CPU headroom after the move, memory headroom, spread or pack, link RTT
5 * (groups), prefer, stickiness for the current member, and the owner penalty.
6 *
7 * Other schedulers (the jobs' leases) use `msc_eligible`, `msc_filter`, `msc_score` and
8 * `msc_explain` directly. */
9#ifndef MESH_SCHED_SCORE_H
10#define MESH_SCHED_SCORE_H
1112#include "mesh/sched_member.h"
13#include "mesh/sched_needs.h"
14#include "mesh/sched_weights.h"
1516#include <stdbool.h>
17#include <stdint.h>
1819/* The executor n would run on at m (written to exec, 16 bytes), or false with *err the reason. */
20bool msc_filter(const msm_member *m, const mesh_needs *n, char exec[16], char **err);
21/* Whether n may run on m at all (the reservations and colocation aside). */
22bool msc_eligible(const msm_member *m, const mesh_needs *n);
2324/* A score's terms (each already weighted) and their sum. */
25typedef struct {
26 char exec[16];
27 double total, perf, load, mem, spread, rtt, prefer, sticky, owner;
28 bool explore; /* the speed is a prior (nothing measured on this member yet) */
29 mof32 share; /* the raw figures behind the terms */
30 mof32 task_us;
31 float cpu_after;
32} msc_score_t;
3334/* "0.812 = perf 0.50 load 0.54 ... (cuda, gpu share 0.50, cpu after 0.10)": a new string. */
35char *msc_explain(const msc_score_t *s);
3637/* What a score depends on beyond the member and the needs. */
38typedef struct {
39 const msw_weights *w;
40 bool current; /* it runs on this member now (no load to add; the sticky bonus) */
41 const msm_perf *here; /* its measured performance here (NULL: none) ... */
42 mof32 best_task_us; /* ... and the best measured time per task anywhere */
43 float own_cpu; /* the CPU cores it uses (measured where it runs, else its reservation) */
44 uint32_t placed, max_placed; /* programs already on this member, and the most on any (spread / pack) */
45 mof32 rtt_ms; /* the mean RTT to its partners in ms (a group); none: not scored */
46} msc_cx;
4748msc_cx msc_cx_simple(const msw_weights *w, const msm_perf *here);
49/* The score terms of running n on m (it passed msc_filter). */
50msc_score_t msc_score_terms(const msm_member *m, const mesh_needs *n, const msc_cx *cx);
51/* The plain score of n on m (no placement context). */
52double msc_score(const msm_member *m, const mesh_needs *n, const msm_perf *here, const msw_weights *w);
5354#endif