Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ jobs:
github.event_name == 'schedule' || needs.changes.outputs.codechange == 'true'
run: |
export PRESTO_SERVER_PATH="${GITHUB_WORKSPACE}/presto-native-execution/_build/release/presto_cpp/main/presto_server"
export TESTFILES=`find ./presto-native-tests/src/test -type f -name 'Test*.java'`
export TESTFILES=`find ./presto-native-tests/src/test -type f -name 'Test*.java' | grep -v 'cudf/'`
# Convert file paths to comma separated class names
export TESTCLASSES=
for test_file in $TESTFILES
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "presto-native-execution/velox"]
path = presto-native-execution/velox
url = https://github.com/facebookincubator/velox.git
url = https://github.com/pramodsatya/velox.git
5 changes: 4 additions & 1 deletion presto-native-execution/etc_sidecar/config.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
discovery.uri=http://127.0.0.1:<replace_port>
discovery.uri=http://presto-coordinator:8080
presto.version=testversion
http-server.http.port=7778
shutdown-onset-sec=1
runtime-metrics-collection-enabled=true
native-sidecar=true
presto.default-namespace=native.default
cudf.enabled=true
cudf.debug_enabled=true
cudf.allow_cpu_fallback=true
4 changes: 2 additions & 2 deletions presto-native-execution/etc_sidecar/node.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
node.environment=testing
node.internal-address=127.0.0.1
node.environment=test
node.internal-address=172.24.0.3
node.location=testing-location
12 changes: 7 additions & 5 deletions presto-native-execution/presto_cpp/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ add_subdirectory(thrift)
add_subdirectory(connectors)
add_subdirectory(functions)
add_subdirectory(tool)

add_library(presto_session_properties SessionProperties.cpp)

target_link_libraries(presto_session_properties ${FOLLY_WITH_DEPENDENCIES})
add_subdirectory(sidecar)

add_library(
presto_server_lib
Expand Down Expand Up @@ -112,7 +109,12 @@ target_link_libraries(
)

if(PRESTO_ENABLE_CUDF)
target_link_libraries(presto_server_lib velox_cudf_exec)
target_link_libraries(
presto_server_lib
presto_cudf_function_metadata
presto_cudf_session_properties
velox_cudf_exec
)
endif()

# Enabling Parquet causes build errors with missing symbols on MacOS. This is
Expand Down
54 changes: 43 additions & 11 deletions presto-native-execution/presto_cpp/main/PrestoServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "presto_cpp/main/CoordinatorDiscoverer.h"
#include "presto_cpp/main/PeriodicMemoryChecker.h"
#include "presto_cpp/main/PeriodicTaskManager.h"
#include "presto_cpp/main/SessionProperties.h"
#include "presto_cpp/main/SignalHandler.h"
#include "presto_cpp/main/TaskResource.h"
#include "presto_cpp/main/common/ConfigReader.h"
Expand All @@ -31,7 +30,6 @@
#include "presto_cpp/main/connectors/Registration.h"
#include "presto_cpp/main/connectors/SystemConnector.h"
#include "presto_cpp/main/connectors/hive/functions/HiveFunctionRegistration.h"
#include "presto_cpp/main/functions/FunctionMetadata.h"
#include "presto_cpp/main/http/HttpConstants.h"
#include "presto_cpp/main/http/filters/AccessLogFilter.h"
#include "presto_cpp/main/http/filters/HttpEndpointLatencyFilter.h"
Expand All @@ -44,6 +42,8 @@
#include "presto_cpp/main/operators/ShuffleExchangeSource.h"
#include "presto_cpp/main/operators/ShuffleRead.h"
#include "presto_cpp/main/operators/ShuffleWrite.h"
#include "presto_cpp/main/sidecar/function/NativeFunctionMetadata.h"
#include "presto_cpp/main/sidecar/properties/SessionProperties.h"
#include "presto_cpp/main/types/ExpressionOptimizer.h"
#include "presto_cpp/main/types/PrestoToVeloxQueryPlan.h"
#include "presto_cpp/main/types/VeloxPlanConversion.h"
Expand Down Expand Up @@ -77,6 +77,8 @@
#include "velox/serializers/UnsafeRowSerializer.h"

#ifdef PRESTO_ENABLE_CUDF
#include "presto_cpp/main/sidecar/function/CudfFunctionMetadata.h"
#include "presto_cpp/main/sidecar/properties/CudfSessionProperties.h"
#include "velox/experimental/cudf/CudfConfig.h"
#include "velox/experimental/cudf/exec/ToCudf.h"
#endif
Expand Down Expand Up @@ -1817,32 +1819,62 @@ void PrestoServer::handleGracefulShutdown(

void PrestoServer::registerSidecarEndpoints() {
VELOX_CHECK(httpServer_);

httpServer_->registerGet(
"/v1/properties/session",
[this](
[](
proxygen::HTTPMessage* /*message*/,
const std::vector<std::unique_ptr<folly::IOBuf>>& /*body*/,
proxygen::ResponseHandler* downstream) {
#ifdef PRESTO_ENABLE_CUDF
const auto* sessionProperties =
facebook::presto::cudf::CudfSessionProperties::instance();
http::sendOkResponse(downstream, sessionProperties->serialize());
#else
const auto* sessionProperties = SessionProperties::instance();
http::sendOkResponse(downstream, sessionProperties->serialize());
#endif
});

httpServer_->registerGet(
"/v1/functions",
[](proxygen::HTTPMessage* /*message*/,
const std::vector<std::unique_ptr<folly::IOBuf>>& /*body*/,
proxygen::ResponseHandler* downstream) {
http::sendOkResponse(downstream, getFunctionsMetadata());
[](
proxygen::HTTPMessage* /*message*/,
const std::vector<std::unique_ptr<folly::IOBuf>>& /*body*/,
proxygen::ResponseHandler* downstream) {
#ifdef PRESTO_ENABLE_CUDF
http::sendOkResponse(
downstream,
presto::cudf::cudfFunctionMetadataProvider().getFunctionsMetadata(
std::nullopt));
#else
http::sendOkResponse(
downstream,
nativeFunctionMetadata().getFunctionsMetadata(
std::nullopt));
#endif
});

httpServer_->registerGet(
R"(/v1/functions/([^/]+))",
[](proxygen::HTTPMessage* /*message*/,
const std::vector<std::string>& pathMatch) {
[](
proxygen::HTTPMessage* /*message*/,
const std::vector<std::string>& pathMatch) {
return new http::CallbackRequestHandler(
[catalog = pathMatch[1]](
[catalog = pathMatch[1]](
proxygen::HTTPMessage* /*message*/,
std::vector<std::unique_ptr<folly::IOBuf>>& /*body*/,
proxygen::ResponseHandler* downstream) {
http::sendOkResponse(downstream, getFunctionsMetadata(catalog));
#ifdef PRESTO_ENABLE_CUDF
http::sendOkResponse(
downstream,
presto::cudf::cudfFunctionMetadataProvider()
.getFunctionsMetadata(catalog));
#else
http::sendOkResponse(
downstream,
nativeFunctionMetadata().getFunctionsMetadata(catalog));
#endif
});
});
httpServer_->registerPost(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
*/

#include "presto_cpp/main/PrestoToVeloxQueryConfig.h"
#include "presto_cpp/main/SessionProperties.h"
#include "presto_cpp/main/common/Configs.h"
#include "presto_cpp/main/sidecar/properties/SessionProperties.h"
#include "velox/common/compression/Compression.h"
#include "velox/core/QueryConfig.h"
#include "velox/type/tz/TimeZoneMap.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#include "presto_cpp/main/QueryContextManager.h"
#include <folly/executors/IOThreadPoolExecutor.h>
#include "presto_cpp/main/PrestoToVeloxQueryConfig.h"
#include "presto_cpp/main/SessionProperties.h"
#include "presto_cpp/main/common/Configs.h"
#include "presto_cpp/main/sidecar/properties/SessionProperties.h"
#include "velox/connectors/hive/HiveConfig.h"
#include "velox/core/QueryConfig.h"

Expand Down
4 changes: 4 additions & 0 deletions presto-native-execution/presto_cpp/main/common/Configs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,10 @@ bool SystemConfig::prestoNativeSidecar() const {
return optionalProperty<bool>(kNativeSidecar).value();
}

std::string SystemConfig::executionMode() const {
return optionalProperty<std::string>(kExecutionMode).value_or("cpu");
}

uint32_t SystemConfig::systemMemLimitGb() const {
return optionalProperty<uint32_t>(kSystemMemLimitGb).value();
}
Expand Down
7 changes: 7 additions & 0 deletions presto-native-execution/presto_cpp/main/common/Configs.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,10 @@ class SystemConfig : public ConfigBase {
/// Indicates if the process is configured as a sidecar.
static constexpr std::string_view kNativeSidecar{"native-sidecar"};

/// Execution mode: "cpu" for Velox/CPU execution or "cudf" for CUDF GPU
/// execution. Default is "cpu".
static constexpr std::string_view kExecutionMode{"execution-mode"};

/// If true, enable memory pushback when the server is under low memory
/// condition. This only applies if 'system-mem-limit-gb' is set.
static constexpr std::string_view kSystemMemPushbackEnabled{
Expand Down Expand Up @@ -1227,6 +1231,9 @@ class SystemConfig : public ConfigBase {

bool prestoNativeSidecar() const;

/// Returns the execution mode ("cpu" or "cudf"). Defaults to "cpu".
std::string executionMode() const;

std::string prestoDefaultNamespacePrefix() const;

std::string poolType() const;
Expand Down
4 changes: 4 additions & 0 deletions presto-native-execution/presto_cpp/main/common/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,8 @@ const std::vector<std::string> getFunctionNameParts(
fmt::format("Prefix missing for function {}", registeredFunction));
return parts;
}

std::string boolToString(bool value) {
return value ? "true" : "false";
}
} // namespace facebook::presto::util
3 changes: 3 additions & 0 deletions presto-native-execution/presto_cpp/main/common/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,7 @@ inline std::string addDefaultNamespacePrefix(
/// three parts, {catalog, schema, function_name}, from the registered function.
const std::vector<std::string> getFunctionNameParts(
const std::string& registeredFunction);

/// Convert boolean to lowercase string representation.
std::string boolToString(bool value);
} // namespace facebook::presto::util
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

add_library(presto_function_metadata OBJECT FunctionMetadata.cpp)
target_link_libraries(presto_function_metadata presto_common velox_function_registry)

add_subdirectory(dynamic_registry)

if(PRESTO_ENABLE_REMOTE_FUNCTIONS)
add_subdirectory(remote)
endif()

if(PRESTO_ENABLE_TESTING)
add_subdirectory(tests)
endif()
Loading
Loading