-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve operator tracing and make it E2E work (#11360)
Summary: Pull Request resolved: #11360 This PR improves the operator trace framework and replay tool implementation: (1) Let driver execution framework to handle the trace input collection and summary file generation. The finish trace is either called when trace limit exceeds or on operator close instead of no more input. So it can capture more information in summary like peak memory usage. By removing the trace input collection into the driver framework it eases the trace input collection for a spilling operator. We add to capture the peak memory and input rows in summary so it helps identify the hot operator or task on replay debugging. (2) Change the trace storage layout to have root with query id for traces from different tasks (3) Abstract the replay tool function into TraceReplayRunner class and derive in Meta internal code repo to handle the Meta internal env setup and keep most common part in TraceReplayRunner for OSS (4) A couple of fixes in trace replay tool to make it E2E function in Meta for table writer use case (5) A couple of file/class renaming to make the file/class name to be more specific as currently we only support operator level trace collection and replay Differential Revision: D64946367
- Loading branch information
1 parent
6440a44
commit 4117e6f
Showing
54 changed files
with
1,285 additions
and
656 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 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
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
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,79 @@ | ||
/* | ||
* 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 <utility> | ||
|
||
#include "velox/exec/OperatorTraceReader.h" | ||
|
||
#include "velox/exec/TraceUtil.h" | ||
|
||
namespace facebook::velox::exec::trace { | ||
|
||
OperatorTraceInputReader::OperatorTraceInputReader( | ||
std::string traceDir, | ||
RowTypePtr dataType, | ||
memory::MemoryPool* pool) | ||
: traceDir_(std::move(traceDir)), | ||
fs_(filesystems::getFileSystem(traceDir_, nullptr)), | ||
dataType_(std::move(dataType)), | ||
pool_(pool), | ||
inputStream_(getInputStream()) { | ||
VELOX_CHECK_NOT_NULL(dataType_); | ||
VELOX_CHECK_NOT_NULL(inputStream_); | ||
} | ||
|
||
bool OperatorTraceInputReader::read(RowVectorPtr& batch) const { | ||
if (inputStream_->atEnd()) { | ||
batch = nullptr; | ||
return false; | ||
} | ||
|
||
VectorStreamGroup::read( | ||
inputStream_.get(), pool_, dataType_, &batch, &readOptions_); | ||
return true; | ||
} | ||
|
||
std::unique_ptr<common::FileInputStream> | ||
OperatorTraceInputReader::getInputStream() const { | ||
auto traceFile = fs_->openFileForRead(getOpTraceInputFilePath(traceDir_)); | ||
// TODO: Make the buffer size configurable. | ||
return std::make_unique<common::FileInputStream>( | ||
std::move(traceFile), 1 << 20, pool_); | ||
} | ||
|
||
OperatorTraceSummaryReader::OperatorTraceSummaryReader( | ||
std::string traceDir, | ||
memory::MemoryPool* pool) | ||
: traceDir_(std::move(traceDir)), | ||
fs_(filesystems::getFileSystem(traceDir_, nullptr)), | ||
pool_(pool), | ||
summaryFile_(fs_->openFileForRead(getOpTraceSummaryFilePath(traceDir_))) { | ||
} | ||
|
||
OperatorTraceSummary OperatorTraceSummaryReader::read() const { | ||
VELOX_CHECK_NOT_NULL(summaryFile_); | ||
const auto summaryStr = summaryFile_->pread(0, summaryFile_->size()); | ||
VELOX_CHECK(!summaryStr.empty()); | ||
|
||
folly::dynamic summaryObj = folly::parseJson(summaryStr); | ||
OperatorTraceSummary summary; | ||
summary.exceededTraceLimit = | ||
summaryObj[OperatorTraceTraits::kTraceLimitExceededKey].asBool(); | ||
summary.peakMemory = summaryObj[OperatorTraceTraits::kPeakMemoryKey].asInt(); | ||
summary.inputRows = summaryObj[OperatorTraceTraits::kInputRowsKey].asInt(); | ||
return summary; | ||
} | ||
} // namespace facebook::velox::exec::trace |
Oops, something went wrong.