Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into complex-type-support-…
Browse files Browse the repository at this point in the history
…for-gte
  • Loading branch information
HeidiHan0000 committed Oct 11, 2024
2 parents 80f8748 + daeff59 commit 01d804a
Show file tree
Hide file tree
Showing 300 changed files with 8,985 additions and 2,648 deletions.
42 changes: 42 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright (c) Facebook, Inc. and its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# The CODEOWNERS file allows us to setup file based rules that will automatically
# request a review from owners on PRs with changes to matching files.
# We currently do not enforce these reviews as required so it's only a tool
# for more granular notifications at the moment. For example component maintainers
# can set a rule so that they are pinged on changes to the sections of the
# codebase that are relevant for their component.

# Only users that have write access to the repo can be added as owners.
# See the official docs for more details on syntax and precedence of rules: https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#example-of-a-codeowners-file

# Build & CI
CMake/ @assignUser @majetideepak
*.cmake @assignUser @majetideepak
**/CMakeLists.txt @assignUser @majetideepak
scripts/ @assignUser @majetideepak
.github/ @assignUser @majetideepak

# Parquet
velox/dwio/parquet/ @majetideepak

# Storage Adapters
velox/connectors/hive/storage_adapters/ @majetideepak

# Connectors
velox/connectors/ @majetideepak

# Caching
velox/common/caching/ @majetideepak
10 changes: 5 additions & 5 deletions CMake/resolve_dependency_modules/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ by Velox. See details on bundling below.
| re2 | 2021-04-01 | Yes |
| fmt | 10.1.1 | Yes |
| simdjson | 3.9.3 | Yes |
| folly | v2024.05.20.00 | Yes |
| fizz | v2024.05.20.00 | No |
| wangle | v2024.05.20.00 | No |
| mvfst | v2024.05.20.00 | No |
| fbthrift | v2024.05.20.00 | No |
| folly | v2024.07.01.00 | Yes |
| fizz | v2024.07.01.00 | No |
| wangle | v2024.07.01.00 | No |
| mvfst | v2024.07.01.00 | No |
| fbthrift | v2024.07.01.00 | No |
| libstemmer | 2.2.0 | Yes |
| DuckDB (testing) | 0.8.1 | Yes |
| cpr (testing) | 1.10.15 | Yes |
Expand Down
4 changes: 2 additions & 2 deletions CMake/resolve_dependency_modules/folly/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
project(Folly)
cmake_minimum_required(VERSION 3.14)

set(VELOX_FOLLY_BUILD_VERSION v2024.05.20.00)
set(VELOX_FOLLY_BUILD_VERSION v2024.07.01.00)
set(VELOX_FOLLY_BUILD_SHA256_CHECKSUM
f4a450e59f0b74d1b0b4e5c55ae38e820166c95d02f8a8a298e54a49a90aa057)
e78584ab7ba9a687285f2849bc0141e2422a5c808ad6ab3558c83d85975e25ed)
set(VELOX_FOLLY_SOURCE_URL
"https://github.com/facebook/folly/releases/download/${VELOX_FOLLY_BUILD_VERSION}/folly-${VELOX_FOLLY_BUILD_VERSION}.tar.gz"
)
Expand Down
7 changes: 4 additions & 3 deletions scripts/setup-centos9.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ USE_CLANG="${USE_CLANG:-false}"
export INSTALL_PREFIX=${INSTALL_PREFIX:-"/usr/local"}
DEPENDENCY_DIR=${DEPENDENCY_DIR:-$(pwd)/deps-download}

FB_OS_VERSION="v2024.05.20.00"
FB_OS_VERSION="v2024.07.01.00"
FMT_VERSION="10.1.1"
BOOST_VERSION="boost-1.84.0"
ARROW_VERSION="15.0.0"
Expand Down Expand Up @@ -138,7 +138,7 @@ function install_protobuf {
wget_and_untar https://github.com/protocolbuffers/protobuf/releases/download/v21.8/protobuf-all-21.8.tar.gz protobuf
(
cd ${DEPENDENCY_DIR}/protobuf
./configure --prefix=${INSTALL_PREFIX}
./configure CXXFLAGS="-fPIC" --prefix=${INSTALL_PREFIX}
make "-j${NPROC}"
make install
ldconfig
Expand Down Expand Up @@ -206,7 +206,8 @@ function install_arrow {
-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
-DCMAKE_BUILD_TYPE=Release \
-DARROW_BUILD_STATIC=ON \
-DThrift_SOURCE=BUNDLED
-DThrift_SOURCE=BUNDLED \
-DBOOST_ROOT=${INSTALL_PREFIX}

(
# Install thrift.
Expand Down
16 changes: 13 additions & 3 deletions scripts/setup-macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ set -x # Print commands that are executed.
SCRIPTDIR=$(dirname "${BASH_SOURCE[0]}")
export INSTALL_PREFIX=${INSTALL_PREFIX:-"$(pwd)/deps-install"}
source $SCRIPTDIR/setup-helper-functions.sh
PYTHON_VENV=${PYHTON_VENV:-"${SCRIPTDIR}/../.venv"}
PYTHON_VENV=${PYTHON_VENV:-"${SCRIPTDIR}/../.venv"}
# Allow installed package headers to be picked up before brew package headers
# by tagging the brew packages to be system packages.
# This is used during package builds.
Expand All @@ -42,9 +42,9 @@ BUILD_DUCKDB="${BUILD_DUCKDB:-true}"
DEPENDENCY_DIR=${DEPENDENCY_DIR:-$(pwd)}
MACOS_VELOX_DEPS="bison flex gflags glog googletest icu4c libevent libsodium lz4 lzo openssl protobuf@21 snappy xz zstd"
MACOS_BUILD_DEPS="ninja cmake"
FB_OS_VERSION="v2024.05.20.00"
FB_OS_VERSION="v2024.07.01.00"
FMT_VERSION="10.1.1"
FAST_FLOAT_VERSION="v6.1.6"
BOOST_VERSION="boost-1.84.0"
STEMMER_VERSION="2.2.0"

function update_brew {
Expand Down Expand Up @@ -99,6 +99,15 @@ function install_velox_deps_from_brew {
done
}

function install_boost {
wget_and_untar https://github.com/boostorg/boost/releases/download/${BOOST_VERSION}/${BOOST_VERSION}.tar.gz boost
(
cd ${DEPENDENCY_DIR}/boost
./bootstrap.sh --prefix=${INSTALL_PREFIX}
${SUDO} ./b2 "-j${NPROC}" -d0 install threading=multi --without-python
)
}

function install_fmt {
wget_and_untar https://github.com/fmtlib/fmt/archive/${FMT_VERSION}.tar.gz fmt
cmake_install_dir fmt -DFMT_TEST=OFF
Expand Down Expand Up @@ -168,6 +177,7 @@ function install_velox_deps {
run_and_time install_ranges_v3
run_and_time install_double_conversion
run_and_time install_re2
run_and_time install_boost
run_and_time install_fmt
run_and_time install_folly
run_and_time install_fizz
Expand Down
17 changes: 15 additions & 2 deletions scripts/setup-ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function install_clang15 {
${SUDO} apt install ${CLANG_PACKAGE_LIST} -y
}

FB_OS_VERSION="v2024.05.20.00"
FB_OS_VERSION="v2024.07.01.00"
FMT_VERSION="10.1.1"
BOOST_VERSION="boost-1.84.0"
ARROW_VERSION="15.0.0"
Expand Down Expand Up @@ -135,6 +135,17 @@ function install_boost {
)
}

function install_protobuf {
wget_and_untar https://github.com/protocolbuffers/protobuf/releases/download/v21.8/protobuf-all-21.8.tar.gz protobuf
(
cd ${DEPENDENCY_DIR}/protobuf
./configure CXXFLAGS="-fPIC" --prefix=${INSTALL_PREFIX}
make "-j${NPROC}"
make install
ldconfig
)
}

function install_folly {
wget_and_untar https://github.com/facebook/folly/archive/refs/tags/${FB_OS_VERSION}.tar.gz folly
cmake_install_dir folly -DBUILD_TESTS=OFF -DFOLLY_HAVE_INT128_T=ON
Expand Down Expand Up @@ -214,7 +225,8 @@ function install_arrow {
-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
-DCMAKE_BUILD_TYPE=Release \
-DARROW_BUILD_STATIC=ON \
-DThrift_SOURCE=BUNDLED
-DThrift_SOURCE=BUNDLED \
-DBOOST_ROOT=${INSTALL_PREFIX}

(
# Install thrift.
Expand All @@ -237,6 +249,7 @@ function install_cuda {
function install_velox_deps {
run_and_time install_velox_deps_from_apt
run_and_time install_fmt
run_and_time install_protobuf
run_and_time install_boost
run_and_time install_folly
run_and_time install_fizz
Expand Down
91 changes: 91 additions & 0 deletions velox/common/base/AdmissionController.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "velox/common/base/AdmissionController.h"

#include "velox/common/base/Exceptions.h"
#include "velox/common/base/StatsReporter.h"
#include "velox/common/time/Timer.h"

namespace facebook::velox::common {

void AdmissionController::accept(uint64_t resourceUnits) {
ContinueFuture future;
uint64_t updatedValue = 0;
VELOX_CHECK_LE(
resourceUnits,
config_.maxLimit,
"A single request cannot exceed the max limit");
{
std::lock_guard<std::mutex> l(mu_);
if (unitsUsed_ + resourceUnits > config_.maxLimit) {
auto [unblockPromise, unblockFuture] = makeVeloxContinuePromiseContract();
Request req;
req.unitsRequested = resourceUnits;
req.promise = std::move(unblockPromise);
queue_.push_back(std::move(req));
future = std::move(unblockFuture);
} else {
updatedValue = unitsUsed_ += resourceUnits;
}
}
if (!future.valid()) {
// Only upadate if there was no wait, as the releasing thread is responsible
// for updating the metric.
if (!config_.resourceUsageAvgMetric.empty()) {
RECORD_METRIC_VALUE(config_.resourceUsageAvgMetric, updatedValue);
}
return;
}
if (!config_.resourceQueuedCountMetric.empty()) {
RECORD_METRIC_VALUE(config_.resourceQueuedCountMetric);
}
uint64_t waitTimeUs{0};
{
MicrosecondTimer timer(&waitTimeUs);
future.wait();
}
if (!config_.resourceQueuedTimeMsHistogramMetric.empty()) {
RECORD_HISTOGRAM_METRIC_VALUE(
config_.resourceQueuedTimeMsHistogramMetric, waitTimeUs / 1'000);
}
}

void AdmissionController::release(uint64_t resourceUnits) {
uint64_t updatedValue = 0;
{
std::lock_guard<std::mutex> l(mu_);
VELOX_CHECK_LE(
resourceUnits,
unitsUsed_,
"Cannot release more units than have been acquired");
unitsUsed_ -= resourceUnits;
while (!queue_.empty()) {
auto& request = queue_.front();
if (unitsUsed_ + request.unitsRequested > config_.maxLimit) {
break;
}
unitsUsed_ += request.unitsRequested;
request.promise.setValue();
queue_.pop_front();
}
updatedValue = unitsUsed_;
}
if (!config_.resourceUsageAvgMetric.empty()) {
RECORD_METRIC_VALUE(config_.resourceUsageAvgMetric, updatedValue);
}
}
} // namespace facebook::velox::common
67 changes: 67 additions & 0 deletions velox/common/base/AdmissionController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once

#include <deque>
#include <mutex>
#include "velox/common/future/VeloxPromise.h"

namespace facebook::velox::common {

/// A generic admission controller that can be used to limit the number of
/// resources in use and can log metrics like resource usage, queued count,
/// queued wait times. When a calling thread's request for resources surpasses
/// the set limit, it will be placed in a FIFO queue. The thread must then wait
/// until sufficient resources are freed by other threads, addressing all
/// preceding requests in the queue, before its own request can be granted.
class AdmissionController {
public:
struct Config {
/// The maximum number of resource units that can be used at any given time.
/// Set to a default value of max unit64 to signify unlimited limit.
uint64_t maxLimit{std::numeric_limits<uint64_t>::max()};
/// The metric name for resource usage. If not set, it will not be reported.
/// Should be a registered as a average metric.
std::string resourceUsageAvgMetric;
/// The metric name for resource queued count. If not set, it will not be
/// reported. Should be a registered as a count metric.
std::string resourceQueuedCountMetric;
/// The metric name for resource queued wait time. If not set, it will not
/// be reported. Should be a registered as a histogram metric.
std::string resourceQueuedTimeMsHistogramMetric;
};
explicit AdmissionController(const Config& config) : config_(config) {}

// Accept can block until sufficient resources are freed by other threads.
void accept(uint64_t resourceUnits);
void release(uint64_t resourceUnits);

uint64_t currentResourceUsage() const {
std::lock_guard<std::mutex> l(mu_);
return unitsUsed_;
}

private:
struct Request {
uint64_t unitsRequested;
ContinuePromise promise;
};
Config config_;
mutable std::mutex mu_;
uint64_t unitsUsed_{0};
std::deque<Request> queue_;
};
} // namespace facebook::velox::common
1 change: 1 addition & 0 deletions velox/common/base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ velox_link_libraries(

velox_add_library(
velox_common_base
AdmissionController.cpp
BitUtil.cpp
Counters.cpp
Fs.cpp
Expand Down
Loading

0 comments on commit 01d804a

Please sign in to comment.