You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by to...@apache.org on 2017/02/28 21:25:52 UTC
[5/5] kudu git commit: Micro-optimizations to try to inline
DeltaKey::DecodeFrom
Micro-optimizations to try to inline DeltaKey::DecodeFrom
This is a hot function in update-heavy workloads (eg YCSB workload A).
This is an attempt to make it inlinable, by marking it "hot" and
out-of-lining the error cases into a function marked "noinline".
Change-Id: I0611a3dd1309ab815880c2d151c1270a05f8e406
Reviewed-on: http://gerrit.cloudera.org:8080/6160
Reviewed-by: David Ribeiro Alves <dr...@apache.org>
Tested-by: Todd Lipcon <to...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/368f4f73
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/368f4f73
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/368f4f73
Branch: refs/heads/master
Commit: 368f4f734e4acbab2bdb19b824e2ba26cb2cfaa6
Parents: cbb07d2
Author: Todd Lipcon <to...@apache.org>
Authored: Sun Feb 26 19:01:49 2017 -0800
Committer: Todd Lipcon <to...@apache.org>
Committed: Tue Feb 28 21:24:47 2017 +0000
----------------------------------------------------------------------
src/kudu/tablet/delta_key.cc | 5 +++++
src/kudu/tablet/delta_key.h | 16 +++++++++++-----
2 files changed, 16 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kudu/blob/368f4f73/src/kudu/tablet/delta_key.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/delta_key.cc b/src/kudu/tablet/delta_key.cc
index 2bfce8f..879e4bd 100644
--- a/src/kudu/tablet/delta_key.cc
+++ b/src/kudu/tablet/delta_key.cc
@@ -34,5 +34,10 @@ const char* DeltaType_Name(DeltaType t) {
return "UNKNOWN";
}
+Status DeltaKey::DeltaKeyError(const Slice& orig, const char* err) {
+ return Status::Corruption(strings::Substitute("Bad delta key: $0", err),
+ KUDU_REDACT(orig.ToDebugString(20)));
+}
+
} // namespace tablet
} // namespace kudu
http://git-wip-us.apache.org/repos/asf/kudu/blob/368f4f73/src/kudu/tablet/delta_key.h
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/delta_key.h b/src/kudu/tablet/delta_key.h
index 402bb74..be5e946 100644
--- a/src/kudu/tablet/delta_key.h
+++ b/src/kudu/tablet/delta_key.h
@@ -72,17 +72,20 @@ class DeltaKey {
// contain further data after that.
// The 'key' slice is mutated so that, upon return, the decoded key has been removed from
// its beginning.
- Status DecodeFrom(Slice *key) {
+ //
+ // This function is called frequently, so is marked HOT to encourage inlining.
+ Status DecodeFrom(Slice *key) ATTRIBUTE_HOT {
Slice orig(*key);
if (!PREDICT_TRUE(DecodeRowId(key, &row_idx_))) {
- return Status::Corruption("Bad delta key: bad rowid",
- KUDU_REDACT(orig.ToDebugString(20)));
+ // Out-of-line the error case to keep this function small and inlinable.
+ return DeltaKeyError(orig, "bad rowid");
}
if (!PREDICT_TRUE(timestamp_.DecodeFrom(key))) {
- return Status::Corruption("Bad delta key: bad timestamp",
- KUDU_REDACT(orig.ToDebugString(20)));
+ // Out-of-line the error case to keep this function small and inlinable.
+ return DeltaKeyError(orig, "bad timestamp");
}
+
return Status::OK();
}
@@ -102,6 +105,9 @@ class DeltaKey {
const Timestamp ×tamp() const { return timestamp_; }
private:
+ // Out-of-line error construction used by DecodeFrom.
+ static Status DeltaKeyError(const Slice& orig, const char* err);
+
// The row which has been updated.
rowid_t row_idx_;