Repository: incubator-impala
Updated Branches:
  refs/heads/master a2caacf87 -> 8afb59045


IMPALA-4764: Add Hedged read metrics

The following Hadoop metrics have been added to the /metrics page:

hedgedReadOps - the number of hedged reads that have occurred

hedgedReadOpsWin - the number of times the hedged read returned
faster than the original read

The metrics will be updated only when --use_hdfs_pread is set to
'true'.

This change depends on the following new commit to HDFS:
https://github.com/apache/hadoop/commit/8c81a16a1fa40d3a3796b1c3633328f1340883ca

Testing: Not adding tests since it requires some custom hadoop
configuration. Tested manually by setting the configurations and
verifying that the metrics work.

Change-Id: Id4a5d396abb3373d352ad2df8c2272db018114da
Reviewed-on: http://gerrit.cloudera.org:8080/6886
Reviewed-by: Matthew Jacobs <[email protected]>
Reviewed-by: Lars Volker <[email protected]>
Tested-by: Impala Public Jenkins


Project: http://git-wip-us.apache.org/repos/asf/incubator-impala/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-impala/commit/c826af68
Tree: http://git-wip-us.apache.org/repos/asf/incubator-impala/tree/c826af68
Diff: http://git-wip-us.apache.org/repos/asf/incubator-impala/diff/c826af68

Branch: refs/heads/master
Commit: c826af6831719cfe5e967a56099493a103c68a90
Parents: a2caacf
Author: Sailesh Mukil <[email protected]>
Authored: Fri May 12 15:18:13 2017 -0700
Committer: Impala Public Jenkins <[email protected]>
Committed: Mon May 15 22:57:32 2017 +0000

----------------------------------------------------------------------
 be/src/runtime/disk-io-mgr-scan-range.cc | 14 ++++++++++++++
 be/src/util/impalad-metrics.cc           | 11 +++++++++++
 be/src/util/impalad-metrics.h            | 12 +++++++++++-
 common/thrift/metrics.json               | 20 ++++++++++++++++++++
 4 files changed, 56 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/c826af68/be/src/runtime/disk-io-mgr-scan-range.cc
----------------------------------------------------------------------
diff --git a/be/src/runtime/disk-io-mgr-scan-range.cc 
b/be/src/runtime/disk-io-mgr-scan-range.cc
index 5111b70..9ccd1da 100644
--- a/be/src/runtime/disk-io-mgr-scan-range.cc
+++ b/be/src/runtime/disk-io-mgr-scan-range.cc
@@ -345,6 +345,20 @@ void DiskIoMgr::ScanRange::Close() {
         }
         hdfsFileFreeReadStatistics(stats);
       }
+
+      if (FLAGS_use_hdfs_pread) {
+        // Update Hedged Read Metrics.
+        // We call it only if the --use_hdfs_pread flag is set, to avoid 
having the
+        // libhdfs client malloc and free a hdfsHedgedReadMetrics object 
unnecessarily
+        // otherwise.
+        struct hdfsHedgedReadMetrics* hedged_metrics;
+        success = hdfsGetHedgedReadMetrics(fs_, &hedged_metrics);
+        if (success == 0) {
+          
ImpaladMetrics::HEDGED_READ_OPS->set_value(hedged_metrics->hedgedReadOps);
+          
ImpaladMetrics::HEDGED_READ_OPS_WIN->set_value(hedged_metrics->hedgedReadOpsWin);
+        }
+        hdfsFreeHedgedReadMetrics(hedged_metrics);
+      }
     }
     if (external_buffer_tag_ == ExternalBufferTag::CACHED_BUFFER) {
       hadoopRzBufferFree(hdfs_file_->file(), cached_buffer_);

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/c826af68/be/src/util/impalad-metrics.cc
----------------------------------------------------------------------
diff --git a/be/src/util/impalad-metrics.cc b/be/src/util/impalad-metrics.cc
index 271f8d7..7155a8d 100644
--- a/be/src/util/impalad-metrics.cc
+++ b/be/src/util/impalad-metrics.cc
@@ -100,6 +100,10 @@ const char* ImpaladMetricKeys::QUERY_DURATIONS =
     "impala-server.query-durations-ms";
 const char* ImpaladMetricKeys::DDL_DURATIONS =
     "impala-server.ddl-durations-ms";
+const char* ImpaladMetricKeys::HEDGED_READ_OPS =
+    "impala-server.hedged-read-ops";
+const char* ImpaladMetricKeys::HEDGED_READ_OPS_WIN =
+    "impala-server.hedged-read-ops-win";
 
 // These are created by impala-server during startup.
 // =======
@@ -118,6 +122,8 @@ IntCounter* ImpaladMetrics::IO_MGR_LOCAL_BYTES_READ = NULL;
 IntCounter* ImpaladMetrics::IO_MGR_SHORT_CIRCUIT_BYTES_READ = NULL;
 IntCounter* ImpaladMetrics::IO_MGR_CACHED_BYTES_READ = NULL;
 IntCounter* ImpaladMetrics::IO_MGR_BYTES_WRITTEN = NULL;
+IntCounter* ImpaladMetrics::HEDGED_READ_OPS = NULL;
+IntCounter* ImpaladMetrics::HEDGED_READ_OPS_WIN = NULL;
 
 // Gauges
 IntGauge* ImpaladMetrics::CATALOG_NUM_DBS = NULL;
@@ -243,6 +249,11 @@ void ImpaladMetrics::CreateMetrics(MetricGroup* m) {
       MetricDefs::Get(ImpaladMetricKeys::QUERY_DURATIONS), FIVE_HOURS_IN_MS, 
3));
   DDL_DURATIONS = m->RegisterMetric(new HistogramMetric(
       MetricDefs::Get(ImpaladMetricKeys::DDL_DURATIONS), FIVE_HOURS_IN_MS, 3));
+
+  // Initialize Hedged read metrics
+  HEDGED_READ_OPS = m->AddCounter<int64_t>(ImpaladMetricKeys::HEDGED_READ_OPS, 
0);
+  HEDGED_READ_OPS_WIN = 
m->AddCounter<int64_t>(ImpaladMetricKeys::HEDGED_READ_OPS_WIN, 0);
+
 }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/c826af68/be/src/util/impalad-metrics.h
----------------------------------------------------------------------
diff --git a/be/src/util/impalad-metrics.h b/be/src/util/impalad-metrics.h
index cc3162a..2dafc6a 100644
--- a/be/src/util/impalad-metrics.h
+++ b/be/src/util/impalad-metrics.h
@@ -139,9 +139,17 @@ class ImpaladMetricKeys {
   /// Total bytes consumed for rows cached to support HS2 FETCH_FIRST.
   static const char* RESULTSET_CACHE_TOTAL_BYTES;
 
-  // Distribution of execution times for queries and DDL statements, in ms.
+  /// Distribution of execution times for queries and DDL statements, in ms.
   static const char* QUERY_DURATIONS;
   static const char* DDL_DURATIONS;
+
+  /// Total number of attempted hedged reads operations.
+  static const char* HEDGED_READ_OPS;
+
+  /// Total number of hedged reads operations that won
+  /// (i.e. returned faster than original read).
+  static const char* HEDGED_READ_OPS_WIN;
+
 };
 
 /// Global impalad-wide metrics.  This is useful for objects that want to 
update metrics
@@ -165,6 +173,8 @@ class ImpaladMetrics {
   static IntCounter* IO_MGR_CACHED_BYTES_READ;
   static IntCounter* IO_MGR_SHORT_CIRCUIT_BYTES_READ;
   static IntCounter* IO_MGR_BYTES_WRITTEN;
+  static IntCounter* HEDGED_READ_OPS;
+  static IntCounter* HEDGED_READ_OPS_WIN;
 
   // Gauges
   static IntGauge* CATALOG_NUM_DBS;

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/c826af68/common/thrift/metrics.json
----------------------------------------------------------------------
diff --git a/common/thrift/metrics.json b/common/thrift/metrics.json
index 49d13ae..cef9b02 100644
--- a/common/thrift/metrics.json
+++ b/common/thrift/metrics.json
@@ -550,6 +550,26 @@
     "key": "impala-server.scan-ranges.total"
   },
   {
+    "description": "The total number of hedged reads attempted over the life 
of the process",
+    "contexts": [
+      "IMPALAD"
+    ],
+    "label": "Hedged Read Operations",
+    "units": "UNIT",
+    "kind": "COUNTER",
+    "key": "impala-server.hedged-read-ops"
+  },
+  {
+    "description": "The total number of times hedged reads were faster than 
regular read operations",
+    "contexts": [
+      "IMPALAD"
+    ],
+    "label": "Hedged Read Operations Won",
+    "units": "UNIT",
+    "kind": "COUNTER",
+    "key": "impala-server.hedged-read-ops-win"
+  },
+  {
     "description": "The local start time of the Impala Server.",
     "contexts": [
       "IMPALAD"

Reply via email to