| 346 | } |
| 347 | |
| 348 | Status ExecEnv::Init() { |
| 349 | LOG(INFO) << "Initializing impalad with backend uuid: " << PrintId(backend_id_); |
| 350 | |
| 351 | // Initialize OTel |
| 352 | if (FLAGS_is_coordinator && FLAGS_otel_trace_enabled) { |
| 353 | init_otel_tracer(); |
| 354 | } |
| 355 | |
| 356 | // Initialize thread pools |
| 357 | if (FLAGS_is_coordinator) { |
| 358 | RETURN_IF_ERROR(hdfs_op_thread_pool_->Init()); |
| 359 | } |
| 360 | |
| 361 | int64_t bytes_limit; |
| 362 | RETURN_IF_ERROR(ChooseProcessMemLimit(&bytes_limit)); |
| 363 | |
| 364 | // Need to register JVM metrics first so that we can use them to compute the buffer pool |
| 365 | // limit. |
| 366 | JvmMemoryMetric::InitMetrics(metrics_.get()); |
| 367 | if (!BitUtil::IsPowerOf2(FLAGS_min_buffer_size)) { |
| 368 | return Status(Substitute( |
| 369 | "--min_buffer_size must be a power-of-two: $0", FLAGS_min_buffer_size)); |
| 370 | } |
| 371 | // The bytes limit we want to size everything else as a fraction of, excluding the |
| 372 | // JVM. |
| 373 | admit_mem_limit_ = bytes_limit; |
| 374 | if (FLAGS_mem_limit_includes_jvm) { |
| 375 | // The JVM max heap size is static and therefore known at this point. Other categories |
| 376 | // of JVM memory consumption are much smaller and dynamic so it is simpler not to |
| 377 | // include them here. |
| 378 | int64_t jvm_max_heap_size = JvmMemoryMetric::HEAP_MAX_USAGE->GetValue(); |
| 379 | admit_mem_limit_ -= jvm_max_heap_size; |
| 380 | if (admit_mem_limit_ <= 0) { |
| 381 | return Status( |
| 382 | Substitute("Invalid combination of --mem_limit_includes_jvm and JVM max heap " |
| 383 | "size $0, which must be smaller than process memory limit $1", |
| 384 | jvm_max_heap_size, bytes_limit)); |
| 385 | } |
| 386 | } |
| 387 | |
| 388 | bool is_percent = false; |
| 389 | int64_t codegen_cache_capacity = |
| 390 | ParseUtil::ParseMemSpec(FLAGS_codegen_cache_capacity, &is_percent, 0); |
| 391 | if (codegen_cache_capacity > 0) { |
| 392 | // If codegen_cache_capacity is larger than 0, the number should not be a percentage. |
| 393 | DCHECK(!is_percent); |
| 394 | int64_t codegen_cache_limit = admit_mem_limit_ * MAX_CODEGEN_CACHE_MEM_PERCENT; |
| 395 | DCHECK(codegen_cache_limit > 0); |
| 396 | if (codegen_cache_capacity > codegen_cache_limit) { |
| 397 | LOG(INFO) << "CodeGen Cache capacity changed from " |
| 398 | << PrettyPrinter::Print(codegen_cache_capacity, TUnit::BYTES) << " to " |
| 399 | << PrettyPrinter::Print(codegen_cache_limit, TUnit::BYTES) |
| 400 | << " due to reaching the limit."; |
| 401 | codegen_cache_capacity = codegen_cache_limit; |
| 402 | } |
| 403 | codegen_cache_.reset(new CodeGenCache(metrics_.get())); |
| 404 | RETURN_IF_ERROR(codegen_cache_->Init(codegen_cache_capacity)); |
| 405 | LOG(INFO) << "CodeGen Cache initialized with capacity " |
nothing calls this directly
no test coverage detected