1/* @ajax/mesh-sched-weights: the fleet scheduler's score weights and rebalancing policy
2 * (sched.rs Weights): the defaults, and the cluster config's `sched_*` keys over them. */
3#ifndef MESH_SCHED_WEIGHTS_H
4#define MESH_SCHED_WEIGHTS_H
56#include "mesh/strmap.h"
78#include <stdbool.h>
9#include <stdint.h>
1011typedef struct {
12 double perf, load, mem, spread, rtt, prefer, sticky, owner;
13 /* A move needs the alternative to score this much better (0.25: 25 %) ... */
14 double improve;
15 /* ... for this long in a row. */
16 uint64_t hold_ms;
17 /* A program moved stays at least this long. */
18 uint64_t dwell_ms;
19 /* Migrations a minute, at most. */
20 uint32_t per_min;
21 /* A member down this long loses its placements (rides out link blips). */
22 uint64_t replace_ms;
23 /* The owner policy: share under / PSI over these for owner_ms makes a member busy. */
24 float owner_share, owner_psi;
25 uint64_t owner_ms;
26 /* The rebalancer's period. */
27 uint64_t tick_ms;
28 /* The CPU and memory left out of every member's reservation budget. */
29 float reserve;
30} msw_weights;
3132msw_weights msw_default(void);
33/* The keys sched_improve, sched_hold_ms, sched_dwell_ms, sched_per_min, sched_replace_ms,
34 * sched_owner_share, sched_owner_psi, sched_owner_ms, sched_tick_ms (at least 100) and
35 * sched_reserve over the defaults. On error *err is the Rust's message. */
36bool msw_from_keys(const ms_map *keys, msw_weights *out, char **err);
37bool msw_eq(const msw_weights *a, const msw_weights *b);
3839#endif