Skip to content
Merged
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
9 changes: 8 additions & 1 deletion cpp/velox/memory/GlutenDirectBufferedInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ class GlutenDirectBufferedInput : public facebook::velox::dwio::common::DirectBu

~GlutenDirectBufferedInput() override {
requests_.clear();
// Cancel all the planned loads as soon as possible to avoid unnecessary IO.
for (auto& load : coalescedLoads_) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we unify the two loops into one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I intentionally moved this forward to cancel the load as early as possible, trying to reduce wait time. Thanks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goal is that we should cancel the unused IO as soon as possible.

In old logic, a I/O thread may still be scheduled when we are waiting for current I/O.

if (load->state() == facebook::velox::cache::CoalescedLoad::State::kPlanned) {
load->cancel();
}
}
// Ensure all the loadings can finish in the TableScan destructor to avoid the issue that the load is still running
// when the VeloxMemoryManager used by the whole task is trying to destruct.
for (auto& load : coalescedLoads_) {
if (load->state() == facebook::velox::cache::CoalescedLoad::State::kLoading) {
folly::SemiFuture<bool> waitFuture(false);
Expand All @@ -56,7 +64,6 @@ class GlutenDirectBufferedInput : public facebook::velox::dwio::common::DirectBu
std::move(waitFuture).via(&exec).wait();
}
}
load->cancel();
}
coalescedLoads_.clear();
}
Expand Down
Loading