OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ExecutorResourceMgr_Namespace::ResourceGrantPolicy Struct Reference

Specifies the policy for granting a resource of a specific ResourceSubtype. Note that this policy only pertains to resource grants on an isolated basis, and that grant policy with respect to concurrent requests is controlled by ConcurrentResourceGrantPolicy. More...

#include <ResourceGrantPolicy.h>

+ Collaboration diagram for ExecutorResourceMgr_Namespace::ResourceGrantPolicy:

Public Member Functions

 ResourceGrantPolicy ()
 
 ResourceGrantPolicy (const ResourceSubtype resource_subtype, const ResourceGrantPolicySizeType policy_size_type, const ResourceGrantSizeInfo size_info)
 
size_t get_grant_quantity (const size_t total_resource_quantity) const
 Used to calculate the maximum quantity that can be granted of the resource. More...
 
size_t get_grant_quantity (const size_t total_resource_quantity, const bool cap_at_total_available) const
 Used to calculate the maximum quantity that can be granted of the resource, optionally capping at the specified total_resource_quantity . More...
 
std::string to_string () const
 

Public Attributes

ResourceSubtype resource_subtype {ResourceSubtype::INVALID_SUBTYPE}
 
ResourceGrantPolicySizeType policy_size_type {ResourceGrantPolicySizeType::CONSTANT}
 
ResourceGrantSizeInfo size_info
 

Detailed Description

Specifies the policy for granting a resource of a specific ResourceSubtype. Note that this policy only pertains to resource grants on an isolated basis, and that grant policy with respect to concurrent requests is controlled by ConcurrentResourceGrantPolicy.

ExecutorResourcePool uses get_grant_quantity to determine the maximum allowable grants for each type of resource (on a static basis) when being initialized.

Definition at line 47 of file ResourceGrantPolicy.h.

Constructor & Destructor Documentation

ExecutorResourceMgr_Namespace::ResourceGrantPolicy::ResourceGrantPolicy ( )
inline

Definition at line 52 of file ResourceGrantPolicy.h.

52 {}
ExecutorResourceMgr_Namespace::ResourceGrantPolicy::ResourceGrantPolicy ( const ResourceSubtype  resource_subtype,
const ResourceGrantPolicySizeType  policy_size_type,
const ResourceGrantSizeInfo  size_info 
)

Member Function Documentation

size_t ExecutorResourceMgr_Namespace::ResourceGrantPolicy::get_grant_quantity ( const size_t  total_resource_quantity) const

Used to calculate the maximum quantity that can be granted of the resource.

If policy_size_type is a ratio, the max grantable quantity will be the ratio specified in the size_info union times the specified total_resource_quantity. If policy_size_type is a constant, the max grantable quantity will be that constant, regardless of what is specified by total_resource_quantity. If policy_size_type is unlimited, the max grantable quantity will be unlimited, specifically the max allowed number for the size_t type.

Parameters
total_resource_quantity- the total quantity available of the resource specified by ResourceGrantPolicy::resource_subtype
Returns
size_t - The max quantity of the resource specified by ResourceGrantPolicy::resource_subtype that can be granted

Definition at line 34 of file ResourceGrantPolicy.cpp.

References ExecutorResourceMgr_Namespace::CONSTANT, ExecutorResourceMgr_Namespace::ResourceGrantSizeInfo::constant, policy_size_type, ExecutorResourceMgr_Namespace::RATIO_TO_TOTAL, ExecutorResourceMgr_Namespace::ResourceGrantSizeInfo::ratio_to_total, size_info, ExecutorResourceMgr_Namespace::UNLIMITED, and UNREACHABLE.

Referenced by get_grant_quantity().

35  {
36  switch (policy_size_type) {
38  return std::numeric_limits<size_t>::max();
40  return size_info.constant;
42  return static_cast<size_t>(
43  ceil(size_info.ratio_to_total * total_resource_quantity));
44  default:
45  UNREACHABLE();
46  }
47  UNREACHABLE();
48  return std::numeric_limits<size_t>::max();
49 }
#define UNREACHABLE()
Definition: Logger.h:338

+ Here is the caller graph for this function:

size_t ExecutorResourceMgr_Namespace::ResourceGrantPolicy::get_grant_quantity ( const size_t  total_resource_quantity,
const bool  cap_at_total_available 
) const

Used to calculate the maximum quantity that can be granted of the resource, optionally capping at the specified total_resource_quantity .

If policy_size_type is a ratio, the max grantable quantity will be the ratio specified in the size_info union times the specified total_resource_quantity. If policy_size_type is a constant, the max grantable quantity will be that constant, regardless of what is specified by total_resource_quantity. If policy_size_type is unlimited, the max grantable quantity will be unlimited, specifically the max allowed number for the size_t type. Regardless of the above, if cap_at_total_available is set to true, then the return size will be the minimum of the above and total_resource_quantity. This flag is used by ExecutorResourcePool::init_max_resource_grants_per_requests() if oversubscription is not allowed (ResourceConcurrencyPolicy::DISALLOW_REQUESTS) as specified by `ConcurrentResourceGrantPolicy::oversubscription_concurrency_policy)

Parameters
total_resource_quantity- the total quantity available of the resource specified by ResourceGrantPolicy::resource_subtype
Returns
size_t - The max quantity of the resource specified by ResourceGrantPolicy::resource_subtype that can be granted

Definition at line 52 of file ResourceGrantPolicy.cpp.

References get_grant_quantity().

53  {
54  const size_t max_per_query_grant_without_cap =
55  get_grant_quantity(total_resource_quantity);
56  if (cap_at_total_available) {
57  return std::min(max_per_query_grant_without_cap, total_resource_quantity);
58  }
59  return max_per_query_grant_without_cap;
60 }
size_t get_grant_quantity(const size_t total_resource_quantity) const
Used to calculate the maximum quantity that can be granted of the resource.

+ Here is the call graph for this function:

std::string ExecutorResourceMgr_Namespace::ResourceGrantPolicy::to_string ( ) const

Definition at line 62 of file ResourceGrantPolicy.cpp.

References ExecutorResourceMgr_Namespace::CONSTANT, ExecutorResourceMgr_Namespace::ResourceGrantSizeInfo::constant, policy_size_type, ExecutorResourceMgr_Namespace::RATIO_TO_TOTAL, ExecutorResourceMgr_Namespace::ResourceGrantSizeInfo::ratio_to_total, resource_subtype, ExecutorResourceMgr_Namespace::ResourceSubtypeStrings, size_info, ExecutorResourceMgr_Namespace::UNLIMITED, and UNREACHABLE.

Referenced by ExecutorResourceMgr_Namespace::ExecutorResourcePool::log_parameters().

62  {
63  std::ostringstream oss;
64  oss << "RESOURCE TYPE: "
65  << ResourceSubtypeStrings[static_cast<size_t>(resource_subtype)] << " ";
66  switch (policy_size_type) {
68  oss << "SIZE TYPE: Unlimited";
69  break;
71  oss << "SIZE TYPE: Constant (" << size_info.constant << ")";
72  break;
74  oss << "SIZE TYPE: Ratio-to-total (" << size_info.ratio_to_total << ")";
75  break;
76  default:
77  UNREACHABLE();
78  }
79  return oss.str();
80 }
#define UNREACHABLE()
Definition: Logger.h:338
static const char * ResourceSubtypeStrings[]

+ Here is the caller graph for this function:

Member Data Documentation

ResourceGrantPolicySizeType ExecutorResourceMgr_Namespace::ResourceGrantPolicy::policy_size_type {ResourceGrantPolicySizeType::CONSTANT}

Definition at line 49 of file ResourceGrantPolicy.h.

Referenced by get_grant_quantity(), and to_string().

ResourceSubtype ExecutorResourceMgr_Namespace::ResourceGrantPolicy::resource_subtype {ResourceSubtype::INVALID_SUBTYPE}

Definition at line 48 of file ResourceGrantPolicy.h.

Referenced by to_string().

ResourceGrantSizeInfo ExecutorResourceMgr_Namespace::ResourceGrantPolicy::size_info

Definition at line 50 of file ResourceGrantPolicy.h.

Referenced by get_grant_quantity(), and to_string().


The documentation for this struct was generated from the following files: