From 7d247af500596effaa34e0fb6db101f87a629d88 Mon Sep 17 00:00:00 2001 From: mpilman Date: Wed, 31 Jul 2019 19:14:11 -0700 Subject: [PATCH] Two minor bug fixes from recent optimizations --- cmake/ConfigureCompiler.cmake | 1 + fdbclient/MasterProxyInterface.h | 5 ++-- fdbclient/StorageServerInterface.h | 7 +++-- fdbrpc/CMakeLists.txt | 1 + fdbrpc/Stats.h | 46 ++++++++++++++++++++++++++++++ fdbrpc/fdbrpc.vcxproj | 1 + flow/Stats.h | 35 ----------------------- 7 files changed, 56 insertions(+), 40 deletions(-) create mode 100644 fdbrpc/Stats.h diff --git a/cmake/ConfigureCompiler.cmake b/cmake/ConfigureCompiler.cmake index 1e326e1c94..3c6c06ea93 100644 --- a/cmake/ConfigureCompiler.cmake +++ b/cmake/ConfigureCompiler.cmake @@ -186,6 +186,7 @@ else() endif() # Check whether we can use dtrace probes + include(CheckSymbolExists) check_symbol_exists(DTRACE_PROBE sys/sdt.h SUPPORT_DTRACE) if(SUPPORT_DTRACE) add_compile_definitions(DTRACE_PROBES) diff --git a/fdbclient/MasterProxyInterface.h b/fdbclient/MasterProxyInterface.h index 7d895c3625..74f88d5c3b 100644 --- a/fdbclient/MasterProxyInterface.h +++ b/fdbclient/MasterProxyInterface.h @@ -31,6 +31,7 @@ #include "fdbclient/CommitTransaction.h" #include "flow/Stats.h" +#include "fdbrpc/Stats.h" struct MasterProxyInterface { constexpr static FileIdentifier file_identifier = 8954922; @@ -132,7 +133,7 @@ struct CommitTransactionRequest : TimedRequest { template void serialize(Ar& ar) { - serializer(ar, transaction, reply, arena, flags, debugID, static_cast(*this)); + serializer(ar, transaction, reply, arena, flags, debugID); } }; @@ -189,7 +190,7 @@ struct GetReadVersionRequest : TimedRequest { template void serialize(Ar& ar) { - serializer(ar, transactionCount, flags, debugID, reply, static_cast(*this)); + serializer(ar, transactionCount, flags, debugID, reply); } }; diff --git a/fdbclient/StorageServerInterface.h b/fdbclient/StorageServerInterface.h index 23e93b3d20..1f5a7f54e7 100644 --- a/fdbclient/StorageServerInterface.h +++ b/fdbclient/StorageServerInterface.h @@ -28,6 +28,7 @@ #include "fdbrpc/fdbrpc.h" #include "fdbrpc/LoadBalance.actor.h" #include "flow/Stats.h" +#include "fdbrpc/Stats.h" struct StorageServerInterface { constexpr static FileIdentifier file_identifier = 15302073; @@ -135,7 +136,7 @@ struct GetValueRequest : TimedRequest { template void serialize( Ar& ar ) { - serializer(ar, key, version, debugID, reply, static_cast(*this)); + serializer(ar, key, version, debugID, reply); } }; @@ -185,7 +186,7 @@ struct GetKeyValuesRequest : TimedRequest { // GetKeyValuesRequest(const KeySelectorRef& begin, const KeySelectorRef& end, Version version, int limit, int limitBytes, Optional debugID) : begin(begin), end(end), version(version), limit(limit), limitBytes(limitBytes) {} template void serialize( Ar& ar ) { - serializer(ar, begin, end, version, limit, limitBytes, isFetchKeys, debugID, reply, arena, static_cast(*this)); + serializer(ar, begin, end, version, limit, limitBytes, isFetchKeys, debugID, reply, arena); } }; @@ -214,7 +215,7 @@ struct GetKeyRequest : TimedRequest { template void serialize( Ar& ar ) { - serializer(ar, sel, version, reply, arena, static_cast(*this)); + serializer(ar, sel, version, reply, arena); } }; diff --git a/fdbrpc/CMakeLists.txt b/fdbrpc/CMakeLists.txt index 06845e8754..c2ecd3764b 100644 --- a/fdbrpc/CMakeLists.txt +++ b/fdbrpc/CMakeLists.txt @@ -26,6 +26,7 @@ set(FDBRPC_SRCS ReplicationUtils.cpp sim2.actor.cpp sim_validation.cpp + Stats.h TLSConnection.actor.cpp TraceFileIO.cpp) diff --git a/fdbrpc/Stats.h b/fdbrpc/Stats.h new file mode 100644 index 0000000000..64319b91c6 --- /dev/null +++ b/fdbrpc/Stats.h @@ -0,0 +1,46 @@ +/* + * Stats.h + * + * This source file is part of the FoundationDB open source project + * + * Copyright 2013-2019 Apple Inc. and the FoundationDB project authors + * + * 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. + */ + +#ifndef FDBRPC_STATS_H +#define FDBRPC_STATS_H +#pragma once + +#include + +class TimedRequest { + double _requestTime; + +public: + double requestTime() const { + ASSERT(_requestTime > 0.0); + return _requestTime; + } + + TimedRequest() { + if (FlowTransport::isClient()) { + _requestTime = timer(); + } else { + _requestTime = 0.0; + } + } +}; + + +#endif diff --git a/fdbrpc/fdbrpc.vcxproj b/fdbrpc/fdbrpc.vcxproj index 4276f05271..0eb323722c 100644 --- a/fdbrpc/fdbrpc.vcxproj +++ b/fdbrpc/fdbrpc.vcxproj @@ -86,6 +86,7 @@ false + diff --git a/flow/Stats.h b/flow/Stats.h index a7547dc765..3a5c4d5e40 100644 --- a/flow/Stats.h +++ b/flow/Stats.h @@ -38,41 +38,6 @@ MyCounters() : foo("foo", cc), bar("bar", cc), baz("baz", cc) {} #include "flow/flow.h" #include "flow/TDMetric.actor.h" -struct TimedRequest { - void setRequestTime(double requestTime_) { this->requestTime_ = requestTime_; } - double requestTime() const { - ASSERT(requestTime_ > 0); - return requestTime_; - } - -private: - double requestTime_ = 0.0; -}; - -template <> -struct scalar_traits : std::true_type { - constexpr static size_t size = 0; - template - static void save(uint8_t*, const TimedRequest&, Context&) { - } - - // Context is an arbitrary type that is plumbed by reference throughout the - // load call tree. - template - static void load(const uint8_t*, TimedRequest& value, Context&) { - value.setRequestTime(timer()); - } -}; - -template -inline void load(Archive& ar, TimedRequest& value) { - value.setRequestTime(timer()); -} - -template -inline void save( Archive& ar, const TimedRequest& value ) { -} - struct ICounter { // All counters have a name and value virtual std::string const& getName() const = 0;