-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
batch-scheduler: move scheduling decisions to batch scheduler
- Loading branch information
1 parent
07da690
commit e22b97a
Showing
38 changed files
with
404 additions
and
363 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#pragma once | ||
|
||
#include <faabric/batch-scheduler/SchedulingDecision.h> | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
namespace faabric::batch_scheduler { | ||
/** | ||
* 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. | ||
*/ | ||
class CachedDecision | ||
{ | ||
public: | ||
CachedDecision(const std::vector<std::string>& hostsIn, int groupIdIn); | ||
|
||
std::vector<std::string> getHosts() { return hosts; } | ||
|
||
int getGroupId() const { return groupId; } | ||
|
||
private: | ||
std::vector<std::string> hosts; | ||
int groupId = 0; | ||
}; | ||
|
||
/** | ||
* 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. | ||
*/ | ||
class DecisionCache | ||
{ | ||
public: | ||
std::shared_ptr<CachedDecision> getCachedDecision( | ||
std::shared_ptr<faabric::BatchExecuteRequest> req); | ||
|
||
void addCachedDecision(std::shared_ptr<BatchExecuteRequest> req, | ||
SchedulingDecision& decision); | ||
|
||
void clear(); | ||
|
||
private: | ||
std::string getCacheKey(std::shared_ptr<BatchExecuteRequest> req); | ||
|
||
std::unordered_map<std::string, std::shared_ptr<CachedDecision>> | ||
cachedDecisions; | ||
}; | ||
|
||
DecisionCache& getSchedulingDecisionCache(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.