Skip to content

Commit

Permalink
[native] Allow termination with core on allocation failure
Browse files Browse the repository at this point in the history
  • Loading branch information
arhimondr committed Jan 10, 2024
1 parent 91954e1 commit 76a1fd5
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 2 deletions.
2 changes: 2 additions & 0 deletions presto-native-execution/presto_cpp/main/PrestoServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,8 @@ void PrestoServer::initializeVeloxMemory() {
options.checkUsageLeak = systemConfig->enableMemoryLeakCheck();
options.trackDefaultUsage =
systemConfig->enableSystemMemoryPoolUsageTracking();
options.coreOnAllocationFailureEnabled =
systemConfig->coreOnAllocationFailureEnabled();
if (!systemConfig->memoryArbitratorKind().empty()) {
options.arbitratorKind = systemConfig->memoryArbitratorKind();
const uint64_t queryMemoryGb = systemConfig->queryMemoryGb();
Expand Down
5 changes: 5 additions & 0 deletions presto-native-execution/presto_cpp/main/common/Configs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,11 @@ bool SystemConfig::enableMemoryLeakCheck() const {
return optionalProperty<bool>(kEnableMemoryLeakCheck).value();
}

bool SystemConfig::coreOnAllocationFailureEnabled() const {
return optionalProperty<bool>(kCoreOnAllocationFailureEnabled)
.value_or(false);
}

bool SystemConfig::skipRuntimeStatsInRunningTaskInfo() const {
return optionalProperty<bool>(kSkipRuntimeStatsInRunningTaskInfo).value();
}
Expand Down
6 changes: 6 additions & 0 deletions presto-native-execution/presto_cpp/main/common/Configs.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,10 @@ class SystemConfig : public ConfigBase {
static constexpr std::string_view kEnableMemoryLeakCheck{
"enable-memory-leak-check"};

/// Terminates the process and generates a core file on an allocation failure
static constexpr std::string_view kCoreOnAllocationFailureEnabled{
"core-on-allocation-failure-enabled"};

/// Do not include runtime stats in the returned task info if the task is
/// in running state.
static constexpr std::string_view kSkipRuntimeStatsInRunningTaskInfo{
Expand Down Expand Up @@ -600,6 +604,8 @@ class SystemConfig : public ConfigBase {

bool enableMemoryLeakCheck() const;

bool coreOnAllocationFailureEnabled() const;

bool skipRuntimeStatsInRunningTaskInfo() const;

bool logZombieTaskInfo() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ public class NativeExecutionSystemConfig
private static final String SHUFFLE_NAME = "shuffle.name";
// Feature flag for access log on presto-native http server
private static final String HTTP_SERVER_ACCESS_LOGS = "http-server.enable-access-log";
// Terminates the native process and generates a core file on an allocation failure
private static final String CORE_ON_ALLOCATION_FAILURE_ENABLED = "core-on-allocation-failure-enabled";
private boolean enableSerializedPageChecksum = true;
private boolean enableVeloxExpressionLogging;
private boolean enableVeloxTaskLogging = true;
Expand Down Expand Up @@ -133,6 +135,7 @@ public class NativeExecutionSystemConfig
private String shuffleName = "local";
private boolean registerTestFunctions;
private boolean enableHttpServerAccessLog = true;
private boolean coreOnAllocationFailureEnabled;

public Map<String, String> getAllProperties()
{
Expand Down Expand Up @@ -168,6 +171,7 @@ public Map<String, String> getAllProperties()
.put(ENABLE_OLD_TASK_CLEANUP, String.valueOf(getOldTaskCleanupMs()))
.put(SHUFFLE_NAME, getShuffleName())
.put(HTTP_SERVER_ACCESS_LOGS, String.valueOf(isEnableHttpServerAccessLog()))
.put(CORE_ON_ALLOCATION_FAILURE_ENABLED, String.valueOf(isCoreOnAllocationFailureEnabled()))
.build();
}

Expand Down Expand Up @@ -542,4 +546,16 @@ public boolean isEnableHttpServerAccessLog()
{
return enableHttpServerAccessLog;
}

public boolean isCoreOnAllocationFailureEnabled()
{
return coreOnAllocationFailureEnabled;
}

@Config(CORE_ON_ALLOCATION_FAILURE_ENABLED)
public NativeExecutionSystemConfig setCoreOnAllocationFailureEnabled(boolean coreOnAllocationFailureEnabled)
{
this.coreOnAllocationFailureEnabled = coreOnAllocationFailureEnabled;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ public void testNativeExecutionSystemConfig()
.setPrestoVersion("dummy.presto.version")
.setShuffleName("local")
.setRegisterTestFunctions(false)
.setEnableHttpServerAccessLog(true));
.setEnableHttpServerAccessLog(true)
.setCoreOnAllocationFailureEnabled(false));

// Test explicit property mapping. Also makes sure properties returned by getAllProperties() covers full property list.
NativeExecutionSystemConfig expected = new NativeExecutionSystemConfig()
Expand Down Expand Up @@ -124,7 +125,8 @@ public void testNativeExecutionSystemConfig()
.setOldTaskCleanupMs(true)
.setShuffleName("custom")
.setRegisterTestFunctions(true)
.setEnableHttpServerAccessLog(false);
.setEnableHttpServerAccessLog(false)
.setCoreOnAllocationFailureEnabled(true);
Map<String, String> properties = expected.getAllProperties();
assertFullMapping(properties, expected);
}
Expand Down

0 comments on commit 76a1fd5

Please sign in to comment.