Skip to content

Commit

Permalink
Remove dead SchedulingResources class (ray-project#33250)
Browse files Browse the repository at this point in the history
Signed-off-by: Jiajun Yao <jeromeyjj@gmail.com>
Signed-off-by: elliottower <elliot@elliottower.com>
  • Loading branch information
jjyao authored and elliottower committed Apr 22, 2023
1 parent 6bb9199 commit 3f6820d
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 269 deletions.
53 changes: 0 additions & 53 deletions src/mock/ray/gcs/gcs_server/gcs_resource_scheduler.h

This file was deleted.

105 changes: 0 additions & 105 deletions src/ray/common/task/scheduling_resources.cc
Original file line number Diff line number Diff line change
Expand Up @@ -250,109 +250,4 @@ const absl::flat_hash_map<std::string, FixedPoint> &ResourceSet::GetResourceAmou
return resource_capacity_;
};

/// SchedulingResources class implementation

SchedulingResources::SchedulingResources()
: resources_total_(ResourceSet()),
resources_available_(ResourceSet()),
resources_load_(ResourceSet()) {}

SchedulingResources::SchedulingResources(const ResourceSet &total)
: resources_total_(total),
resources_available_(total),
resources_load_(ResourceSet()) {}

SchedulingResources::~SchedulingResources() {}

const ResourceSet &SchedulingResources::GetAvailableResources() const {
return resources_available_;
}

void SchedulingResources::SetAvailableResources(ResourceSet &&newset) {
resources_available_ = newset;
}

const ResourceSet &SchedulingResources::GetTotalResources() const {
return resources_total_;
}

void SchedulingResources::SetTotalResources(ResourceSet &&newset) {
resources_total_ = newset;
}

const ResourceSet &SchedulingResources::GetLoadResources() const {
return resources_load_;
}

void SchedulingResources::SetLoadResources(ResourceSet &&newset) {
resources_load_ = newset;
}

// Return specified resources back to SchedulingResources.
void SchedulingResources::Release(const ResourceSet &resources) {
return resources_available_.AddResourcesCapacityConstrained(resources,
resources_total_);
}

// Take specified resources from SchedulingResources.
void SchedulingResources::Acquire(const ResourceSet &resources) {
resources_available_.SubtractResourcesStrict(resources);
}

// The reason we need this method is sometimes we may want add some converted
// resource which is not exist in total resource to the available resource.
// (e.g., placement group)
void SchedulingResources::AddResource(const ResourceSet &resources) {
resources_total_.AddResources(resources);
resources_available_.AddResources(resources);
}

void SchedulingResources::UpdateResourceCapacity(const std::string &resource_name,
int64_t capacity) {
const FixedPoint new_capacity = FixedPoint(capacity);
const FixedPoint &current_capacity = resources_total_.GetResource(resource_name);
if (current_capacity > 0) {
// If the resource exists, add to total and available resources
const FixedPoint capacity_difference = new_capacity - current_capacity;
const FixedPoint &current_available_capacity =
resources_available_.GetResource(resource_name);
FixedPoint new_available_capacity = current_available_capacity + capacity_difference;
if (new_available_capacity < 0) {
new_available_capacity = 0;
}
resources_total_.AddOrUpdateResource(resource_name, new_capacity);
resources_available_.AddOrUpdateResource(resource_name, new_available_capacity);
} else {
// Resource does not exist, just add it to total and available. Do not add to load.
resources_total_.AddOrUpdateResource(resource_name, new_capacity);
resources_available_.AddOrUpdateResource(resource_name, new_capacity);
}
}

void SchedulingResources::DeleteResource(const std::string &resource_name) {
resources_total_.DeleteResource(resource_name);
resources_available_.DeleteResource(resource_name);
resources_load_.DeleteResource(resource_name);
}

const ResourceSet &SchedulingResources::GetNormalTaskResources() const {
return resources_normal_tasks_;
}

void SchedulingResources::SetNormalTaskResources(const ResourceSet &newset) {
resources_normal_tasks_ = newset;
}

std::string SchedulingResources::DebugString() const {
std::stringstream result;

auto resources_available = resources_available_;
resources_available.SubtractResources(resources_normal_tasks_);

result << "\n- total: " << resources_total_.ToString();
result << "\n- avail: " << resources_available.ToString();
result << "\n- normal task usage: " << resources_normal_tasks_.ToString();
return result.str();
};

} // namespace ray
111 changes: 0 additions & 111 deletions src/ray/common/task/scheduling_resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,117 +177,6 @@ class ResourceSet {
absl::flat_hash_map<std::string, FixedPoint> resource_capacity_;
};

/// \class SchedulingResources
/// SchedulingResources class encapsulates the state of all local resources and
/// manages accounting of those resources. Resources include configured resource
/// bundle capacity, and GPU allocation map.
class SchedulingResources {
public:
/// SchedulingResources constructor: sets configured and available resources
/// to an empty set.
SchedulingResources();

/// SchedulingResources constructor: sets available and configured capacity
/// to the resource set specified.
///
/// \param total: The amount of total configured capacity.
SchedulingResources(const ResourceSet &total);

/// \brief SchedulingResources destructor.
~SchedulingResources();

/// \brief Request the set and capacity of resources currently available.
///
/// \return Immutable set of resources with currently available capacity.
const ResourceSet &GetAvailableResources() const;

/// \brief Overwrite available resource capacity with the specified resource set.
///
/// \param newset: The set of resources that replaces available resource capacity.
/// \return Void.
void SetAvailableResources(ResourceSet &&newset);

/// \brief Request the total resources capacity.
///
/// \return Immutable set of resources with currently total capacity.
const ResourceSet &GetTotalResources() const;

/// \brief Overwrite total resource capacity with the specified resource set.
///
/// \param newset: The set of resources that replaces total resource capacity.
/// \return Void.
void SetTotalResources(ResourceSet &&newset);

/// \brief Request the resource load information.
///
/// \return Immutable set of resources describing the load information.
const ResourceSet &GetLoadResources() const;

/// \brief Overwrite information about resource load with new resource load set.
///
/// \param newset: The set of resources that replaces resource load information.
/// \return Void.
void SetLoadResources(ResourceSet &&newset);

/// \brief Release the amount of resources specified.
///
/// \param resources: the amount of resources to be released.
/// \return Void.
void Release(const ResourceSet &resources);

/// \brief Acquire the amount of resources specified.
///
/// \param resources: the amount of resources to be acquired.
/// \return Void.
void Acquire(const ResourceSet &resources);

/// \brief Add a new resource to available resource.
///
/// \param resources: the amount of resources to be added.
/// \return Void.
void AddResource(const ResourceSet &resources);

/// Returns debug string for class.
///
/// \return string.
std::string DebugString() const;

/// \brief Update total, available and load resources with the specified capacity.
/// Create if not exists.
///
/// \param resource_name: Name of the resource to be modified
/// \param capacity: New capacity of the resource.
/// \return Void.
void UpdateResourceCapacity(const std::string &resource_name, int64_t capacity);

/// \brief Delete resource from total, available and load resources.
///
/// \param resource_name: Name of the resource to be deleted.
/// \return Void.
void DeleteResource(const std::string &resource_name);

/// \brief Get the resources used by normal tasks.
///
/// \return Resources used by normal tasks.
const ResourceSet &GetNormalTaskResources() const;

/// \brief Set the amount of resources used by normal tasks.
///
/// \param newset: The new resource set to update.
/// \return Void.
void SetNormalTaskResources(const ResourceSet &newset);

private:
/// Static resource configuration (e.g., static_resources).
ResourceSet resources_total_;
/// Dynamic resource capacity (e.g., dynamic_resources).
ResourceSet resources_available_;
/// Resource load.
ResourceSet resources_load_;
/// Resources used by normal tasks.
ResourceSet resources_normal_tasks_;
};

std::string format_resource(std::string resource_name, double quantity);

} // namespace ray
Expand Down

0 comments on commit 3f6820d

Please sign in to comment.