OmniSciDB
a5dc49c757
|
ExecutorResourcePool keeps track of available compute and memory resources and can be queried to get the min and max resources grantable (embodied in a ResourceGrant) for a request, given a ResourceRequest. More...
#include <ExecutorResourcePool.h>
Public Member Functions | |
ExecutorResourcePool (const std::vector< std::pair< ResourceType, size_t >> &total_resources, const std::vector< ConcurrentResourceGrantPolicy > &concurrent_resource_grant_policies, const std::vector< ResourceGrantPolicy > &max_per_request_resource_grant_policies) | |
void | log_parameters () const |
std::vector< ResourceRequestGrant > | calc_static_resource_grant_ranges_for_request (const std::vector< ResourceRequest > &resource_requests) const |
std::pair< ResourceGrant, ResourceGrant > | calc_min_max_resource_grants_for_request (const RequestInfo &resource_request) const |
Given the provided resource_request, statically calculate the minimum and maximum grantable resources for that request. Note that the max resource grant may be less that requested by the query. More... | |
bool | can_currently_satisfy_request (const ResourceGrant &min_resource_grant, const ChunkRequestInfo &chunk_request_info) const |
std::pair< bool, ResourceGrant > | determine_dynamic_resource_grant (const ResourceGrant &min_resource_grant, const ResourceGrant &max_resource_grant, const ChunkRequestInfo &chunk_request_info, const double max_request_backoff_ratio) const |
Determines the actual resource grant to give a query (which will be somewhere between the provided min_resource_grant and max_resource_grant, unless it is determined that the request cannot be currently satisfied). More... | |
void | allocate_resources (const ResourceGrant &resource_grant, const ChunkRequestInfo &chunk_request_info) |
Given a resource grant (assumed to be computed in determine_dynamic_resource_grant), actually allocate (reserve) the resources in the pool so other requestors (queries) cannot use those resources until returned to the pool. More... | |
void | deallocate_resources (const ResourceGrant &resource_grant, const ChunkRequestInfo &chunk_request_info) |
Deallocates resources granted to a requestor such that they can be used for other requests. More... | |
std::pair< size_t, size_t > | get_resource_info (const ResourceType resource_type) const |
Returns the allocated and total available amount of the resource specified. More... | |
ResourcePoolInfo | get_resource_info () const |
Returns a struct detailing the allocated and total available resources of each type tracked in ExecutorResourcePool. More... | |
void | set_resource (const ResourceType resource_type, const size_t resource_quantity) |
Sets the quantity of resource_type to resource_quantity. If pool has outstanding requests, will throw. Responsibility of allowing the pool to empty and preventing concurrent requests while this operation is running is left to the caller (in particular, ExecutorResourceMgr::set_resource pauses the process queue, which waits until all executing requests are finished before yielding to the caller, before calling this method). More... | |
ConcurrentResourceGrantPolicy | get_concurrent_resource_grant_policy (const ResourceType resource_type) const |
const ResourceGrantPolicy & | get_max_resource_grant_per_request_policy (const ResourceSubtype resource_subtype) const |
void | set_concurrent_resource_grant_policy (const ConcurrentResourceGrantPolicy &concurrent_resource_grant_policy) |
Resets the concurrent resource grant policy object, which specifies a ResourceType as well as normal and oversubscription concurrency policies. If pool has outstanding requests, will throw. Responsibility of allowing the pool to empty and preventing concurrent requests while this operation is running is left to the caller (in particular, ExecutorResourceMgr::set_concurent_resource_grant_policy pauses the process queue, which waits until all executing requests are finished before yielding to the caller, before calling this method). More... | |
Private Member Functions | |
void | init (const std::vector< std::pair< ResourceType, size_t >> &total_resources, const std::vector< ConcurrentResourceGrantPolicy > &concurrent_resource_grant_policies, const std::vector< ResourceGrantPolicy > &max_per_request_resource_grant_policies) |
void | init_concurrency_policies () |
void | init_max_resource_grants_per_requests () |
void | throw_insufficient_resource_error (const ResourceSubtype resource_subtype, const size_t min_resource_requested) const |
size_t | calc_max_resource_grant_for_request (const size_t requested_resource_quantity, const size_t min_requested_resource_quantity, const size_t max_grantable_resource_quantity) const |
std::pair< size_t, size_t > | calc_min_dependent_resource_grant_for_request (const size_t min_requested_dependent_resource_quantity, const size_t min_requested_independent_resource_quantity, const size_t dependent_to_independent_resource_ratio) const |
std::pair< size_t, size_t > | calc_max_dependent_resource_grant_for_request (const size_t requested_dependent_resource_quantity, const size_t min_requested_dependent_resource_quantity, const size_t max_grantable_dependent_resource_quantity, const size_t min_requested_independent_resource_quantity, const size_t max_grantable_independent_resource_quantity, const size_t dependent_to_independent_resource_ratio) const |
bool | check_request_against_global_policy (const size_t resource_total, const size_t resource_allocated, const ConcurrentResourceGrantPolicy &concurrent_resource_grant_policy) const |
bool | check_request_against_policy (const size_t resource_request, const size_t resource_total, const size_t resource_allocated, const size_t global_outstanding_requests, const ConcurrentResourceGrantPolicy &concurrent_resource_grant_policy) const |
bool | can_currently_satisfy_request_impl (const ResourceGrant &min_resource_grant, const ChunkRequestInfo &chunk_request_info) const |
bool | can_currently_satisfy_chunk_request (const ResourceGrant &min_resource_grant, const ChunkRequestInfo &chunk_request_info) const |
ChunkRequestInfo | get_requested_chunks_not_in_pool (const ChunkRequestInfo &chunk_request_info) const |
size_t | get_chunk_bytes_not_in_pool (const ChunkRequestInfo &chunk_request_info) const |
void | add_chunk_requests_to_allocated_pool (const ResourceGrant &resource_grant, const ChunkRequestInfo &chunk_request_info) |
void | remove_chunk_requests_from_allocated_pool (const ResourceGrant &resource_grant, const ChunkRequestInfo &chunk_request_info) |
size_t | determine_dynamic_single_resource_grant (const size_t min_resource_requested, const size_t max_resource_requested, const size_t resource_allocated, const size_t total_resource, const double max_request_backoff_ratio) const |
void | sanity_check_requests_against_allocations () const |
size_t | get_total_allocated_buffer_pool_mem_for_level (const ExecutorDeviceType memory_pool_type) const |
bool | is_resource_valid (const ResourceType resource_type) const |
size_t | get_total_resource (const ResourceType resource_type) const |
size_t | get_allocated_resource_of_subtype (const ResourceSubtype resource_subtype) const |
size_t | get_allocated_resource_of_type (const ResourceType resource_type) const |
size_t | get_max_resource_grant_per_request (const ResourceSubtype resource_subtype) const |
size_t | get_total_per_resource_num_requests (const ResourceType resource_type) const |
size_t | increment_total_per_resource_num_requests (const ResourceType resource_type) |
size_t | decrement_total_per_resource_num_requests (const ResourceType resource_type) |
size_t | get_outstanding_per_resource_num_requests (const ResourceType resource_type) const |
size_t | increment_outstanding_per_resource_num_requests (const ResourceType resource_type) |
size_t | decrement_outstanding_per_resource_num_requests (const ResourceType resource_type) |
Private Attributes | |
std::array< size_t, ResourceTypeSize > | total_resources_ {} |
std::array< bool, ResourceTypeSize > | resource_type_validity_ |
std::array< size_t, ResourceSubtypeSize > | allocated_resources_ {} |
std::array < ResourceGrantPolicy, ResourceSubtypeSize > | max_resource_grants_per_request_policies_ {} |
std::array< size_t, ResourceSubtypeSize > | max_resource_grants_per_request_ {} |
std::array < ConcurrentResourceGrantPolicy, ResourceTypeSize > | concurrent_resource_grant_policies_ |
size_t | total_num_requests_ {0} |
size_t | outstanding_num_requests_ {0} |
std::array< size_t, ResourceTypeSize > | total_per_resource_num_requests_ {} |
std::array< size_t, ResourceTypeSize > | outstanding_per_resource_num_requests_ {} |
BufferPoolChunkMap | allocated_cpu_buffer_pool_chunks_ |
BufferPoolChunkMap | allocated_gpu_buffer_pool_chunks_ |
const bool | sanity_check_pool_state_on_deallocations_ {false} |
std::shared_mutex | resource_mutex_ |
ExecutorResourcePool keeps track of available compute and memory resources and can be queried to get the min and max resources grantable (embodied in a ResourceGrant) for a request, given a ResourceRequest.
ExecutorResourcePool keeps track of logical resources available to the executor, categorized and typed by the ResourceType enum. Current valid categories of ResourceType include CPU_SLOTS, GPU_SLOTS, CPU_RESULT_MEM, CPU_BUFFER_POOL_MEM, and GPU_BUFFER_POOL_MEM. Furthermore, a ResourceSubtype enum is used to represent more granular sub-categories of the above. Namely, there exists ResourceSubtype PINNED_CPU_BUFFER_POOL_MEM and PINNED_GPU_BUFFER_POOL_MEM to represent non-pageable memory (specifcally for kernel results), and PAGEABLE_CPU_BUFFER_POOL_MEM and PAGEABLE_GPU_BUFFER_POOL_MEM to represent data that could be evicted as neccessary.
Currently, a singleton ExecutorResourcePool is managed by ExecutorResourceMgr and is initialized by the latter in the ExecutorResourceMgr constructor. Various parameters driving behavior of ExecutorResourcePool are passed to its constructor, comprising the total resources available in the pool in each of the above categories, policies around concurrent requests to the pool for each of the resources (embodied in a vector of ConcurrentResourceGrantPolicy), and policies around limits to individual resource grants (embodied in a vector of ResourceGrantPolicy).
Generally for a given resource request, the following lifecycle is prescribed, as can be seen in the various invocations of ExecutorResourcePool methods by ExecutorResourceMgr:
Definition at line 237 of file ExecutorResourcePool.h.
ExecutorResourceMgr_Namespace::ExecutorResourcePool::ExecutorResourcePool | ( | const std::vector< std::pair< ResourceType, size_t >> & | total_resources, |
const std::vector< ConcurrentResourceGrantPolicy > & | concurrent_resource_grant_policies, | ||
const std::vector< ResourceGrantPolicy > & | max_per_request_resource_grant_policies | ||
) |
Definition at line 48 of file ExecutorResourcePool.cpp.
References init(), and log_parameters().
|
private |
Definition at line 714 of file ExecutorResourcePool.cpp.
References allocated_cpu_buffer_pool_chunks_, allocated_gpu_buffer_pool_chunks_, allocated_resources_, ExecutorResourceMgr_Namespace::ResourceGrant::buffer_mem_for_given_slots, ExecutorResourceMgr_Namespace::ResourceGrant::buffer_mem_gated_per_slot, CHECK, CHECK_LE, ExecutorResourceMgr_Namespace::ChunkRequestInfo::chunks_with_byte_sizes, CPU, ExecutorResourceMgr_Namespace::CPU_BUFFER_POOL_MEM, ExecutorResourceMgr_Namespace::debug_print(), ExecutorResourceMgr_Namespace::ChunkRequestInfo::device_memory_pool_type, ExecutorResourceMgr_Namespace::ENABLE_DEBUG_PRINTING, logger::EXECUTOR, format_num_bytes(), get_allocated_resource_of_subtype(), get_total_allocated_buffer_pool_mem_for_level(), get_total_resource(), ExecutorResourceMgr_Namespace::GPU_BUFFER_POOL_MEM, LOG, ExecutorResourceMgr_Namespace::ChunkRequestInfo::num_chunks, ExecutorResourceMgr_Namespace::PAGEABLE_CPU_BUFFER_POOL_MEM, ExecutorResourceMgr_Namespace::PINNED_CPU_BUFFER_POOL_MEM, ExecutorResourceMgr_Namespace::PINNED_GPU_BUFFER_POOL_MEM, and ExecutorResourceMgr_Namespace::ChunkRequestInfo::total_bytes.
Referenced by allocate_resources().
void ExecutorResourceMgr_Namespace::ExecutorResourcePool::allocate_resources | ( | const ResourceGrant & | resource_grant, |
const ChunkRequestInfo & | chunk_request_info | ||
) |
Given a resource grant (assumed to be computed in determine_dynamic_resource_grant), actually allocate (reserve) the resources in the pool so other requestors (queries) cannot use those resources until returned to the pool.
Note that the chunk requests do not and should not neccessarily match the state of the BufferMgrs (where evictions can happen etc), but are just used to keep track of what chunks are pledged for running queries. In the future we may try to get all of this info from the BufferMgr directly, but would need to add a layer of state there that would keep track of both what is currently allocated and what is pledged to queries. For now, this effort was not deemed worth the complexity and risk it would introduce.
resource_grant | - Granted resource_grant, assumed to be determined previously in determine_dynamic_resource_grant |
chunk_request_info | - The DataMgr chunk keys and other associated info needed by this query. The ExecutorResourcePool must keep track of chunks that are in the pool so it can properly determine whether queries can execute (given chunks can be shared resources across requestors/queries). |
Definition at line 1022 of file ExecutorResourcePool.cpp.
References add_chunk_requests_to_allocated_pool(), allocated_resources_, ExecutorResourceMgr_Namespace::ResourceGrant::buffer_mem_gated_per_slot, can_currently_satisfy_request_impl(), CHECK, CPU, ExecutorResourceMgr_Namespace::CPU_BUFFER_POOL_MEM, ExecutorResourceMgr_Namespace::CPU_RESULT_MEM, ExecutorResourceMgr_Namespace::ResourceGrant::cpu_result_mem, ExecutorResourceMgr_Namespace::CPU_SLOTS, ExecutorResourceMgr_Namespace::ResourceGrant::cpu_slots, ExecutorResourceMgr_Namespace::ChunkRequestInfo::device_memory_pool_type, logger::EXECUTOR, format_num_bytes(), get_allocated_resource_of_type(), get_outstanding_per_resource_num_requests(), get_total_resource(), GPU, ExecutorResourceMgr_Namespace::GPU_BUFFER_POOL_MEM, ExecutorResourceMgr_Namespace::GPU_SLOTS, ExecutorResourceMgr_Namespace::ResourceGrant::gpu_slots, increment_outstanding_per_resource_num_requests(), increment_total_per_resource_num_requests(), LOG, ExecutorResourceMgr_Namespace::ChunkRequestInfo::num_chunks, outstanding_num_requests_, resource_mutex_, ExecutorResourceMgr_Namespace::ChunkRequestInfo::total_bytes, and total_num_requests_.
Referenced by ExecutorResourceMgr_Namespace::ExecutorResourceMgr::process_queue_loop().
|
private |
Definition at line 266 of file ExecutorResourcePool.cpp.
References calc_min_dependent_resource_grant_for_request(), CHECK_GE, and CHECK_LE.
Referenced by calc_min_max_resource_grants_for_request(), and determine_dynamic_resource_grant().
|
private |
Definition at line 235 of file ExecutorResourcePool.cpp.
Referenced by calc_min_max_resource_grants_for_request(), and calc_static_resource_grant_ranges_for_request().
|
private |
Definition at line 249 of file ExecutorResourcePool.cpp.
Referenced by calc_max_dependent_resource_grant_for_request(), and calc_min_max_resource_grants_for_request().
std::pair< ResourceGrant, ResourceGrant > ExecutorResourceMgr_Namespace::ExecutorResourcePool::calc_min_max_resource_grants_for_request | ( | const RequestInfo & | resource_request | ) | const |
Given the provided resource_request, statically calculate the minimum and maximum grantable resources for that request. Note that the max resource grant may be less that requested by the query.
Note that this method only looks at static total available resources as well as the ideal and minimum resources requested (in resource_request) to determine the max grants, and does not evaluate the current state of resource use in the pool. That is done in a later call, detrmine_dynamic_resource_grant.
resource_request | - Details the resources a query would like to have as well as the minimum resources it can run with |
Definition at line 365 of file ExecutorResourcePool.cpp.
References ExecutorResourceMgr_Namespace::ResourceGrant::buffer_mem_for_given_slots, ExecutorResourceMgr_Namespace::ResourceGrant::buffer_mem_gated_per_slot, ExecutorResourceMgr_Namespace::ResourceGrant::buffer_mem_per_slot, calc_max_dependent_resource_grant_for_request(), calc_max_resource_grant_for_request(), calc_min_dependent_resource_grant_for_request(), CHECK, CHECK_EQ, CHECK_GE, CHECK_GT, CHECK_LE, ExecutorResourceMgr_Namespace::RequestInfo::chunk_request_info, CPU, ExecutorResourceMgr_Namespace::RequestInfo::cpu_result_mem, ExecutorResourceMgr_Namespace::CPU_RESULT_MEM, ExecutorResourceMgr_Namespace::ResourceGrant::cpu_result_mem, ExecutorResourceMgr_Namespace::RequestInfo::cpu_slots, ExecutorResourceMgr_Namespace::CPU_SLOTS, ExecutorResourceMgr_Namespace::ResourceGrant::cpu_slots, get_max_resource_grant_per_request(), ExecutorResourceMgr_Namespace::RequestInfo::gpu_slots, ExecutorResourceMgr_Namespace::GPU_SLOTS, ExecutorResourceMgr_Namespace::ResourceGrant::gpu_slots, ExecutorResourceMgr_Namespace::RequestInfo::min_cpu_result_mem, ExecutorResourceMgr_Namespace::RequestInfo::min_cpu_slots, ExecutorResourceMgr_Namespace::RequestInfo::min_gpu_slots, ExecutorResourceMgr_Namespace::PAGEABLE_CPU_BUFFER_POOL_MEM, ExecutorResourceMgr_Namespace::PAGEABLE_GPU_BUFFER_POOL_MEM, ExecutorResourceMgr_Namespace::PINNED_CPU_BUFFER_POOL_MEM, and ExecutorResourceMgr_Namespace::PINNED_GPU_BUFFER_POOL_MEM.
Referenced by ExecutorResourceMgr_Namespace::ExecutorResourceMgr::request_resources_with_timeout().
std::vector< ResourceRequestGrant > ExecutorResourceMgr_Namespace::ExecutorResourcePool::calc_static_resource_grant_ranges_for_request | ( | const std::vector< ResourceRequest > & | resource_requests | ) | const |
Definition at line 337 of file ExecutorResourcePool.cpp.
References calc_max_resource_grant_for_request(), CHECK, CHECK_EQ, CHECK_LE, get_max_resource_grant_per_request(), ExecutorResourceMgr_Namespace::INVALID_SUBTYPE, ExecutorResourceMgr_Namespace::ResourceRequest::max_quantity, ExecutorResourceMgr_Namespace::ResourceRequest::resource_subtype, and throw_insufficient_resource_error().
|
private |
Definition at line 676 of file ExecutorResourcePool.cpp.
References ExecutorResourceMgr_Namespace::ResourceGrant::buffer_mem_gated_per_slot, ExecutorResourceMgr_Namespace::ResourceGrant::buffer_mem_per_slot, CHECK, CHECK_GT, CHECK_LE, CPU, ExecutorResourceMgr_Namespace::CPU_BUFFER_POOL_MEM, ExecutorResourceMgr_Namespace::ResourceGrant::cpu_slots, ExecutorResourceMgr_Namespace::debug_print(), ExecutorResourceMgr_Namespace::ChunkRequestInfo::device_memory_pool_type, ExecutorResourceMgr_Namespace::ENABLE_DEBUG_PRINTING, format_num_bytes(), get_chunk_bytes_not_in_pool(), get_total_allocated_buffer_pool_mem_for_level(), get_total_resource(), ExecutorResourceMgr_Namespace::GPU_BUFFER_POOL_MEM, and ExecutorResourceMgr_Namespace::ChunkRequestInfo::total_bytes.
Referenced by can_currently_satisfy_request_impl().
bool ExecutorResourceMgr_Namespace::ExecutorResourcePool::can_currently_satisfy_request | ( | const ResourceGrant & | min_resource_grant, |
const ChunkRequestInfo & | chunk_request_info | ||
) | const |
Definition at line 910 of file ExecutorResourcePool.cpp.
References can_currently_satisfy_request_impl(), and resource_mutex_.
|
private |
Definition at line 555 of file ExecutorResourcePool.cpp.
References can_currently_satisfy_chunk_request(), check_request_against_global_policy(), check_request_against_policy(), ExecutorResourceMgr_Namespace::CPU_RESULT_MEM, ExecutorResourceMgr_Namespace::ResourceGrant::cpu_result_mem, ExecutorResourceMgr_Namespace::CPU_SLOTS, ExecutorResourceMgr_Namespace::ResourceGrant::cpu_slots, get_allocated_resource_of_type(), get_concurrent_resource_grant_policy(), get_max_resource_grant_per_request(), get_total_resource(), ExecutorResourceMgr_Namespace::GPU_SLOTS, ExecutorResourceMgr_Namespace::ResourceGrant::gpu_slots, and outstanding_num_requests_.
Referenced by allocate_resources(), can_currently_satisfy_request(), and determine_dynamic_resource_grant().
|
private |
Definition at line 491 of file ExecutorResourcePool.cpp.
References ExecutorResourceMgr_Namespace::ALLOW_SINGLE_REQUEST_GLOBALLY, ExecutorResourceMgr_Namespace::ConcurrentResourceGrantPolicy::concurrency_policy, and ExecutorResourceMgr_Namespace::ConcurrentResourceGrantPolicy::oversubscription_concurrency_policy.
Referenced by can_currently_satisfy_request_impl().
|
private |
Definition at line 508 of file ExecutorResourcePool.cpp.
References ExecutorResourceMgr_Namespace::ALLOW_CONCURRENT_REQUESTS, ExecutorResourceMgr_Namespace::ALLOW_SINGLE_REQUEST, ExecutorResourceMgr_Namespace::ALLOW_SINGLE_REQUEST_GLOBALLY, ExecutorResourceMgr_Namespace::ConcurrentResourceGrantPolicy::concurrency_policy, ExecutorResourceMgr_Namespace::DISALLOW_REQUESTS, ExecutorResourceMgr_Namespace::ConcurrentResourceGrantPolicy::oversubscription_concurrency_policy, and UNREACHABLE.
Referenced by can_currently_satisfy_request_impl().
void ExecutorResourceMgr_Namespace::ExecutorResourcePool::deallocate_resources | ( | const ResourceGrant & | resource_grant, |
const ChunkRequestInfo & | chunk_request_info | ||
) |
Deallocates resources granted to a requestor such that they can be used for other requests.
resource_grant | - Resources granted to the request that should be deallocated |
chunk_request_info | - The DataMgr chunk keys (and other associated info) granted to this query that should be deallocated. |
Definition at line 1087 of file ExecutorResourcePool.cpp.
References allocated_resources_, ExecutorResourceMgr_Namespace::ResourceGrant::buffer_mem_gated_per_slot, CHECK_LE, CPU, ExecutorResourceMgr_Namespace::CPU_BUFFER_POOL_MEM, ExecutorResourceMgr_Namespace::CPU_RESULT_MEM, ExecutorResourceMgr_Namespace::ResourceGrant::cpu_result_mem, ExecutorResourceMgr_Namespace::CPU_SLOTS, ExecutorResourceMgr_Namespace::ResourceGrant::cpu_slots, decrement_outstanding_per_resource_num_requests(), ExecutorResourceMgr_Namespace::ChunkRequestInfo::device_memory_pool_type, logger::EXECUTOR, format_num_bytes(), get_allocated_resource_of_type(), get_outstanding_per_resource_num_requests(), get_total_resource(), GPU, ExecutorResourceMgr_Namespace::GPU_BUFFER_POOL_MEM, ExecutorResourceMgr_Namespace::GPU_SLOTS, ExecutorResourceMgr_Namespace::ResourceGrant::gpu_slots, LOG, ExecutorResourceMgr_Namespace::ChunkRequestInfo::num_chunks, outstanding_num_requests_, remove_chunk_requests_from_allocated_pool(), resource_mutex_, sanity_check_pool_state_on_deallocations_, sanity_check_requests_against_allocations(), and ExecutorResourceMgr_Namespace::ChunkRequestInfo::total_bytes.
Referenced by ExecutorResourceMgr_Namespace::ExecutorResourceMgr::release_resources().
|
inlineprivate |
Definition at line 519 of file ExecutorResourcePool.h.
References outstanding_per_resource_num_requests_.
Referenced by deallocate_resources().
|
inlineprivate |
Definition at line 504 of file ExecutorResourcePool.h.
References total_per_resource_num_requests_.
std::pair< bool, ResourceGrant > ExecutorResourceMgr_Namespace::ExecutorResourcePool::determine_dynamic_resource_grant | ( | const ResourceGrant & | min_resource_grant, |
const ResourceGrant & | max_resource_grant, | ||
const ChunkRequestInfo & | chunk_request_info, | ||
const double | max_request_backoff_ratio | ||
) | const |
Determines the actual resource grant to give a query (which will be somewhere between the provided min_resource_grant and max_resource_grant, unless it is determined that the request cannot be currently satisfied).
Generally the resources granted of each type are computed independently, but if buffer_mem_gated_per_slot is set on min_resource_grant, other resources such as threads granted may be scaled back to match the amount of buffer pool mem available.
min_resource_grant | - The min resource grant allowable for this request, determined in calc_min_max_resource_grants_for_request |
max_resource_grant | - The max resource grant possible for this request, determined in calc_min_max_resource_grants_for_request |
chunk_request_info | - The DataMgr chunks with associated sizes needed for this query |
max_request_backoff_ratio | - The fraction from 0 to 1 of each resource we will leave in the pool, even if the resources are available to satisfy the max_resource_grant (so that there will be resources available for other queries). |
Definition at line 936 of file ExecutorResourcePool.cpp.
References ExecutorResourceMgr_Namespace::ResourceGrant::buffer_mem_for_given_slots, ExecutorResourceMgr_Namespace::ResourceGrant::buffer_mem_gated_per_slot, ExecutorResourceMgr_Namespace::ResourceGrant::buffer_mem_per_slot, calc_max_dependent_resource_grant_for_request(), can_currently_satisfy_request_impl(), CHECK, CHECK_EQ, CHECK_GE, CHECK_LE, CPU, ExecutorResourceMgr_Namespace::CPU_BUFFER_POOL_MEM, ExecutorResourceMgr_Namespace::CPU_RESULT_MEM, ExecutorResourceMgr_Namespace::ResourceGrant::cpu_result_mem, ExecutorResourceMgr_Namespace::CPU_SLOTS, ExecutorResourceMgr_Namespace::ResourceGrant::cpu_slots, determine_dynamic_single_resource_grant(), ExecutorResourceMgr_Namespace::ChunkRequestInfo::device_memory_pool_type, get_allocated_resource_of_type(), get_total_resource(), ExecutorResourceMgr_Namespace::GPU_BUFFER_POOL_MEM, ExecutorResourceMgr_Namespace::GPU_SLOTS, ExecutorResourceMgr_Namespace::ResourceGrant::gpu_slots, ExecutorResourceMgr_Namespace::ChunkRequestInfo::max_bytes_per_kernel, resource_mutex_, and ExecutorResourceMgr_Namespace::ChunkRequestInfo::total_bytes.
Referenced by ExecutorResourceMgr_Namespace::ExecutorResourceMgr::choose_next_request().
|
private |
Definition at line 917 of file ExecutorResourcePool.cpp.
References CHECK_LE.
Referenced by determine_dynamic_resource_grant().
|
inlineprivate |
Definition at line 482 of file ExecutorResourcePool.h.
References allocated_resources_.
Referenced by add_chunk_requests_to_allocated_pool(), get_allocated_resource_of_type(), get_resource_info(), and remove_chunk_requests_from_allocated_pool().
|
private |
Definition at line 169 of file ExecutorResourcePool.cpp.
References get_allocated_resource_of_subtype(), and ExecutorResourceMgr_Namespace::map_resource_type_to_resource_subtypes().
Referenced by allocate_resources(), can_currently_satisfy_request_impl(), deallocate_resources(), determine_dynamic_resource_grant(), get_resource_info(), get_total_allocated_buffer_pool_mem_for_level(), remove_chunk_requests_from_allocated_pool(), and sanity_check_requests_against_allocations().
|
private |
Definition at line 658 of file ExecutorResourcePool.cpp.
References allocated_cpu_buffer_pool_chunks_, allocated_gpu_buffer_pool_chunks_, ExecutorResourceMgr_Namespace::ChunkRequestInfo::chunks_with_byte_sizes, CPU, and ExecutorResourceMgr_Namespace::ChunkRequestInfo::device_memory_pool_type.
Referenced by can_currently_satisfy_chunk_request().
|
inline |
Definition at line 369 of file ExecutorResourcePool.h.
References concurrent_resource_grant_policies_.
Referenced by can_currently_satisfy_request_impl(), ExecutorResourceMgr_Namespace::ExecutorResourceMgr::get_concurrent_resource_grant_policy(), init_max_resource_grants_per_requests(), log_parameters(), and ExecutorResourceMgr_Namespace::ExecutorResourceMgr::set_concurrent_resource_grant_policy().
|
inlineprivate |
Definition at line 489 of file ExecutorResourcePool.h.
References max_resource_grants_per_request_.
Referenced by calc_min_max_resource_grants_for_request(), calc_static_resource_grant_ranges_for_request(), can_currently_satisfy_request_impl(), and throw_insufficient_resource_error().
|
inline |
Definition at line 374 of file ExecutorResourcePool.h.
References max_resource_grants_per_request_policies_.
Referenced by log_parameters().
|
inlineprivate |
Definition at line 509 of file ExecutorResourcePool.h.
References outstanding_per_resource_num_requests_.
Referenced by allocate_resources(), deallocate_resources(), get_resource_info(), and sanity_check_requests_against_allocations().
|
private |
Definition at line 638 of file ExecutorResourcePool.cpp.
References allocated_cpu_buffer_pool_chunks_, allocated_gpu_buffer_pool_chunks_, ExecutorResourceMgr_Namespace::ChunkRequestInfo::chunks_with_byte_sizes, CPU, ExecutorResourceMgr_Namespace::ChunkRequestInfo::device_memory_pool_type, ExecutorResourceMgr_Namespace::ChunkRequestInfo::num_chunks, and ExecutorResourceMgr_Namespace::ChunkRequestInfo::total_bytes.
std::pair< size_t, size_t > ExecutorResourceMgr_Namespace::ExecutorResourcePool::get_resource_info | ( | const ResourceType | resource_type | ) | const |
Returns the allocated and total available amount of the resource specified.
Definition at line 179 of file ExecutorResourcePool.cpp.
References get_allocated_resource_of_type(), get_total_resource(), and resource_mutex_.
Referenced by ExecutorResourceMgr_Namespace::ExecutorResourceMgr::get_resource_info().
ResourcePoolInfo ExecutorResourceMgr_Namespace::ExecutorResourcePool::get_resource_info | ( | ) | const |
Returns a struct detailing the allocated and total available resources of each type tracked in ExecutorResourcePool.
Definition at line 186 of file ExecutorResourcePool.cpp.
References allocated_cpu_buffer_pool_chunks_, allocated_gpu_buffer_pool_chunks_, ExecutorResourceMgr_Namespace::CPU_BUFFER_POOL_MEM, ExecutorResourceMgr_Namespace::CPU_RESULT_MEM, ExecutorResourceMgr_Namespace::CPU_SLOTS, get_allocated_resource_of_subtype(), get_allocated_resource_of_type(), get_outstanding_per_resource_num_requests(), get_total_resource(), ExecutorResourceMgr_Namespace::GPU_BUFFER_POOL_MEM, ExecutorResourceMgr_Namespace::GPU_SLOTS, outstanding_num_requests_, ExecutorResourceMgr_Namespace::PAGEABLE_CPU_BUFFER_POOL_MEM, ExecutorResourceMgr_Namespace::PAGEABLE_GPU_BUFFER_POOL_MEM, resource_mutex_, and total_num_requests_.
|
inlineprivate |
Definition at line 467 of file ExecutorResourcePool.h.
References CPU, ExecutorResourceMgr_Namespace::CPU_BUFFER_POOL_MEM, get_allocated_resource_of_type(), and ExecutorResourceMgr_Namespace::GPU_BUFFER_POOL_MEM.
Referenced by add_chunk_requests_to_allocated_pool(), and can_currently_satisfy_chunk_request().
|
inlineprivate |
Definition at line 494 of file ExecutorResourcePool.h.
References total_per_resource_num_requests_.
|
inlineprivate |
Definition at line 478 of file ExecutorResourcePool.h.
References total_resources_.
Referenced by add_chunk_requests_to_allocated_pool(), allocate_resources(), can_currently_satisfy_chunk_request(), can_currently_satisfy_request_impl(), deallocate_resources(), determine_dynamic_resource_grant(), get_resource_info(), init_max_resource_grants_per_requests(), log_parameters(), and remove_chunk_requests_from_allocated_pool().
|
inlineprivate |
Definition at line 514 of file ExecutorResourcePool.h.
References outstanding_per_resource_num_requests_.
Referenced by allocate_resources().
|
inlineprivate |
Definition at line 499 of file ExecutorResourcePool.h.
References total_per_resource_num_requests_.
Referenced by allocate_resources().
|
private |
Definition at line 58 of file ExecutorResourcePool.cpp.
References concurrent_resource_grant_policies_, init_concurrency_policies(), init_max_resource_grants_per_requests(), ExecutorResourceMgr_Namespace::INVALID_SUBTYPE, ExecutorResourceMgr_Namespace::INVALID_TYPE, max_resource_grants_per_request_policies_, resource_type_validity_, and total_resources_.
Referenced by ExecutorResourcePool(), set_concurrent_resource_grant_policy(), and set_resource().
|
private |
Definition at line 95 of file ExecutorResourcePool.cpp.
References ExecutorResourceMgr_Namespace::ALLOW_SINGLE_REQUEST, CHECK, concurrent_resource_grant_policies_, ExecutorResourceMgr_Namespace::DISALLOW_REQUESTS, ExecutorResourceMgr_Namespace::INVALID_TYPE, and is_resource_valid().
Referenced by init().
|
private |
Definition at line 118 of file ExecutorResourcePool.cpp.
References CHECK, ExecutorResourceMgr_Namespace::DISALLOW_REQUESTS, get_concurrent_resource_grant_policy(), get_total_resource(), ExecutorResourceMgr_Namespace::INVALID_SUBTYPE, is_resource_valid(), ExecutorResourceMgr_Namespace::map_resource_subtype_to_resource_type(), max_resource_grants_per_request_, max_resource_grants_per_request_policies_, and ExecutorResourceMgr_Namespace::UNLIMITED.
Referenced by init().
|
inlineprivate |
Definition at line 474 of file ExecutorResourcePool.h.
References resource_type_validity_.
Referenced by init_concurrency_policies(), init_max_resource_grants_per_requests(), and log_parameters().
void ExecutorResourceMgr_Namespace::ExecutorResourcePool::log_parameters | ( | ) | const |
Definition at line 149 of file ExecutorResourcePool.cpp.
References logger::EXECUTOR, get_concurrent_resource_grant_policy(), get_max_resource_grant_per_request_policy(), get_total_resource(), is_resource_valid(), LOG, ExecutorResourceMgr_Namespace::map_resource_type_to_resource_subtypes(), ExecutorResourceMgr_Namespace::resource_type_to_string(), ExecutorResourceMgr_Namespace::ResourceTypeSize, ExecutorResourceMgr_Namespace::ResourceGrantPolicy::to_string(), and ExecutorResourceMgr_Namespace::ConcurrentResourceGrantPolicy::to_string().
Referenced by ExecutorResourcePool().
|
private |
Definition at line 814 of file ExecutorResourcePool.cpp.
References allocated_cpu_buffer_pool_chunks_, allocated_gpu_buffer_pool_chunks_, allocated_resources_, ExecutorResourceMgr_Namespace::ResourceGrant::buffer_mem_for_given_slots, ExecutorResourceMgr_Namespace::ResourceGrant::buffer_mem_gated_per_slot, CHECK, CHECK_GE, ExecutorResourceMgr_Namespace::ChunkRequestInfo::chunks_with_byte_sizes, CPU, ExecutorResourceMgr_Namespace::CPU_BUFFER_POOL_MEM, ExecutorResourceMgr_Namespace::debug_print(), ExecutorResourceMgr_Namespace::ChunkRequestInfo::device_memory_pool_type, ExecutorResourceMgr_Namespace::ENABLE_DEBUG_PRINTING, logger::EXECUTOR, format_num_bytes(), get_allocated_resource_of_subtype(), get_allocated_resource_of_type(), get_total_resource(), ExecutorResourceMgr_Namespace::GPU_BUFFER_POOL_MEM, LOG, ExecutorResourceMgr_Namespace::ChunkRequestInfo::num_chunks, ExecutorResourceMgr_Namespace::PAGEABLE_CPU_BUFFER_POOL_MEM, ExecutorResourceMgr_Namespace::PINNED_CPU_BUFFER_POOL_MEM, ExecutorResourceMgr_Namespace::PINNED_GPU_BUFFER_POOL_MEM, and ExecutorResourceMgr_Namespace::ChunkRequestInfo::total_bytes.
Referenced by deallocate_resources().
|
private |
Definition at line 1153 of file ExecutorResourcePool.cpp.
References allocated_cpu_buffer_pool_chunks_, allocated_gpu_buffer_pool_chunks_, CHECK, CHECK_EQ, CHECK_LE, ExecutorResourceMgr_Namespace::CPU_BUFFER_POOL_MEM, ExecutorResourceMgr_Namespace::CPU_RESULT_MEM, ExecutorResourceMgr_Namespace::CPU_SLOTS, get_allocated_resource_of_type(), get_outstanding_per_resource_num_requests(), ExecutorResourceMgr_Namespace::GPU_BUFFER_POOL_MEM, ExecutorResourceMgr_Namespace::GPU_SLOTS, outstanding_num_requests_, and total_num_requests_.
Referenced by deallocate_resources().
void ExecutorResourceMgr_Namespace::ExecutorResourcePool::set_concurrent_resource_grant_policy | ( | const ConcurrentResourceGrantPolicy & | concurrent_resource_grant_policy | ) |
Resets the concurrent resource grant policy object, which specifies a ResourceType as well as normal and oversubscription concurrency policies. If pool has outstanding requests, will throw. Responsibility of allowing the pool to empty and preventing concurrent requests while this operation is running is left to the caller (in particular, ExecutorResourceMgr::set_concurent_resource_grant_policy pauses the process queue, which waits until all executing requests are finished before yielding to the caller, before calling this method).
Currently only used for testing, but a SQL interface to live-change concurrency policies for the pool could be added.
concurrent_resource_grant_policy | - new concurrent resource policy (which encompasses the type of resource) |
Definition at line 224 of file ExecutorResourcePool.cpp.
References CHECK, init(), ExecutorResourceMgr_Namespace::INVALID_TYPE, outstanding_num_requests_, and ExecutorResourceMgr_Namespace::ConcurrentResourceGrantPolicy::resource_type.
Referenced by ExecutorResourceMgr_Namespace::ExecutorResourceMgr::set_concurrent_resource_grant_policy().
void ExecutorResourceMgr_Namespace::ExecutorResourcePool::set_resource | ( | const ResourceType | resource_type, |
const size_t | resource_quantity | ||
) |
Sets the quantity of resource_type to resource_quantity. If pool has outstanding requests, will throw. Responsibility of allowing the pool to empty and preventing concurrent requests while this operation is running is left to the caller (in particular, ExecutorResourceMgr::set_resource pauses the process queue, which waits until all executing requests are finished before yielding to the caller, before calling this method).
Currently only used for testing, but a SQL interface to live-change resources available in the pool could be added.
resource_type | - type of resource to change the quanity of |
resource_quantity | - new quantity of resource for given resource_type |
Definition at line 212 of file ExecutorResourcePool.cpp.
References CHECK, init(), ExecutorResourceMgr_Namespace::INVALID_TYPE, and outstanding_num_requests_.
Referenced by ExecutorResourceMgr_Namespace::ExecutorResourceMgr::set_resource().
|
private |
Definition at line 314 of file ExecutorResourcePool.cpp.
References ExecutorResourceMgr_Namespace::CPU_RESULT_MEM, ExecutorResourceMgr_Namespace::CPU_SLOTS, get_max_resource_grant_per_request(), and ExecutorResourceMgr_Namespace::GPU_SLOTS.
Referenced by calc_static_resource_grant_ranges_for_request().
|
private |
Definition at line 545 of file ExecutorResourcePool.h.
Referenced by add_chunk_requests_to_allocated_pool(), get_chunk_bytes_not_in_pool(), get_requested_chunks_not_in_pool(), get_resource_info(), remove_chunk_requests_from_allocated_pool(), and sanity_check_requests_against_allocations().
|
private |
Definition at line 546 of file ExecutorResourcePool.h.
Referenced by add_chunk_requests_to_allocated_pool(), get_chunk_bytes_not_in_pool(), get_requested_chunks_not_in_pool(), get_resource_info(), remove_chunk_requests_from_allocated_pool(), and sanity_check_requests_against_allocations().
|
private |
Definition at line 529 of file ExecutorResourcePool.h.
Referenced by add_chunk_requests_to_allocated_pool(), allocate_resources(), deallocate_resources(), get_allocated_resource_of_subtype(), and remove_chunk_requests_from_allocated_pool().
|
private |
Definition at line 534 of file ExecutorResourcePool.h.
Referenced by get_concurrent_resource_grant_policy(), init(), and init_concurrency_policies().
|
private |
Definition at line 532 of file ExecutorResourcePool.h.
Referenced by get_max_resource_grant_per_request(), and init_max_resource_grants_per_requests().
|
private |
Definition at line 531 of file ExecutorResourcePool.h.
Referenced by get_max_resource_grant_per_request_policy(), init(), and init_max_resource_grants_per_requests().
|
private |
Definition at line 537 of file ExecutorResourcePool.h.
Referenced by allocate_resources(), can_currently_satisfy_request_impl(), deallocate_resources(), get_resource_info(), sanity_check_requests_against_allocations(), set_concurrent_resource_grant_policy(), and set_resource().
|
private |
Definition at line 543 of file ExecutorResourcePool.h.
Referenced by decrement_outstanding_per_resource_num_requests(), get_outstanding_per_resource_num_requests(), and increment_outstanding_per_resource_num_requests().
|
mutableprivate |
Definition at line 549 of file ExecutorResourcePool.h.
Referenced by allocate_resources(), can_currently_satisfy_request(), deallocate_resources(), determine_dynamic_resource_grant(), and get_resource_info().
|
private |
Definition at line 526 of file ExecutorResourcePool.h.
Referenced by init(), and is_resource_valid().
|
private |
Definition at line 548 of file ExecutorResourcePool.h.
Referenced by deallocate_resources().
|
private |
Definition at line 536 of file ExecutorResourcePool.h.
Referenced by allocate_resources(), get_resource_info(), and sanity_check_requests_against_allocations().
|
private |
Definition at line 540 of file ExecutorResourcePool.h.
Referenced by decrement_total_per_resource_num_requests(), get_total_per_resource_num_requests(), and increment_total_per_resource_num_requests().
|
private |
Definition at line 525 of file ExecutorResourcePool.h.
Referenced by get_total_resource(), and init().