Namespace faabric::batch_scheduler

namespace batch_scheduler

Typedefs

typedef std::pair<std::shared_ptr<BatchExecuteRequest>, std::shared_ptr<SchedulingDecision>> InFlightPair
typedef std::map<int32_t, InFlightPair> InFlightReqs
typedef std::shared_ptr<HostState> Host
typedef std::map<std::string, Host> HostMap

Enums

enum DecisionType

Values:

enumerator NO_DECISION_TYPE
enumerator NEW
enumerator DIST_CHANGE
enumerator SCALE_CHANGE
enum SchedulingTopologyHint

Values:

enumerator NONE
enumerator CACHED
enumerator FORCE_LOCAL
enumerator NEVER_ALONE
enumerator UNDERFULL
enum MigrationStrategy

Values:

enumerator BIN_PACK
enumerator EMPTY_HOSTS

Functions

std::shared_ptr<BatchScheduler> getBatchScheduler()
void resetBatchScheduler()
void resetBatchScheduler(const std::string &newMode)
DecisionCache &getSchedulingDecisionCache()
static std::map<std::string, int> getHostFreqCount(std::shared_ptr<SchedulingDecision> decision)
static std::shared_ptr<SchedulingDecision> minimiseNumOfMigrations(std::shared_ptr<SchedulingDecision> newDecision, std::shared_ptr<SchedulingDecision> oldDecision)
static std::map<std::string, int> getHostFreqCount(std::shared_ptr<SchedulingDecision> decision)
static std::shared_ptr<SchedulingDecision> minimiseNumOfMigrations(std::shared_ptr<SchedulingDecision> newDecision, std::shared_ptr<SchedulingDecision> oldDecision)
static HostMap deepCopyHostMap(const HostMap &hostMap)
static void filterHosts(HostMap &hostMap, const InFlightReqs &inFlightReqs, std::shared_ptr<faabric::BatchExecuteRequest> req)
static std::map<std::string, int> getHostFreqCount(std::shared_ptr<SchedulingDecision> decision)
static std::shared_ptr<SchedulingDecision> minimiseNumOfMigrations(std::shared_ptr<SchedulingDecision> newDecision, std::shared_ptr<SchedulingDecision> oldDecision)
static std::set<std::string> filterHosts(HostMap &hostMap)

Variables

const std::unordered_map<std::string, SchedulingTopologyHint> strToTopologyHint = {{"NONE", SchedulingTopologyHint::NONE}, {"CACHED", SchedulingTopologyHint::CACHED}, {"FORCE_LOCAL", SchedulingTopologyHint::FORCE_LOCAL}, {"NEVER_ALONE", SchedulingTopologyHint::NEVER_ALONE}, {"UNDERFULL", SchedulingTopologyHint::UNDERFULL},}
const std::unordered_map<SchedulingTopologyHint, std::string> topologyHintToStr = {{SchedulingTopologyHint::NONE, "NONE"}, {SchedulingTopologyHint::CACHED, "CACHED"}, {SchedulingTopologyHint::FORCE_LOCAL, "FORCE_LOCAL"}, {SchedulingTopologyHint::NEVER_ALONE, "NEVER_ALONE"}, {SchedulingTopologyHint::UNDERFULL, "UNDERFULL"},}
static std::shared_ptr<BatchScheduler> batchScheduler = nullptr
class BatchScheduler

Subclassed by faabric::batch_scheduler::BinPackScheduler, faabric::batch_scheduler::CompactScheduler, faabric::batch_scheduler::SpotScheduler

Public Functions

virtual std::shared_ptr<SchedulingDecision> makeSchedulingDecision(HostMap &hostMap, const InFlightReqs &inFlightReqs, std::shared_ptr<faabric::BatchExecuteRequest> req) = 0

Public Static Functions

static DecisionType getDecisionType(const InFlightReqs &inFlightReqs, std::shared_ptr<faabric::BatchExecuteRequest> req)
class BinPackScheduler : public faabric::batch_scheduler::BatchScheduler

Public Functions

virtual std::shared_ptr<SchedulingDecision> makeSchedulingDecision(HostMap &hostMap, const InFlightReqs &inFlightReqs, std::shared_ptr<faabric::BatchExecuteRequest> req) override
class CachedDecision
#include <DecisionCache.h>

A record of a decision already taken for the given size of batch request for the given function. This doesn’t contain the messages themselves, just the hosts and group ID that was used.

Public Functions

CachedDecision(const std::vector<std::string> &hostsIn, int groupIdIn)
inline std::vector<std::string> getHosts()
inline int getGroupId() const
class CompactScheduler : public faabric::batch_scheduler::BatchScheduler

Public Functions

virtual std::shared_ptr<SchedulingDecision> makeSchedulingDecision(HostMap &hostMap, const InFlightReqs &inFlightReqs, std::shared_ptr<faabric::BatchExecuteRequest> req) override
class DecisionCache
#include <DecisionCache.h>

Repository for cached scheduling decisions. Object is not thread safe as we assume only a single executor will be caching decisions for a given function and size of batch request on one host at a time.

Public Functions

std::shared_ptr<CachedDecision> getCachedDecision(std::shared_ptr<faabric::BatchExecuteRequest> req)
void addCachedDecision(std::shared_ptr<BatchExecuteRequest> req, SchedulingDecision &decision)
void clear()
struct HostState

Public Functions

inline HostState(const std::string &ipIn, int slotsIn, int usedSlotsIn)

Public Members

std::string ip
int slots
int usedSlots
class SchedulingDecision

Public Functions

SchedulingDecision(uint32_t appIdIn, int32_t groupIdIn)
bool operator==(const SchedulingDecision &rhs) const = default
bool isSingleHost() const

Work out if this decision is all in one host. If the decision is completely on another host, we still count it as not being on a single host, as this host will be the main.

Will always return false if single host optimisations are switched off.

void addMessage(const std::string &host, const faabric::Message &msg)
void addMessage(const std::string &host, int32_t messageId, int32_t appIdx)
void addMessage(const std::string &host, int32_t messageId, int32_t appIdx, int32_t groupIdx)
void addMessageInPosition(int32_t pos, const std::string &host, int32_t messageId, int32_t appIdx, int32_t groupIdx, int32_t mpiPort)
int32_t removeMessage(int32_t messageId)
std::set<std::string> uniqueHosts()
void print(const std::string &logLevel = "debug")

Public Members

uint32_t appId = 0
int32_t groupId = 0
int32_t nFunctions = 0
std::vector<std::string> hosts
std::vector<int32_t> messageIds
std::vector<int32_t> appIdxs
std::vector<int32_t> groupIdxs
std::vector<int32_t> mpiPorts
std::string returnHost

Public Static Functions

static SchedulingDecision fromPointToPointMappings(faabric::PointToPointMappings &mappings)
class SpotScheduler : public faabric::batch_scheduler::BatchScheduler

Public Functions

virtual std::shared_ptr<SchedulingDecision> makeSchedulingDecision(HostMap &hostMap, const InFlightReqs &inFlightReqs, std::shared_ptr<faabric::BatchExecuteRequest> req) override