Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions cpp/velox/compute/WholeStageResultIterator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ WholeStageResultIterator::WholeStageResultIterator(
folly::Executor* executor,
folly::Executor* spillExecutor,
VeloxConnectorIds connectorIds,
const std::string spillDir,
const std::string& spillDir,
const std::shared_ptr<facebook::velox::config::ConfigBase>& veloxCfg,
const SparkTaskInfo& taskInfo)
: memoryManager_(memoryManager),
Expand Down Expand Up @@ -361,7 +361,7 @@ void WholeStageResultIterator::getOrderedNodeIds(
if (projectedChild != nullptr) {
const auto projectSources = projectedChild->sources();
GLUTEN_CHECK(projectSources.size() == 1, "Illegal state");
const auto projectSource = projectSources.at(0);
const auto& projectSource = projectSources.at(0);
getOrderedNodeIds(projectSource, nodeIds);
} else {
getOrderedNodeIds(source, nodeIds);
Expand Down Expand Up @@ -551,15 +551,17 @@ std::unordered_map<std::string, std::string> WholeStageResultIterator::getQueryC
// Partial aggregation memory configurations.
// TODO: Move the calculations to Java side.
auto offHeapMemory = veloxCfg_->get<int64_t>(kSparkTaskOffHeapMemory, facebook::velox::memory::kMaxMemory);
const auto partialAggregationMemory = veloxCfg_->get<int64_t>(kMaxPartialAggregationMemory);
auto maxPartialAggregationMemory = std::max<int64_t>(
1 << 24,
veloxCfg_->get<int64_t>(kMaxPartialAggregationMemory).has_value()
? veloxCfg_->get<int64_t>(kMaxPartialAggregationMemory).value()
partialAggregationMemory.has_value()
? *partialAggregationMemory
: static_cast<int64_t>(veloxCfg_->get<double>(kMaxPartialAggregationMemoryRatio, 0.1) * offHeapMemory));
const auto extendedPartialAggregationMemory = veloxCfg_->get<int64_t>(kMaxExtendedPartialAggregationMemory);
auto maxExtendedPartialAggregationMemory = std::max<int64_t>(
1 << 26,
veloxCfg_->get<int64_t>(kMaxExtendedPartialAggregationMemory).has_value()
? veloxCfg_->get<int64_t>(kMaxExtendedPartialAggregationMemory).value()
extendedPartialAggregationMemory.has_value()
? *extendedPartialAggregationMemory
: static_cast<int64_t>(
veloxCfg_->get<double>(kMaxExtendedPartialAggregationMemoryRatio, 0.15) * offHeapMemory));
configs[velox::core::QueryConfig::kMaxPartialAggregationMemory] = std::to_string(maxPartialAggregationMemory);
Expand Down
23 changes: 14 additions & 9 deletions cpp/velox/compute/WholeStageResultIterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,25 @@ class WholeStageResultIterator : public SplitAwareColumnarBatchIterator {
folly::Executor* executor,
folly::Executor* spillExecutor,
VeloxConnectorIds connectorIds,
const std::string spillDir,
const std::string& spillDir,
const std::shared_ptr<facebook::velox::config::ConfigBase>& veloxCfg,
const SparkTaskInfo& taskInfo);

virtual ~WholeStageResultIterator() {
if (task_ != nullptr) {
if (task_->isRunning()) {
// calling .wait() may take no effect in single thread execution mode
task_->requestCancel().wait();
// A destructor must not throw: log a failure to cancel or wait for the task instead.
try {
if (task_ != nullptr) {
if (task_->isRunning()) {
// calling .wait() may take no effect in single thread execution mode
task_->requestCancel().wait();
}
auto deletionFuture = task_->taskDeletionFuture();
cursor_.reset();
task_ = nullptr;
deletionFuture.wait();
}
auto deletionFuture = task_->taskDeletionFuture();
cursor_.reset();
task_ = nullptr;
deletionFuture.wait();
} catch (const std::exception& e) {
LOG(WARNING) << "Failed to release the Velox task: " << e.what();
}
#ifdef GLUTEN_ENABLE_GPU
if (enableCudf_) {
Expand Down
Loading