wrench::ServerlessSchedulingState

class ServerlessSchedulingState

A class to encode a “scheduling state”, that is a clone of the system state that a scheduler can work with and modify at will for planning purposes.

Public Functions

explicit ServerlessSchedulingState(const ServerlessStateOfTheSystem *state)

Constructor.

Parameters:

state – current system state

bool areAllImageLayersInRAM(const std::shared_ptr<Image> &image, const std::shared_ptr<ServerlessComputeNode> &node) const

Are all layers of an image in RAM at a compute node?

Helper Functions

Parameters:
  • image – an image

  • node – the compute node

Returns:

True if all necessary layers are in RAM

bool areAllImageLayersInRAMOrOnTheirWayToRAM(const std::shared_ptr<Image> &image, const std::shared_ptr<ServerlessComputeNode> &node) const

Are all layers either in ram or on their way to ram at a compute node?

Parameters:
  • image – an image

  • node – the compute node

Returns:

True or false

bool areAllImageLayersOnDisk(const std::shared_ptr<Image> &image, const std::shared_ptr<ServerlessComputeNode> &node) const

Are all layers either on disk or on their way to ram at a compute node?

Parameters:
  • image – an image

  • node – the compute node

Returns:

True or false

bool areAllImageLayersOnDiskOrOnTheirWayToDisk(const std::shared_ptr<Image> &image, const std::shared_ptr<ServerlessComputeNode> &node) const

Are all layers either on disk or on their way to ram at a compute node?

Parameters:
  • image – an image

  • node – the compute node

Returns:

True or false

bool areAllImageLayersOnDiskOrOnTheirWayToRAM(const std::shared_ptr<Image> &image, const std::shared_ptr<ServerlessComputeNode> &node) const

Are all layers either on disk or on their way to ram at a compute node?

Parameters:
  • image – an image

  • node – the compute node

Returns:

True or false

void excludeNodeFromPlanning(const std::shared_ptr<ServerlessComputeNode> &node)

Exclude a compute node from all future planning.

Parameters:

node –

const std::vector<std::shared_ptr<ServerlessComputeNode>> &getActivatedComputeNodes()

Get the activated compute nodes.

Returns:

A list of compute nodes

const std::map<std::shared_ptr<Image>, std::vector<std::shared_ptr<Invocation>>> &getAdmittedInvocations() const

Get the admitted invocations (images not yet downloaded to the head node).

Accessor Functions

Returns:

A (reference to) the map of admitted invocations (keyed by Image)

sg_size_t getDiskSpaceAvailable(const std::shared_ptr<ServerlessComputeNode> &node) const

Get the disk space (in bytes) available at a compute node.

Parameters:

node – A compute node

Returns:

A number of bytes

std::set<std::shared_ptr<Container>> getIdleContainersAtComputeNode(const std::shared_ptr<ServerlessComputeNode> &node) const

Get the set of idle containers at a compute node.

Parameters:

node – the compute node

Returns:

a set of idle containers

const std::set<std::shared_ptr<ImageLayer>> &getImageLayersInRAM(const std::shared_ptr<ServerlessComputeNode> &node)

Get the image layers in RAM at a compute node.

Parameters:

node – A compute node

Returns:

A set of image layers

const std::set<std::shared_ptr<ImageLayer>> &getImageLayersOnDisk(const std::shared_ptr<ServerlessComputeNode> &node)

Get the image layers on disk at a compute node.

Parameters:

node – A compute node

Returns:

A set of image layers

const std::set<std::shared_ptr<ImageLayer>> &getImageLayersOnTheirWayToDisk(const std::shared_ptr<ServerlessComputeNode> &node)

Get the image layers on their way to disk at a compute node.

Parameters:

node – A compute node

Returns:

A set of image layers

const std::set<std::shared_ptr<ImageLayer>> &getImageLayersOnTheirWayToRAM(const std::shared_ptr<ServerlessComputeNode> &node) const

Get the image layers on their way to RAM at a compute node.

Parameters:

node – A compute node

Returns:

A set of image layers

const std::set<std::shared_ptr<Container>> &getInitializedContainers(const std::shared_ptr<ServerlessComputeNode> &node)

Get the initialized containers at a compute node.

Parameters:

node – A compute node

Returns:

A set of containers

const std::set<std::shared_ptr<Container>> &getInitializingContainers(const std::shared_ptr<ServerlessComputeNode> &node)

Get the initializing containers at a compute node.

Parameters:

node – A compute node

Returns:

A set of containers

unsigned long getNumBeingActivatedComputeNodes() const

Get the number of compute nodes that are being activated.

Returns:

A number of nodes

unsigned long getNumDeactivatedComputeNodes() const

Get the number of deactivated compute nodes.

Returns:

A number of nodes

unsigned long getNumInFlightInvocationsOnContainer(const std::shared_ptr<Container> &container) const

Get the number of (planned) in-flight invocations at a container.

Parameters:

container – A container

Returns:

A number of invocations

unsigned long getNumPossibleNewContainersAtComputeNode(const std::shared_ptr<ServerlessComputeNode> &node) const

Get the number of possible new containers at a compute node.

Parameters:

node – A compute node

Returns:

A remaining container capacity in this planning snapshot

unsigned long getNumPossibleNewInvocationsAtComputeNode(const std::shared_ptr<ServerlessComputeNode> &node) const

Get the node capacity remaining for invocation selections in this round.

Starts with the node’s invocation limit minus its observed in-flight invocations. Selected dispatches, image preparations, and waits for image preparation each consume one unit during planning.

Parameters:

node – A compute node

Returns:

A remaining invocation capacity in this planning snapshot

unsigned long getNumPossibleNewInvocationsOnContainer(const std::shared_ptr<Container> &container) const

Get the number of possible new invocations on a container.

Parameters:

container – A container

Returns:

A remaining invocation capacity in this planning snapshot

const std::map<std::shared_ptr<Function>, unsigned long> &getPendingInvocationCounts() const

Get the pending invocation counts.

Returns:

The map of pending invocations

const std::set<std::shared_ptr<ImageLayer>> &getProtectedImageLayers(const std::shared_ptr<ServerlessComputeNode> &node)

Get the protected image layers at a compute node.

Parameters:

node – A compute node

Returns:

A set of image layers

sg_size_t getRAMSpaceAvailable(const std::shared_ptr<ServerlessComputeNode> &node) const

Get the RAM space (in bytes) available at a compute node.

Parameters:

node – A compute node

Returns:

A number of bytes

std::vector<std::shared_ptr<Invocation>> &getSchedulableInvocations()

Get the schedulable invocations.

Returns:

A (reference to) the list of schedulable invocations

void planContainerPrewarm(const std::shared_ptr<ServerlessComputeNode> &node, const std::shared_ptr<Function> &function)

Plan for a container prewarm.

Parameters:

node – The compute node at which to prewarm a container

void planIdleContainerTermination(const std::shared_ptr<ServerlessComputeNode> &node, const std::shared_ptr<Container> &container)

Plan for the termination of an idle container.

Parameters:

container – the container

void planInvocationDispatch(const std::shared_ptr<Invocation> &inv, const std::shared_ptr<ServerlessComputeNode> &node, const std::shared_ptr<Container> &container)

Plan for a new invocation.

Parameters:
  • inv – The invocation to place

  • node – The node on which to place it

  • container – The container to use (if non-nullptr)

void planInvocationFailures(const std::set<std::shared_ptr<Invocation>> &invocations)

Plan to fail some invocations.

Parameters:

invocations – A set of invocations to fail

void planLayerEvictionFromDisk(const std::shared_ptr<ServerlessComputeNode> &node, const std::shared_ptr<ImageLayer> &layer)

Plan a layer eviction from Disk.

Parameters:
  • node – The compute node where the eviction will take place

  • layer – The layer that will be evicted

void planLayerEvictionFromRAM(const std::shared_ptr<ServerlessComputeNode> &node, const std::shared_ptr<ImageLayer> &layer)

Plan a layer eviction from RAM.

Parameters:
  • node – The compute node where the eviction will take place

  • layer – The layer that will be evicted

void planLayerLoadToRAM(const std::shared_ptr<ServerlessComputeNode> &node, const std::shared_ptr<ImageLayer> &layer)

Plan for a layer load to RAM.

Parameters:
  • node – The node at which to load

  • layer – The layer to load

void planLayerStagingToDisk(const std::shared_ptr<ServerlessComputeNode> &node, const std::shared_ptr<ImageLayer> &layer)

Plan for a layer staging to disk.

Parameters:
  • node – The node at which to stage

  • layer – The layer to stage

void protectImageLayers(const std::shared_ptr<ServerlessComputeNode> &node, const std::shared_ptr<Image> &image)

Make all of an image’s layer protected at a compute node.

Parameters:
  • node – The compute node

  • image – The image

void reserveInvocationSlot(const std::shared_ptr<ServerlessComputeNode> &node)

Claim one unit of a node’s invocation capacity in this planning round.

Update this planning snapshot after operations or waiting choices have been selected.

These methods do not select operations, append scheduling decisions, execute simulated work, or modify runtime objects. The caller appends any required runtime operations separately. Capacity claims and layer protection may account for a waiting choice that emits no operation.

Updates only the planning snapshot. Does not assign an invocation to the node, reserve a container or its private resources, change pending invocation counts, or append a scheduling decision.

Each invocation selecting a node must consume exactly one unit of node capacity. Do not make a separate claim if dispatch accounting already includes it.

Parameters:

node – A compute node