Please update Analyzer.getMaxMemLimitPerHost() in Analyzer.java if updating this.
| 297 | |
| 298 | // Please update Analyzer.getMaxMemLimitPerHost() in Analyzer.java if updating this. |
| 299 | void ScheduleState::UpdateMemoryRequirements(const TPoolConfig& pool_cfg, |
| 300 | int64_t coord_mem_limit_admission, int64_t executor_mem_limit_admission) { |
| 301 | // If the max_mem_resources, min_query_mem_limit, and max_query_mem_limit are not set |
| 302 | // in the pool config then it falls back to traditional(old) behavior, which means |
| 303 | // that, it sets the mem_limit if it is set in the query options, else sets it to |
| 304 | // -1 (no limit). |
| 305 | const bool mimic_old_behaviour = |
| 306 | pool_cfg.max_mem_resources <= 0 && |
| 307 | pool_cfg.min_query_mem_limit == 0 && |
| 308 | pool_cfg.max_query_mem_limit == 0; |
| 309 | const bool use_dedicated_coord_estimates = UseDedicatedCoordEstimates(); |
| 310 | |
| 311 | query_schedule_pb_->set_per_backend_mem_to_admit(0); |
| 312 | query_schedule_pb_->set_per_backend_mem_to_admit_source(MemLimitSourcePB::NO_LIMIT); |
| 313 | query_schedule_pb_->set_coord_backend_mem_to_admit(0); |
| 314 | query_schedule_pb_->set_coord_backend_mem_to_admit_source(MemLimitSourcePB::NO_LIMIT); |
| 315 | bool is_mem_limit_set = false; |
| 316 | if (query_options().__isset.mem_limit && query_options().mem_limit > 0) { |
| 317 | query_schedule_pb_->set_per_backend_mem_to_admit(query_options().mem_limit); |
| 318 | query_schedule_pb_->set_per_backend_mem_to_admit_source( |
| 319 | MemLimitSourcePB::QUERY_OPTION_MEM_LIMIT); |
| 320 | query_schedule_pb_->set_coord_backend_mem_to_admit(query_options().mem_limit); |
| 321 | query_schedule_pb_->set_coord_backend_mem_to_admit_source( |
| 322 | MemLimitSourcePB::QUERY_OPTION_MEM_LIMIT); |
| 323 | is_mem_limit_set = true; |
| 324 | } |
| 325 | |
| 326 | if (!is_mem_limit_set) { |
| 327 | query_schedule_pb_->set_per_backend_mem_to_admit(GetPerExecutorMemoryEstimate()); |
| 328 | query_schedule_pb_->set_per_backend_mem_to_admit_source( |
| 329 | MemLimitSourcePB::QUERY_PLAN_PER_HOST_MEM_ESTIMATE); |
| 330 | if (use_dedicated_coord_estimates) { |
| 331 | query_schedule_pb_->set_coord_backend_mem_to_admit( |
| 332 | GetDedicatedCoordMemoryEstimate()); |
| 333 | query_schedule_pb_->set_coord_backend_mem_to_admit_source( |
| 334 | MemLimitSourcePB::QUERY_PLAN_DEDICATED_COORDINATOR_MEM_ESTIMATE); |
| 335 | } else { |
| 336 | query_schedule_pb_->set_coord_backend_mem_to_admit(GetPerExecutorMemoryEstimate()); |
| 337 | query_schedule_pb_->set_coord_backend_mem_to_admit_source( |
| 338 | MemLimitSourcePB::QUERY_PLAN_PER_HOST_MEM_ESTIMATE); |
| 339 | } |
| 340 | VLOG(3) << "use_dedicated_coord_estimates=" << use_dedicated_coord_estimates |
| 341 | << " coord_backend_mem_to_admit=" |
| 342 | << query_schedule_pb_->coord_backend_mem_to_admit() |
| 343 | << " per_backend_mem_to_admit=" |
| 344 | << query_schedule_pb_->per_backend_mem_to_admit(); |
| 345 | if (!mimic_old_behaviour) { |
| 346 | int64_t min_mem_limit_required = |
| 347 | ReservationUtil::GetMinMemLimitFromReservation(largest_min_reservation()); |
| 348 | CompareMaxBackendMemToAdmit( |
| 349 | min_mem_limit_required, MemLimitSourcePB::ADJUSTED_PER_HOST_MEM_ESTIMATE); |
| 350 | int64_t min_coord_mem_limit_required = |
| 351 | ReservationUtil::GetMinMemLimitFromReservation(coord_min_reservation()); |
| 352 | CompareMaxCoordinatorMemToAdmit(min_coord_mem_limit_required, |
| 353 | MemLimitSourcePB::ADJUSTED_DEDICATED_COORDINATOR_MEM_ESTIMATE); |
| 354 | } |
| 355 | } |
| 356 |