Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gflag to allow growing buffers that were created in different task #10768

Closed
Closed
Show file tree
Hide file tree
Changes from 3 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
5 changes: 5 additions & 0 deletions velox/exec/MemoryReclaimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
#include "velox/exec/Driver.h"
#include "velox/exec/Task.h"

DEFINE_bool(
transferred_arbitration_allowed,
xiaoxmeng marked this conversation as resolved.
Show resolved Hide resolved
false,
"Whether to allow entering memory arbitration on memory pool that is from another task");
xiaoxmeng marked this conversation as resolved.
Show resolved Hide resolved

namespace facebook::velox::exec {
std::unique_ptr<memory::MemoryReclaimer> MemoryReclaimer::create() {
return std::unique_ptr<memory::MemoryReclaimer>(new MemoryReclaimer());
Expand Down
2 changes: 2 additions & 0 deletions velox/exec/MemoryReclaimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

#include "velox/common/memory/MemoryArbitrator.h"

DECLARE_bool(transferred_arbitration_allowed);

namespace facebook::velox::exec {
/// Provides the default leaf memory reclaimer implementation for velox task
/// execution.
Expand Down
34 changes: 20 additions & 14 deletions velox/exec/Operator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,15 +563,19 @@ void Operator::MemoryReclaimer::enterArbitration() {
}

Driver* const runningDriver = driverThreadCtx->driverCtx.driver;
if (auto opDriver = ensureDriver()) {
// NOTE: the current running driver might not be the driver of the operator
// that requests memory arbitration. The reason is that an operator might
// extend the buffer allocated from the other operator either from the same
// or different drivers. But they must be from the same task.
VELOX_CHECK_EQ(
runningDriver->task()->taskId(),
opDriver->task()->taskId(),
"The current running driver and the request driver must be from the same task");
if (!FLAGS_transferred_arbitration_allowed) {
if (auto opDriver = ensureDriver()) {
// NOTE: the current running driver might not be the driver of the
// operator that requests memory arbitration. The reason is that an
// operator might extend the buffer allocated from the other operator
// either from the same or different drivers. But they must be from the
// same task as the following check. User could set
// FLAGS_transferred_arbitration_allowed=true to bypass this check.
VELOX_CHECK_EQ(
runningDriver->task()->taskId(),
opDriver->task()->taskId(),
"The current running driver and the request driver must be from the same task");
}
}
if (runningDriver->task()->enterSuspended(runningDriver->state()) !=
StopReason::kNone) {
Expand All @@ -589,11 +593,13 @@ void Operator::MemoryReclaimer::leaveArbitration() noexcept {
return;
}
Driver* const runningDriver = driverThreadCtx->driverCtx.driver;
if (auto opDriver = ensureDriver()) {
VELOX_CHECK_EQ(
runningDriver->task()->taskId(),
opDriver->task()->taskId(),
"The current running driver and the request driver must be from the same task");
if (!FLAGS_transferred_arbitration_allowed) {
if (auto opDriver = ensureDriver()) {
VELOX_CHECK_EQ(
runningDriver->task()->taskId(),
opDriver->task()->taskId(),
"The current running driver and the request driver must be from the same task");
}
}
runningDriver->task()->leaveSuspended(runningDriver->state());
}
Expand Down
Loading