forked from facebookincubator/velox
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/acvictor/velox into acvicto…
…r/updateFileHandleGen
- Loading branch information
Showing
240 changed files
with
9,655 additions
and
1,663 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,11 +72,8 @@ Blog posts are available [here](https://velox-lib.io/blog). | |
|
||
### Get the Velox Source | ||
``` | ||
git clone --recursive https://github.com/facebookincubator/velox.git | ||
git clone https://github.com/facebookincubator/velox.git | ||
cd velox | ||
# if you are updating an existing checkout | ||
git submodule sync --recursive | ||
git submodule update --init --recursive | ||
``` | ||
Once Velox is checked out, the first step is to install the dependencies. | ||
Details on the dependencies and how Velox manages some of them for you | ||
|
@@ -90,7 +87,7 @@ dependencies for a given platform. | |
On an Intel MacOS machine you can setup and then build like so: | ||
|
||
```shell | ||
$ ./scripts/setup-macos.sh | ||
$ ./scripts/setup-macos.sh | ||
$ make | ||
``` | ||
|
||
|
@@ -117,7 +114,7 @@ $ CPU_TARGET="aarch64" make | |
Once you have checked out Velox, you can setup and build like so: | ||
|
||
```shell | ||
$ ./scripts/setup-ubuntu.sh | ||
$ ./scripts/setup-ubuntu.sh | ||
$ make | ||
``` | ||
|
||
|
@@ -135,7 +132,7 @@ Note that, | |
* f16c | ||
* Velox tries to use the following (or equivalent) instruction sets where available: | ||
* On Intel CPUs | ||
* avx | ||
* avx | ||
* avx2 | ||
* sse | ||
* On ARM | ||
|
@@ -167,7 +164,7 @@ contribute to the project. | |
## Community | ||
|
||
The main communication channel with the Velox OSS community is through the | ||
[the Velox-OSS Slack workspace](http://velox-oss.slack.com). | ||
[the Velox-OSS Slack workspace](http://velox-oss.slack.com). | ||
Please reach out to **[email protected]** to get access to Velox Slack Channel. | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* 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/PeriodicStatsReporter.h" | ||
#include "velox/common/base/Counters.h" | ||
#include "velox/common/base/StatsReporter.h" | ||
#include "velox/common/memory/Memory.h" | ||
|
||
namespace facebook::velox { | ||
|
||
namespace { | ||
#define REPORT_IF_NOT_ZERO(name, counter) \ | ||
if ((counter) != 0) { \ | ||
RECORD_METRIC_VALUE((name), (counter)); \ | ||
} | ||
|
||
std::mutex& instanceMutex() { | ||
static std::mutex instanceMu; | ||
return instanceMu; | ||
} | ||
|
||
// Global instance. Must be called while holding a lock over instanceMutex(). | ||
std::unique_ptr<PeriodicStatsReporter>& instance() { | ||
static std::unique_ptr<PeriodicStatsReporter> reporter; | ||
return reporter; | ||
} | ||
} // namespace | ||
|
||
void startPeriodicStatsReporter(const PeriodicStatsReporter::Options& options) { | ||
std::lock_guard<std::mutex> l(instanceMutex()); | ||
auto& instanceRef = instance(); | ||
VELOX_CHECK_NULL( | ||
instanceRef, "The periodic stats reporter has already started."); | ||
instanceRef = std::make_unique<PeriodicStatsReporter>(options); | ||
instanceRef->start(); | ||
} | ||
|
||
void stopPeriodicStatsReporter() { | ||
std::lock_guard<std::mutex> l(instanceMutex()); | ||
auto& instanceRef = instance(); | ||
VELOX_CHECK_NOT_NULL(instanceRef, "No periodic stats reporter to stop."); | ||
instanceRef->stop(); | ||
instanceRef.reset(); | ||
} | ||
|
||
PeriodicStatsReporter::PeriodicStatsReporter(const Options& options) | ||
: arbitrator_(options.arbitrator), options_(options) {} | ||
|
||
void PeriodicStatsReporter::start() { | ||
LOG(INFO) << "Starting PeriodicStatsReporter with options " | ||
<< options_.toString(); | ||
addTask( | ||
"report_arbitrator_stats", | ||
[this]() { reportArbitratorStats(); }, | ||
options_.arbitratorStatsIntervalMs); | ||
} | ||
|
||
void PeriodicStatsReporter::stop() { | ||
LOG(INFO) << "Stopping PeriodicStatsReporter"; | ||
scheduler_.stop(); | ||
} | ||
|
||
void PeriodicStatsReporter::reportArbitratorStats() { | ||
if (arbitrator_ == nullptr) { | ||
return; | ||
} | ||
|
||
const auto stats = arbitrator_->stats(); | ||
RECORD_METRIC_VALUE( | ||
kMetricArbitratorFreeCapacityBytes, | ||
stats.freeCapacityBytes + stats.freeReservedCapacityBytes); | ||
RECORD_METRIC_VALUE( | ||
kMetricArbitratorFreeReservedCapacityBytes, | ||
stats.freeReservedCapacityBytes); | ||
} | ||
|
||
} // namespace facebook::velox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* 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 <folly/experimental/ThreadedRepeatingFunctionRunner.h> | ||
#include "velox/common/memory/MemoryArbitrator.h" | ||
|
||
namespace folly { | ||
class CPUThreadPoolExecutor; | ||
} | ||
|
||
namespace facebook::velox { | ||
|
||
namespace memory { | ||
class MemoryAllocator; | ||
} | ||
|
||
namespace cache { | ||
class AsyncDataCache; | ||
} | ||
|
||
/// Manages a background daemon thread to report stats through 'StatsReporter'. | ||
class PeriodicStatsReporter { | ||
public: | ||
struct Options { | ||
Options() {} | ||
|
||
const memory::MemoryArbitrator* arbitrator{nullptr}; | ||
|
||
uint64_t arbitratorStatsIntervalMs{60'000}; | ||
|
||
std::string toString() const { | ||
return fmt::format( | ||
"arbitratorStatsIntervalMs:{}", arbitratorStatsIntervalMs); | ||
} | ||
}; | ||
|
||
PeriodicStatsReporter(const Options& options = Options()); | ||
|
||
/// Invoked to start the report daemon in background. | ||
void start(); | ||
|
||
/// Invoked to stop the report daemon in background. | ||
void stop(); | ||
|
||
private: | ||
// Add a task to run periodically. | ||
template <typename TFunc> | ||
void addTask(const std::string& taskName, TFunc&& func, size_t intervalMs) { | ||
scheduler_.add( | ||
taskName, | ||
[taskName, | ||
intervalMs, | ||
func = std::forward<TFunc>(func)]() mutable noexcept { | ||
try { | ||
func(); | ||
} catch (const std::exception& e) { | ||
LOG(ERROR) << "Error running periodic task " << taskName << ": " | ||
<< e.what(); | ||
} | ||
return std::chrono::milliseconds(intervalMs); | ||
}); | ||
} | ||
|
||
void reportArbitratorStats(); | ||
|
||
const velox::memory::MemoryArbitrator* const arbitrator_{nullptr}; | ||
const Options options_; | ||
|
||
folly::ThreadedRepeatingFunctionRunner scheduler_; | ||
}; | ||
|
||
/// Initializes and starts the process-wide periodic stats reporter. Before | ||
/// 'stopPeriodicStatsReporter()' is called, this method can only be called once | ||
/// process-wide, and additional calls to this method will throw. | ||
void startPeriodicStatsReporter(const PeriodicStatsReporter::Options& options); | ||
|
||
/// Stops the process-wide periodic stats reporter. | ||
void stopPeriodicStatsReporter(); | ||
|
||
} // namespace facebook::velox |
Oops, something went wrong.