1/* @ajax/mesh-peer-view: two small pieces of the fleet thread's scheduler glue (peer_sched.rs):
2 * - a view the target of a migration asked its source for, arriving as F_VIEW chunks: the total must
3 * not pass the program's view (`limit`) and must not change between chunks, a chunk must not pass the
4 * total, and a duplicate chunk counts once (review finding 11);
5 * - a member's load smoothed over its samples (one a second, ~5 samples' time constant), so a
6 * tenant's one-second spike does not look like a busy member to the rebalancer. */
7#ifndef MESH_PEER_VIEW_H
8#define MESH_PEER_VIEW_H
910#include "mesh/range_set.h"
11#include "mesh/sched_member.h"
1213#include <stdbool.h>
14#include <stddef.h>
15#include <stdint.h>
1617typedef struct {
18 uint32_t from;
19 uint64_t deadline;
20 uint8_t *buf;
21 bool has_total;
22 size_t total; /* the view's size as the first chunk said */
23 size_t limit;
24 rs_set have; /* the byte ranges received */
25} mpv_wait;
2627mpv_wait mpv_wait_new(uint32_t from, uint64_t deadline, size_t limit);
28void mpv_wait_free(mpv_wait *w);
29/* A chunk: 1 when the view is whole, 0 when not yet, -1 with *err when the chunks do not make one. */
30int mpv_take(mpv_wait *w, uint32_t total, uint32_t off, const uint8_t *b, size_t n, char **err);
3132#define MPV_LOAD_ALPHA 0.2f
3334typedef struct {
35 uint64_t at;
36 float cpu;
37 mof32 psi_cpu, psi_mem, share;
38} mpv_load;
3940void mpv_load_add(mpv_load *l, uint64_t at, float cpu, mof32 psi_cpu, mof32 psi_mem, mof32 share);
4142#endif