You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@orc.apache.org by do...@apache.org on 2022/08/05 15:41:44 UTC
[orc] branch main updated: ORC-1232:[C++] Disable the metrics collector at compile phase
This is an automated email from the ASF dual-hosted git repository.
dongjoon pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/orc.git
The following commit(s) were added to refs/heads/main by this push:
new 7f7362bdc ORC-1232:[C++] Disable the metrics collector at compile phase
7f7362bdc is described below
commit 7f7362bdcecfd48e5ff9f4a3255100e3ea724f6f
Author: coderex2522 <re...@gmail.com>
AuthorDate: Fri Aug 5 08:41:32 2022 -0700
ORC-1232:[C++] Disable the metrics collector at compile phase
### What changes were proposed in this pull request?
The patch will disable the metrics collector at the compile time.
### Why are the changes needed?
The metrics collector could cause performance degradation in some [cases](https://issues.apache.org/jira/projects/ORC/issues/ORC-1232).
### How was this patch tested?
The option BUILD_CPP_ENABLE_METRICS set to ON will triggers the related UTs.
Closes #1206 from coderex2522/ORC-1232.
Lead-authored-by: coderex2522 <re...@gmail.com>
Co-authored-by: Dongjoon Hyun <do...@apache.org>
Signed-off-by: Dongjoon Hyun <do...@apache.org>
---
CMakeLists.txt | 12 ++++++++++++
c++/include/orc/Reader.hh | 1 +
c++/src/Options.hh | 2 +-
c++/src/OrcFile.cc | 8 ++++++++
c++/src/OrcHdfsFile.cc | 8 ++++++++
c++/src/Utils.hh | 5 +++++
tools/src/FileScan.cc | 3 +++
7 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2dff2d66e..d030d3cd3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -60,6 +60,10 @@ option(BUILD_POSITION_INDEPENDENT_LIB
"Compile static libraries with position independent code"
OFF)
+option(BUILD_CPP_ENABLE_METRICS
+ "Enable the metrics collection at compile phase"
+ OFF)
+
# Make sure that a build type is selected
if (NOT CMAKE_BUILD_TYPE)
message(STATUS "No build type selected, default to ReleaseWithDebugInfo")
@@ -130,6 +134,14 @@ elseif (MSVC)
set (WARN_FLAGS "${WARN_FLAGS} -wd4146") # unary minus operator applied to unsigned type, result still unsigned
endif ()
+if (BUILD_CPP_ENABLE_METRICS)
+ message(STATUS "Enable the metrics collection")
+ add_compile_definitions(ENABLE_METRICS=1)
+else ()
+ message(STATUS "Disable the metrics collection")
+ add_compile_definitions(ENABLE_METRICS=0)
+endif ()
+
enable_testing()
INCLUDE(CheckSourceCompiles)
diff --git a/c++/include/orc/Reader.hh b/c++/include/orc/Reader.hh
index 1bfb8bea0..6f4aaf67d 100644
--- a/c++/include/orc/Reader.hh
+++ b/c++/include/orc/Reader.hh
@@ -102,6 +102,7 @@ namespace orc {
/**
* Set the reader metrics.
*
+ * Defaults to nullptr.
* When set to nullptr, the reader metrics will be disabled.
*/
ReaderOptions& setReaderMetrics(ReaderMetrics* metrics);
diff --git a/c++/src/Options.hh b/c++/src/Options.hh
index 36fec500d..50363c5b3 100644
--- a/c++/src/Options.hh
+++ b/c++/src/Options.hh
@@ -48,7 +48,7 @@ namespace orc {
tailLocation = std::numeric_limits<uint64_t>::max();
errorStream = &std::cerr;
memoryPool = getDefaultPool();
- metrics = getDefaultReaderMetrics();
+ metrics = nullptr;
}
};
diff --git a/c++/src/OrcFile.cc b/c++/src/OrcFile.cc
index 9b7fc7b75..5f4544cee 100644
--- a/c++/src/OrcFile.cc
+++ b/c++/src/OrcFile.cc
@@ -40,6 +40,12 @@
namespace orc {
+DIAGNOSTIC_PUSH
+
+#ifdef __clang__
+ DIAGNOSTIC_IGNORE("-Wunused-private-field")
+#endif
+
class FileInputStream : public InputStream {
private:
std::string filename;
@@ -112,6 +118,8 @@ namespace orc {
#endif
}
+DIAGNOSTIC_POP
+
std::unique_ptr<InputStream> readLocalFile(const std::string& path,
ReaderMetrics* metrics) {
return std::unique_ptr<InputStream>(new FileInputStream(path, metrics));
diff --git a/c++/src/OrcHdfsFile.cc b/c++/src/OrcHdfsFile.cc
index 381e96cef..103d41369 100644
--- a/c++/src/OrcHdfsFile.cc
+++ b/c++/src/OrcHdfsFile.cc
@@ -34,6 +34,12 @@
namespace orc {
+DIAGNOSTIC_PUSH
+
+#ifdef __clang__
+ DIAGNOSTIC_IGNORE("-Wunused-private-field")
+#endif
+
class HdfsFileInputStream : public InputStream {
private:
std::string filename;
@@ -170,6 +176,8 @@ namespace orc {
~HdfsFileInputStream() override;
};
+DIAGNOSTIC_POP
+
HdfsFileInputStream::~HdfsFileInputStream() {
}
diff --git a/c++/src/Utils.hh b/c++/src/Utils.hh
index 6f478f583..129356dce 100644
--- a/c++/src/Utils.hh
+++ b/c++/src/Utils.hh
@@ -60,6 +60,7 @@ public:
}
};
+#if ENABLE_METRICS
#define SCOPED_STOPWATCH(METRICS_PTR, LATENCY_VAR, COUNT_VAR) \
AutoStopwatch measure( \
(METRICS_PTR == nullptr ? nullptr : &METRICS_PTR->LATENCY_VAR), \
@@ -69,6 +70,10 @@ public:
AutoStopwatch measure( \
(METRICS_PTR == nullptr ? nullptr : &METRICS_PTR->LATENCY_VAR), \
nullptr, true)
+#else
+#define SCOPED_STOPWATCH(METRICS_PTR, LATENCY_VAR, COUNT_VAR)
+#define SCOPED_MINUS_STOPWATCH(METRICS_PTR, LATENCY_VAR)
+#endif
}
diff --git a/tools/src/FileScan.cc b/tools/src/FileScan.cc
index 8ed6b7b6e..85abb6c73 100644
--- a/tools/src/FileScan.cc
+++ b/tools/src/FileScan.cc
@@ -24,6 +24,9 @@ void scanFile(std::ostream & out, const char* filename, uint64_t batchSize,
const orc::RowReaderOptions& rowReaderOpts,
bool showMetrics) {
orc::ReaderOptions readerOpts;
+ if (showMetrics) {
+ readerOpts.setReaderMetrics(orc::getDefaultReaderMetrics());
+ }
std::unique_ptr<orc::Reader> reader =
orc::createReader(orc::readFile(filename,
readerOpts.getReaderMetrics()),