diff --git a/bindings/c/ThreadCleanup.cpp b/bindings/c/ThreadCleanup.cpp index 20b49cf8e5..966e38b800 100644 --- a/bindings/c/ThreadCleanup.cpp +++ b/bindings/c/ThreadCleanup.cpp @@ -34,6 +34,10 @@ BOOL WINAPI DllMain( HINSTANCE dll, DWORD reason, LPVOID reserved ) { #elif defined( __unixish__ ) +#ifdef __INTEL_COMPILER +#pragma warning ( disable:2415 ) +#endif + static pthread_key_t threadDestructorKey; static void threadDestructor(void*) { @@ -57,4 +61,4 @@ static int threadDestructorKeyInit = initThreadDestructorKey(); #else #error Port me! -#endif \ No newline at end of file +#endif diff --git a/cmake/ConfigureCompiler.cmake b/cmake/ConfigureCompiler.cmake index d989283033..c276fec24a 100644 --- a/cmake/ConfigureCompiler.cmake +++ b/cmake/ConfigureCompiler.cmake @@ -75,8 +75,11 @@ if(WIN32) else() set(GCC NO) set(CLANG NO) + set(ICC NO) if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") set(CLANG YES) + elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") + set(ICC YES) else() # This is not a very good test. However, as we do not really support many architectures # this is good enough for now @@ -155,13 +158,17 @@ else() else() add_compile_options(-Werror) endif() - add_compile_options($<$:-Wno-pragmas>) + if (GCC) + add_compile_options(-Wno-pragmas -fdiagnostics-color=always) + elseif(ICC) + add_compile_options(-wd1879 -wd1011) + elseif(CLANG) + endif() add_compile_options(-Wno-error=format -Wunused-variable -Wno-deprecated -fvisibility=hidden -Wreturn-type - -fdiagnostics-color=always -fPIC) if (GPERFTOOLS_FOUND AND GCC) add_compile_options( diff --git a/fdbcli/fdbcli.actor.cpp b/fdbcli/fdbcli.actor.cpp index 00327def46..1cd7d386a5 100644 --- a/fdbcli/fdbcli.actor.cpp +++ b/fdbcli/fdbcli.actor.cpp @@ -545,7 +545,7 @@ void initHelp() { void printVersion() { printf("FoundationDB CLI " FDB_VT_PACKAGE_NAME " (v" FDB_VT_VERSION ")\n"); printf("source version %s\n", getHGVersion()); - printf("protocol %" PRIx64 "\n", currentProtocolVersion); + printf("protocol %" PRIx64 "\n", currentProtocolVersion.versionWithFlags()); } void printHelpOverview() { @@ -1329,7 +1329,7 @@ void printStatus(StatusObjectReader statusObj, StatusClient::StatusLevel level, NetworkAddress parsedAddress; try { parsedAddress = NetworkAddress::parse(address); - } catch (Error& e) { + } catch (Error&) { // Groups all invalid IP address/port pair in the end of this detail group. line = format(" %-22s (invalid IP address or port)", address.c_str()); IPAddress::IPAddressStore maxIp; @@ -1847,10 +1847,10 @@ ACTOR Future fileConfigure(Database db, std::string filePath, bool isNewDa ACTOR Future coordinators( Database db, std::vector tokens, bool isClusterTLS ) { state StringRef setName; StringRef nameTokenBegin = LiteralStringRef("description="); - for(auto t = tokens.begin()+1; t != tokens.end(); ++t) - if (t->startsWith(nameTokenBegin)) { - setName = t->substr(nameTokenBegin.size()); - std::copy( t+1, tokens.end(), t ); + for(auto tok = tokens.begin()+1; tok != tokens.end(); ++tok) + if (tok->startsWith(nameTokenBegin)) { + setName = tok->substr(nameTokenBegin.size()); + std::copy( tok+1, tokens.end(), tok ); tokens.resize( tokens.size()-1 ); break; } diff --git a/fdbclient/Atomic.h b/fdbclient/Atomic.h index d9aecbe8a3..490485064c 100644 --- a/fdbclient/Atomic.h +++ b/fdbclient/Atomic.h @@ -24,7 +24,7 @@ #include "fdbclient/CommitTransaction.h" -static ValueRef doLittleEndianAdd(const Optional& existingValueOptional, const ValueRef& otherOperand, Arena& ar) { +inline ValueRef doLittleEndianAdd(const Optional& existingValueOptional, const ValueRef& otherOperand, Arena& ar) { const ValueRef& existingValue = existingValueOptional.present() ? existingValueOptional.get() : StringRef(); if(!existingValue.size()) return otherOperand; if(!otherOperand.size()) return otherOperand; @@ -47,7 +47,7 @@ static ValueRef doLittleEndianAdd(const Optional& existingValueOptiona return StringRef(buf, i); } -static ValueRef doAnd(const Optional& existingValueOptional, const ValueRef& otherOperand, Arena& ar) { +inline ValueRef doAnd(const Optional& existingValueOptional, const ValueRef& otherOperand, Arena& ar) { const ValueRef& existingValue = existingValueOptional.present() ? existingValueOptional.get() : StringRef(); if(!otherOperand.size()) return otherOperand; @@ -62,14 +62,14 @@ static ValueRef doAnd(const Optional& existingValueOptional, const Val return StringRef(buf, i); } -static ValueRef doAndV2(const Optional& existingValueOptional, const ValueRef& otherOperand, Arena& ar) { +inline ValueRef doAndV2(const Optional& existingValueOptional, const ValueRef& otherOperand, Arena& ar) { if (!existingValueOptional.present()) return otherOperand; return doAnd(existingValueOptional, otherOperand, ar); } -static ValueRef doOr(const Optional& existingValueOptional, const ValueRef& otherOperand, Arena& ar) { +inline ValueRef doOr(const Optional& existingValueOptional, const ValueRef& otherOperand, Arena& ar) { const ValueRef& existingValue = existingValueOptional.present() ? existingValueOptional.get() : StringRef(); if(!existingValue.size()) return otherOperand; if(!otherOperand.size()) return otherOperand; @@ -85,7 +85,7 @@ static ValueRef doOr(const Optional& existingValueOptional, const Valu return StringRef(buf, i); } -static ValueRef doXor(const Optional& existingValueOptional, const ValueRef& otherOperand, Arena& ar) { +inline ValueRef doXor(const Optional& existingValueOptional, const ValueRef& otherOperand, Arena& ar) { const ValueRef& existingValue = existingValueOptional.present() ? existingValueOptional.get() : StringRef(); if(!existingValue.size()) return otherOperand; if(!otherOperand.size()) return otherOperand; @@ -102,7 +102,7 @@ static ValueRef doXor(const Optional& existingValueOptional, const Val return StringRef(buf, i); } -static ValueRef doAppendIfFits(const Optional& existingValueOptional, const ValueRef& otherOperand, Arena& ar) { +inline ValueRef doAppendIfFits(const Optional& existingValueOptional, const ValueRef& otherOperand, Arena& ar) { const ValueRef& existingValue = existingValueOptional.present() ? existingValueOptional.get() : StringRef(); if(!existingValue.size()) return otherOperand; if(!otherOperand.size()) return existingValue; @@ -123,7 +123,7 @@ static ValueRef doAppendIfFits(const Optional& existingValueOptional, return StringRef(buf, i+j); } -static ValueRef doMax(const Optional& existingValueOptional, const ValueRef& otherOperand, Arena& ar) { +inline ValueRef doMax(const Optional& existingValueOptional, const ValueRef& otherOperand, Arena& ar) { const ValueRef& existingValue = existingValueOptional.present() ? existingValueOptional.get() : StringRef(); if (!existingValue.size()) return otherOperand; if (!otherOperand.size()) return otherOperand; @@ -155,7 +155,7 @@ static ValueRef doMax(const Optional& existingValueOptional, const Val return otherOperand; } -static ValueRef doByteMax(const Optional& existingValueOptional, const ValueRef& otherOperand, Arena& ar) { +inline ValueRef doByteMax(const Optional& existingValueOptional, const ValueRef& otherOperand, Arena& ar) { if (!existingValueOptional.present()) return otherOperand; const ValueRef& existingValue = existingValueOptional.get(); @@ -165,7 +165,7 @@ static ValueRef doByteMax(const Optional& existingValueOptional, const return otherOperand; } -static ValueRef doMin(const Optional& existingValueOptional, const ValueRef& otherOperand, Arena& ar) { +inline ValueRef doMin(const Optional& existingValueOptional, const ValueRef& otherOperand, Arena& ar) { if (!otherOperand.size()) return otherOperand; const ValueRef& existingValue = existingValueOptional.present() ? existingValueOptional.get() : StringRef(); @@ -203,14 +203,14 @@ static ValueRef doMin(const Optional& existingValueOptional, const Val return otherOperand; } -static ValueRef doMinV2(const Optional& existingValueOptional, const ValueRef& otherOperand, Arena& ar) { +inline ValueRef doMinV2(const Optional& existingValueOptional, const ValueRef& otherOperand, Arena& ar) { if (!existingValueOptional.present()) return otherOperand; return doMin(existingValueOptional, otherOperand, ar); } -static ValueRef doByteMin(const Optional& existingValueOptional, const ValueRef& otherOperand, Arena& ar) { +inline ValueRef doByteMin(const Optional& existingValueOptional, const ValueRef& otherOperand, Arena& ar) { if (!existingValueOptional.present()) return otherOperand; const ValueRef& existingValue = existingValueOptional.get(); @@ -220,7 +220,7 @@ static ValueRef doByteMin(const Optional& existingValueOptional, const return otherOperand; } -static Optional doCompareAndClear(const Optional& existingValueOptional, +inline Optional doCompareAndClear(const Optional& existingValueOptional, const ValueRef& otherOperand, Arena& ar) { if (!existingValueOptional.present() || existingValueOptional.get() == otherOperand) { // Clear the value. @@ -232,7 +232,7 @@ static Optional doCompareAndClear(const Optional& existingVa /* * Returns the range corresponding to the specified versionstamp key. */ -static KeyRangeRef getVersionstampKeyRange(Arena& arena, const KeyRef &key, const KeyRef &maxKey) { +inline KeyRangeRef getVersionstampKeyRange(Arena& arena, const KeyRef &key, const KeyRef &maxKey) { KeyRef begin(arena, key); KeyRef end(arena, key); @@ -255,7 +255,7 @@ static KeyRangeRef getVersionstampKeyRange(Arena& arena, const KeyRef &key, cons return KeyRangeRef(begin, std::min(end, maxKey)); } -static void placeVersionstamp( uint8_t* destination, Version version, uint16_t transactionNumber ) { +inline void placeVersionstamp( uint8_t* destination, Version version, uint16_t transactionNumber ) { version = bigEndian64(version); transactionNumber = bigEndian16(transactionNumber); static_assert( sizeof(version) == 8, "version size mismatch" ); @@ -264,7 +264,7 @@ static void placeVersionstamp( uint8_t* destination, Version version, uint16_t t memcpy( destination + sizeof(version), &transactionNumber, sizeof(transactionNumber) ); } -static void transformVersionstampMutation( MutationRef& mutation, StringRef MutationRef::* param, Version version, uint16_t transactionNumber ) { +inline void transformVersionstampMutation( MutationRef& mutation, StringRef MutationRef::* param, Version version, uint16_t transactionNumber ) { if ((mutation.*param).size() >= 4) { int32_t pos; memcpy(&pos, (mutation.*param).end() - sizeof(int32_t), sizeof(int32_t)); diff --git a/fdbclient/FDBTypes.h b/fdbclient/FDBTypes.h index edb83f5f92..b1143ba505 100644 --- a/fdbclient/FDBTypes.h +++ b/fdbclient/FDBTypes.h @@ -92,7 +92,7 @@ struct struct_like_traits : std::true_type { } template - static const void assign(Member& m, const Type& t) { + static void assign(Member& m, const Type& t) { if constexpr (i == 0) { m.id = t; } else { @@ -124,26 +124,26 @@ void uniquify( Collection& c ) { c.resize( std::unique(c.begin(), c.end()) - c.begin() ); } -static std::string describe( const Tag item ) { +inline std::string describe( const Tag item ) { return format("%d:%d", item.locality, item.id); } -static std::string describe( const int item ) { +inline std::string describe( const int item ) { return format("%d", item); } template -static std::string describe( Reference const& item ) { +std::string describe( Reference const& item ) { return item->toString(); } template -static std::string describe( T const& item ) { +std::string describe( T const& item ) { return item.toString(); } template -static std::string describe( std::map const& items, int max_items = -1 ) { +std::string describe( std::map const& items, int max_items = -1 ) { if(!items.size()) return "[no items]"; @@ -159,7 +159,7 @@ static std::string describe( std::map const& items, int max_items = -1 ) { } template -static std::string describeList( T const& items, int max_items ) { +std::string describeList( T const& items, int max_items ) { if(!items.size()) return "[no items]"; @@ -175,12 +175,12 @@ static std::string describeList( T const& items, int max_items ) { } template -static std::string describe( std::vector const& items, int max_items = -1 ) { +std::string describe( std::vector const& items, int max_items = -1 ) { return describeList(items, max_items); } template -static std::string describe( std::set const& items, int max_items = -1 ) { +std::string describe( std::set const& items, int max_items = -1 ) { return describeList(items, max_items); } @@ -492,7 +492,7 @@ struct KeyRangeWith : KeyRange { } }; template -static inline KeyRangeWith keyRangeWith( const KeyRangeRef& range, const Val& value ) { +KeyRangeWith keyRangeWith( const KeyRangeRef& range, const Val& value ) { return KeyRangeWith(range, value); } @@ -757,7 +757,7 @@ struct AddressExclusion { } }; -static bool addressExcluded( std::set const& exclusions, NetworkAddress const& addr ) { +inline bool addressExcluded( std::set const& exclusions, NetworkAddress const& addr ) { return exclusions.count( AddressExclusion(addr.ip, addr.port) ) || exclusions.count( AddressExclusion(addr.ip) ); } diff --git a/fdbclient/FileBackupAgent.actor.cpp b/fdbclient/FileBackupAgent.actor.cpp index efa53801c7..736fad10b0 100644 --- a/fdbclient/FileBackupAgent.actor.cpp +++ b/fdbclient/FileBackupAgent.actor.cpp @@ -572,8 +572,8 @@ namespace fileBackup { // Functions for consuming big endian (network byte order) integers. // Consumes a big endian number, swaps it to little endian, and returns it. - const int32_t consumeNetworkInt32() { return (int32_t)bigEndian32((uint32_t)consume< int32_t>());} - const uint32_t consumeNetworkUInt32() { return bigEndian32( consume());} + int32_t consumeNetworkInt32() { return (int32_t)bigEndian32((uint32_t)consume< int32_t>());} + uint32_t consumeNetworkUInt32() { return bigEndian32( consume());} bool eof() { return rptr == end; } diff --git a/fdbclient/ManagementAPI.actor.cpp b/fdbclient/ManagementAPI.actor.cpp index a371ac2624..f9680f25a8 100644 --- a/fdbclient/ManagementAPI.actor.cpp +++ b/fdbclient/ManagementAPI.actor.cpp @@ -104,8 +104,8 @@ std::map configForToken( std::string const& mode ) { // Add any new store types to fdbserver/workloads/ConfigureDatabase, too if (storeType.present()) { - out[p+"log_engine"] = format("%d", logType.get()); - out[p+"storage_engine"] = format("%d", storeType.get()); + out[p+"log_engine"] = format("%d", logType.get().operator KeyValueStoreType::StoreType()); + out[p+"storage_engine"] = format("%d", storeType.get().operator KeyValueStoreType::StoreType()); return out; } diff --git a/fdbclient/MonitorLeader.h b/fdbclient/MonitorLeader.h index 62fcd61427..6ec86570df 100644 --- a/fdbclient/MonitorLeader.h +++ b/fdbclient/MonitorLeader.h @@ -36,7 +36,9 @@ Future monitorLeader( Reference const& connFile, Re // of the current leader. If a leader is elected for long enough and communication with a quorum of // coordinators is possible, eventually outKnownLeader will be that leader's interface. +#ifndef __INTEL_COMPILER #pragma region Implementation +#endif Future monitorLeaderInternal( Reference const& connFile, Reference> const& outSerializedLeaderInfo, Reference> const& connectedCoordinatorsNum ); @@ -69,6 +71,8 @@ Future monitorLeader(Reference const& connFile, return m || deserializer( serializedInfo, outKnownLeader ); } +#ifndef __INTEL_COMPILER #pragma endregion +#endif #endif diff --git a/fdbclient/NativeAPI.actor.cpp b/fdbclient/NativeAPI.actor.cpp index 6fbf778997..76f051197e 100644 --- a/fdbclient/NativeAPI.actor.cpp +++ b/fdbclient/NativeAPI.actor.cpp @@ -252,24 +252,6 @@ ACTOR Future databaseLogger( DatabaseContext *cx ) { } } -ACTOR static Future > getSampleVersionStamp(Transaction *tr) { - loop{ - try { - tr->reset(); - tr->setOption(FDBTransactionOptions::PRIORITY_SYSTEM_IMMEDIATE); - wait(success(tr->get(LiteralStringRef("\xff/StatusJsonTestKey62793")))); - state Future > vstamp = tr->getVersionstamp(); - tr->makeSelfConflicting(); - wait(tr->commit()); - Standalone val = wait(vstamp); - return val; - } - catch (Error& e) { - wait(tr->onError(e)); - } - } -} - struct TrInfoChunk { ValueRef value; Key key; diff --git a/fdbclient/RYWIterator.cpp b/fdbclient/RYWIterator.cpp index 3f8decfaab..7e9960b40f 100644 --- a/fdbclient/RYWIterator.cpp +++ b/fdbclient/RYWIterator.cpp @@ -334,31 +334,31 @@ ACTOR Standalone getRange( Transaction* tr, KeySelector begin, K -static void printWriteMap(WriteMap *p) { - WriteMap::iterator it(p); - for (it.skip(allKeys.begin); it.beginKey() < allKeys.end; ++it) { - if (it.is_cleared_range()) { - printf("CLEARED "); - } - if (it.is_conflict_range()) { - printf("CONFLICT "); - } - if (it.is_operation()) { - printf("OPERATION "); - printf(it.is_independent() ? "INDEPENDENT " : "DEPENDENT "); - } - if (it.is_unmodified_range()) { - printf("UNMODIFIED "); - } - if (it.is_unreadable()) { - printf("UNREADABLE "); - } - printf(": \"%s\" -> \"%s\"\n", - printable(it.beginKey().toStandaloneStringRef()).c_str(), - printable(it.endKey().toStandaloneStringRef()).c_str()); - } - printf("\n"); -} +//static void printWriteMap(WriteMap *p) { +// WriteMap::iterator it(p); +// for (it.skip(allKeys.begin); it.beginKey() < allKeys.end; ++it) { +// if (it.is_cleared_range()) { +// printf("CLEARED "); +// } +// if (it.is_conflict_range()) { +// printf("CONFLICT "); +// } +// if (it.is_operation()) { +// printf("OPERATION "); +// printf(it.is_independent() ? "INDEPENDENT " : "DEPENDENT "); +// } +// if (it.is_unmodified_range()) { +// printf("UNMODIFIED "); +// } +// if (it.is_unreadable()) { +// printf("UNREADABLE "); +// } +// printf(": \"%s\" -> \"%s\"\n", +// printable(it.beginKey().toStandaloneStringRef()).c_str(), +// printable(it.endKey().toStandaloneStringRef()).c_str()); +// } +// printf("\n"); +//} static int getWriteMapCount(WriteMap *p) { // printWriteMap(p); diff --git a/fdbclient/Status.h b/fdbclient/Status.h index 6d7384abfb..8a6e49ff25 100644 --- a/fdbclient/Status.h +++ b/fdbclient/Status.h @@ -68,7 +68,7 @@ struct StatusValue : json_spirit::mValue { StatusValue(json_spirit::mValue const& o) : json_spirit::mValue(o) {} }; -static StatusObject makeMessage(const char *name, const char *description) { +inline StatusObject makeMessage(const char *name, const char *description) { StatusObject out; out["name"] = name; out["description"] = description; @@ -88,7 +88,7 @@ template <> inline bool JSONDoc::get(const std::string path, StatusObje } // Takes an object by reference so make usage look clean and avoid the client doing object["messages"] which will create the key. -static bool findMessagesByName(StatusObjectReader object, std::set to_find) { +inline bool findMessagesByName(StatusObjectReader object, std::set to_find) { if (!object.has("messages") || object.last().type() != json_spirit::array_type) return false; diff --git a/fdbclient/ThreadSafeTransaction.actor.cpp b/fdbclient/ThreadSafeTransaction.actor.cpp index 130b1652ce..134e07fda2 100644 --- a/fdbclient/ThreadSafeTransaction.actor.cpp +++ b/fdbclient/ThreadSafeTransaction.actor.cpp @@ -53,9 +53,9 @@ Reference ThreadSafeDatabase::createTransaction() { void ThreadSafeDatabase::setOption( FDBDatabaseOptions::Option option, Optional value) { DatabaseContext *db = this->db; Standalone> passValue = value; - onMainThreadVoid( [db, option, passValue](){ + onMainThreadVoid( [db, option, passValue](){ db->checkDeferredError(); - db->setOption(option, passValue.contents()); + db->setOption(option, passValue.contents()); }, &db->deferredError ); } @@ -66,7 +66,7 @@ ThreadSafeDatabase::ThreadSafeDatabase(std::string connFilename, int apiVersion) // but run its constructor on the main thread DatabaseContext *db = this->db = DatabaseContext::allocateOnForeignThread(); - onMainThreadVoid([db, connFile, apiVersion](){ + onMainThreadVoid([db, connFile, apiVersion](){ try { Database::createDatabase(connFile, apiVersion, LocalityData(), db).extractPtr(); } @@ -312,7 +312,10 @@ void ThreadSafeTransaction::reset() { extern const char* getHGVersion(); -ThreadSafeApi::ThreadSafeApi() : apiVersion(-1), clientVersion(format("%s,%s,%llx", FDB_VT_VERSION, getHGVersion(), currentProtocolVersion)), transportId(0) {} +ThreadSafeApi::ThreadSafeApi() + : apiVersion(-1), + clientVersion(format("%s,%s,%llx", FDB_VT_VERSION, getHGVersion(), currentProtocolVersion.versionWithFlags())), + transportId(0) {} void ThreadSafeApi::selectApiVersion(int apiVersion) { this->apiVersion = apiVersion; diff --git a/fdbrpc/Locality.h b/fdbrpc/Locality.h index 759e59948c..ea6f4544a4 100644 --- a/fdbrpc/Locality.h +++ b/fdbrpc/Locality.h @@ -252,10 +252,10 @@ static std::string describe( } return s; } -static std::string describeZones( std::vector const& items, int max_items = -1 ) { +inline std::string describeZones( std::vector const& items, int max_items = -1 ) { return describe(items, LocalityData::keyZoneId, max_items); } -static std::string describeDataHalls( std::vector const& items, int max_items = -1 ) { +inline std::string describeDataHalls( std::vector const& items, int max_items = -1 ) { return describe(items, LocalityData::keyDataHallId, max_items); } diff --git a/fdbrpc/Net2FileSystem.cpp b/fdbrpc/Net2FileSystem.cpp index 31ce9f6095..cb33c1c84b 100644 --- a/fdbrpc/Net2FileSystem.cpp +++ b/fdbrpc/Net2FileSystem.cpp @@ -107,7 +107,7 @@ Net2FileSystem::Net2FileSystem(double ioTimeout, std::string fileSystemPath) criticalError(FDB_EXIT_ERROR, "FileSystemError", format("`%s' is not a mount point", fileSystemPath.c_str()).c_str()); } } - } catch (Error& e) { + } catch (Error&) { criticalError(FDB_EXIT_ERROR, "FileSystemError", format("Could not get device id from `%s'", fileSystemPath.c_str()).c_str()); } } diff --git a/fdbrpc/crc32c.cpp b/fdbrpc/crc32c.cpp index 899a0b88e4..9c0eb397b4 100644 --- a/fdbrpc/crc32c.cpp +++ b/fdbrpc/crc32c.cpp @@ -38,53 +38,6 @@ #include "generated-constants.cpp" #pragma GCC target("sse4.2") -static uint32_t append_trivial(uint32_t crc, const uint8_t * input, size_t length) -{ - for (size_t i = 0; i < length; ++i) - { - crc = crc ^ input[i]; - for (int j = 0; j < 8; j++) - crc = (crc >> 1) ^ 0x80000000 ^ ((~crc & 1) * POLY); - } - return crc; -} - -/* Table-driven software version as a fall-back. This is about 15 times slower - than using the hardware instructions. This assumes little-endian integers, - as is the case on Intel processors that the assembler code here is for. */ -static uint32_t append_adler_table(uint32_t crci, const uint8_t * input, size_t length) -{ - const uint8_t * next = input; - uint64_t crc; - - crc = crci ^ 0xffffffff; - while (length && ((uintptr_t)next & 7) != 0) - { - crc = table[0][(crc ^ *next++) & 0xff] ^ (crc >> 8); - --length; - } - while (length >= 8) - { - crc ^= *(uint64_t *)next; - crc = table[7][crc & 0xff] - ^ table[6][(crc >> 8) & 0xff] - ^ table[5][(crc >> 16) & 0xff] - ^ table[4][(crc >> 24) & 0xff] - ^ table[3][(crc >> 32) & 0xff] - ^ table[2][(crc >> 40) & 0xff] - ^ table[1][(crc >> 48) & 0xff] - ^ table[0][crc >> 56]; - next += 8; - length -= 8; - } - while (length) - { - crc = table[0][(crc ^ *next++) & 0xff] ^ (crc >> 8); - --length; - } - return (uint32_t)crc ^ 0xffffffff; -} - /* Table-driven software version as a fall-back. This is about 15 times slower than using the hardware instructions. This assumes little-endian integers, as is the case on Intel processors that the assembler code here is for. */ diff --git a/fdbrpc/dsltest.actor.cpp b/fdbrpc/dsltest.actor.cpp index fce4617fa8..eaaac40907 100644 --- a/fdbrpc/dsltest.actor.cpp +++ b/fdbrpc/dsltest.actor.cpp @@ -262,14 +262,20 @@ Future switchTest( FutureStream as, Future oneb ) { class TestBuffer : public ReferenceCounted { public: static TestBuffer* create( int length ) { +#if defined(__INTEL_COMPILER) + return new TestBuffer(length); +#else auto b = (TestBuffer*)new int[ (length+7)/4 ]; new (b) TestBuffer(length); return b; +#endif } +#if !defined(__INTEL_COMPILER) void operator delete( void* buf ) { cout << "Freeing buffer" << endl; delete[] (int*)buf; } +#endif int size() const { return length; } uint8_t* begin() { return data; } @@ -278,7 +284,7 @@ public: const uint8_t* end() const { return data+length; } private: - TestBuffer(int length) throw () : length(length) {} + TestBuffer(int length) noexcept : length(length) {} int length; uint8_t data[1]; }; diff --git a/fdbrpc/libcoroutine/Coro.c b/fdbrpc/libcoroutine/Coro.c index e72990f4d9..67330972e1 100644 --- a/fdbrpc/libcoroutine/Coro.c +++ b/fdbrpc/libcoroutine/Coro.c @@ -75,8 +75,6 @@ typedef struct CallbackBlock CoroStartCallback *func; } CallbackBlock; -static CallbackBlock globalCallbackBlock; - Coro *Coro_new(void) { Coro *self = (Coro *)io_calloc(1, sizeof(Coro)); @@ -286,6 +284,9 @@ void Coro_Start(void) } */ #else + +static CallbackBlock globalCallbackBlock; + void Coro_StartWithArg(CallbackBlock *block) { setProfilingEnabled(1); @@ -421,6 +422,8 @@ void Coro_setup(Coro *self, void *arg) #define buf (self->env) +static CallbackBlock globalCallbackBlock; + void Coro_setup(Coro *self, void *arg) { setjmp(buf); @@ -456,6 +459,8 @@ void Coro_setup(Coro *self, void *arg) #define setjmp _setjmp #define longjmp _longjmp +static CallbackBlock globalCallbackBlock; + void Coro_setup(Coro *self, void *arg) { size_t *sp = (size_t *)(((intptr_t)Coro_stack(self) diff --git a/fdbserver/ApplyMetadataMutation.h b/fdbserver/ApplyMetadataMutation.h index 6756f15a3e..a01ea7467b 100644 --- a/fdbserver/ApplyMetadataMutation.h +++ b/fdbserver/ApplyMetadataMutation.h @@ -30,7 +30,7 @@ #include "fdbserver/LogSystem.h" #include "fdbserver/LogProtocolMessage.h" -static bool isMetadataMutation(MutationRef const& m) { +inline bool isMetadataMutation(MutationRef const& m) { // FIXME: This is conservative - not everything in system keyspace is necessarily processed by applyMetadataMutations return (m.type == MutationRef::SetValue && m.param1.size() && m.param1[0] == systemKeys.begin[0] && !m.param1.startsWith(nonMetadataSystemKeys.begin)) || (m.type == MutationRef::ClearRange && m.param2.size() && m.param2[0] == systemKeys.begin[0] && !nonMetadataSystemKeys.contains(KeyRangeRef(m.param1, m.param2)) ); @@ -42,7 +42,7 @@ struct applyMutationsData { Reference> keyVersion; }; -static Reference getStorageInfo(UID id, std::map>* storageCache, IKeyValueStore* txnStateStore) { +inline Reference getStorageInfo(UID id, std::map>* storageCache, IKeyValueStore* txnStateStore) { Reference storageInfo; auto cacheItr = storageCache->find(id); if(cacheItr == storageCache->end()) { @@ -59,7 +59,7 @@ static Reference getStorageInfo(UID id, std::map const& mutations, IKeyValueStore* txnStateStore, LogPushData* toCommit, bool *confChange, Reference logSystem = Reference(), Version popVersion = 0, +inline void applyMetadataMutations(UID const& dbgid, Arena &arena, VectorRef const& mutations, IKeyValueStore* txnStateStore, LogPushData* toCommit, bool *confChange, Reference logSystem = Reference(), Version popVersion = 0, KeyRangeMap >* vecBackupKeys = NULL, KeyRangeMap* keyInfo = NULL, std::map* uid_applyMutationsData = NULL, RequestStream commit = RequestStream(), Database cx = Database(), NotifiedVersion* commitVersion = NULL, std::map>* storageCache = NULL, std::map* tag_popped = NULL, bool initialCommit = false ) { for (auto const& m : mutations) { diff --git a/fdbserver/KeyValueStoreSQLite.actor.cpp b/fdbserver/KeyValueStoreSQLite.actor.cpp index e53fa5a29a..3e831d85a8 100644 --- a/fdbserver/KeyValueStoreSQLite.actor.cpp +++ b/fdbserver/KeyValueStoreSQLite.actor.cpp @@ -1426,7 +1426,7 @@ struct ThreadSafeCounter { ThreadSafeCounter() : counter(0) {} void operator ++() { interlockedIncrement64(&counter); } void operator --() { interlockedDecrement64(&counter); } - operator const int64_t() const { return counter; } + operator int64_t() const { return counter; } }; class KeyValueStoreSQLite : public IKeyValueStore { diff --git a/fdbserver/LeaderElection.h b/fdbserver/LeaderElection.h index 8e90c53034..3140466a58 100644 --- a/fdbserver/LeaderElection.h +++ b/fdbserver/LeaderElection.h @@ -47,7 +47,9 @@ Future tryBecomeLeader( ServerCoordinators const& coordinators, Future changeLeaderCoordinators( ServerCoordinators const& coordinators, Value const& forwardingInfo ); // Inform all the coordinators that they have been replaced with a new connection string +#ifndef __INTEL_COMPILER #pragma region Implementation +#endif // __INTEL_COMPILER Future tryBecomeLeaderInternal( ServerCoordinators const& coordinators, Value const& proposedSerializedInterface, Reference> const& outSerializedLeader, bool const& hasConnected, Reference> const& asyncPriorityInfo ); @@ -66,6 +68,8 @@ Future tryBecomeLeader( ServerCoordinators const& coordinators, return m || asyncDeserialize(serializedInfo, outKnownLeader, g_network->useObjectSerializer()); } +#ifndef __INTEL_COMPILER #pragma endregion +#endif // __INTEL_COMPILER #endif diff --git a/fdbserver/SkipList.cpp b/fdbserver/SkipList.cpp index 62f22a66b9..e570db08e7 100644 --- a/fdbserver/SkipList.cpp +++ b/fdbserver/SkipList.cpp @@ -88,7 +88,7 @@ void SlowConflictSet::add( const VectorRef& clearRanges, const Vect } -PerfDoubleCounter +PerfDoubleCounter g_buildTest("Build", skc), g_add("Add", skc), g_add_sort("A.Sort", skc), @@ -163,7 +163,7 @@ force_inline bool getCharacter(const KeyInfo& ki, int character, int &outputChar // termination if (character == ki.key.size()){ outputCharacter = 0; - return false; + return false; } if (character == ki.key.size()+1) { @@ -313,8 +313,8 @@ private: uint8_t* value() { return end() + nPointers*(sizeof(Node*)+sizeof(Version)); } int length() { return valueLength; } Node* getNext(int i) { return *((Node**)end() + i); } - void setNext(int i, Node* n) { - *((Node**)end() + i) = n; + void setNext(int i, Node* n) { + *((Node**)end() + i) = n; #if defined(_DEBUG) || 1 /*if (n && n->level() < i) *(volatile int*)0 = 0;*/ @@ -438,7 +438,7 @@ public: // Returns true if we have advanced to the next level force_inline bool advance() { Node* next = x->getNext(level-1); - + if (next == alreadyChecked || !less(next->value(), next->length(), value.begin(), value.size())) { alreadyChecked = next; level--; @@ -464,7 +464,7 @@ public: Node *n = finger[0]->getNext(0); // or alreadyChecked, but that is more easily invalidated if (n && n->length() == value.size() && !memcmp(n->value(), value.begin(), value.size())) return n; - else + else return NULL; } @@ -477,9 +477,9 @@ public: int count() { int count = 0; Node* x = header->getNext(0); - while (x) { - x = x->getNext(0); - count++; + while (x) { + x = x->getNext(0); + count++; } return count; } @@ -561,7 +561,7 @@ public: void partition( StringRef* begin, int splitCount, SkipList* output ) { for(int i=splitCount-1; i>=0; i--) { Finger f( header, begin[i] ); - while (!f.finished()) + while (!f.finished()) f.nextLevel(); split(f, output[i+1]); } @@ -585,7 +585,7 @@ public: } void find( const StringRef* values, Finger* results, int* temp, int count ) { - // Relying on the ordering of values, descend until the values aren't all in the + // Relying on the ordering of values, descend until the values aren't all in the // same part of the tree // vtune: 11 parts @@ -674,7 +674,7 @@ public: while (nodeCount--) { Node* x = f.finger[0]->getNext(0); if (!x) break; - + // double prefetch gives +25% speed (single threaded) Node* next = x->getNext(0); _mm_prefetch( (const char*)next, _MM_HINT_T0 ); @@ -703,7 +703,7 @@ public: private: void remove( const Finger& start, const Finger& end ) { - if (start.finger[0] == end.finger[0]) + if (start.finger[0] == end.finger[0]) return; Node *x = start.finger[0]->getNext(0); @@ -792,17 +792,17 @@ private: return conflict(); } state = 1; - case 1: + case 1: { // check the end side of the pyramid Node *e = end.finger[end.level]; while (e->getMaxVersion(end.level) > version) { - if (end.finished()) + if (end.finished()) return conflict(); end.nextLevel(); Node *f = end.finger[end.level]; while (e != f){ - if (e->getMaxVersion(end.level) > version) + if (e->getMaxVersion(end.level) > version) return conflict(); e = e->getNext(end.level); } @@ -814,11 +814,11 @@ private: Node *nextS = start.finger[start.level]->getNext(start.level); Node *p = nextS; while (p != s){ - if (p->getMaxVersion(start.level) > version) + if (p->getMaxVersion(start.level) > version) return conflict(); p = p->getNext(start.level); } - if (start.finger[start.level]->getMaxVersion(start.level) <= version) + if (start.finger[start.level]->getMaxVersion(start.level) <= version) return noConflict(); s = nextS; if (start.finished()) { @@ -854,7 +854,7 @@ private: Node* node = header; for(int l=MaxLevels-1; l>=0; l--) { Node* next; - while ( (next=node->getNext(l)) != NULL ) + while ( (next=node->getNext(l)) != NULL ) node = next; end.finger[l] = node; } @@ -866,7 +866,7 @@ private: } }; -struct Action { +struct Action { virtual void operator()() = 0; // self-destructs }; typedef Action* PAction; @@ -1184,7 +1184,7 @@ void ConflictBatch::detectConflicts(Version now, Version newOldestVersion, std:: t = timer(); mergeWriteConflictRanges(now); g_merge += timer()-t; - + for (int i = 0; i < transactionCount; i++) { if (!transactionConflictStatus[i]) @@ -1198,7 +1198,7 @@ void ConflictBatch::detectConflicts(Version now, Version newOldestVersion, std:: t = timer(); if (newOldestVersion > cs->oldestVersion) { cs->oldestVersion = newOldestVersion; - SkipList::Finger finger; + SkipList::Finger finger; int temp; cs->versionHistory.find( &cs->removalKey, &finger, &temp, 1 ); cs->versionHistory.removeBefore( cs->oldestVersion, finger, combinedWriteConflictRanges.size()*3 + 10 ); @@ -1208,28 +1208,29 @@ void ConflictBatch::detectConflicts(Version now, Version newOldestVersion, std:: } void ConflictBatch::checkReadConflictRanges() { - if (!combinedReadConflictRanges.size()) + if (!combinedReadConflictRanges.size()) return; - if (PARALLEL_THREAD_COUNT) { - Event done[PARALLEL_THREAD_COUNT?PARALLEL_THREAD_COUNT:1]; - for(int t=0; tworker_nextAction[t] = action( [&,t] { +#if PARALLEL_THREAD_COUNT + Event done[PARALLEL_THREAD_COUNT ? PARALLEL_THREAD_COUNT : 1]; + for (int t = 0; t < PARALLEL_THREAD_COUNT; t++) { + cs->worker_nextAction[t] = action([&, t] { #pragma GCC diagnostic push -DISABLE_ZERO_DIVISION_FLAG - auto begin = &combinedReadConflictRanges[0] + t*combinedReadConflictRanges.size()/PARALLEL_THREAD_COUNT; - auto end = &combinedReadConflictRanges[0] + (t+1)*combinedReadConflictRanges.size()/PARALLEL_THREAD_COUNT; + DISABLE_ZERO_DIVISION_FLAG + auto begin = &combinedReadConflictRanges[0] + t * combinedReadConflictRanges.size() / PARALLEL_THREAD_COUNT; + auto end = + &combinedReadConflictRanges[0] + (t + 1) * combinedReadConflictRanges.size() / PARALLEL_THREAD_COUNT; #pragma GCC diagnostic pop - cs->versionHistory.detectConflicts( begin, end-begin, transactionConflictStatus ); - done[t].set(); - }); - cs->worker_ready[t]->set(); - } - for(int i=0; iversionHistory.detectConflicts( &combinedReadConflictRanges[0], combinedReadConflictRanges.size(), transactionConflictStatus ); + cs->versionHistory.detectConflicts(begin, end - begin, transactionConflictStatus); + done[t].set(); + }); + cs->worker_ready[t]->set(); } + for (int i = 0; i < PARALLEL_THREAD_COUNT; i++) done[i].block(); +#else + cs->versionHistory.detectConflicts(&combinedReadConflictRanges[0], combinedReadConflictRanges.size(), + transactionConflictStatus); +#endif } void ConflictBatch::addConflictRanges(Version now, std::vector< std::pair >::iterator begin, std::vector< std::pair >::iterator end,SkipList* part) { @@ -1258,7 +1259,7 @@ void ConflictBatch::addConflictRanges(Version now, std::vector< std::pair clusterGetStatus( state JsonBuilderObject qos; state JsonBuilderObject data_overlay; - statusObj["protocol_version"] = format("%llx", currentProtocolVersion); + statusObj["protocol_version"] = format("%llx", currentProtocolVersion.versionWithFlags()); statusObj["connection_string"] = coordinators.ccf->getConnectionString().toString(); state Optional configuration; diff --git a/fdbserver/TLogServer.actor.cpp b/fdbserver/TLogServer.actor.cpp index 52d0079ab7..4e38bdb685 100644 --- a/fdbserver/TLogServer.actor.cpp +++ b/fdbserver/TLogServer.actor.cpp @@ -254,10 +254,6 @@ static StringRef stripTagMessagesKey( StringRef key ) { return key.substr( sizeof(UID) + sizeof(Tag) + persistTagMessagesKeys.begin.size() ); } -static StringRef stripTagMessageRefsKey( StringRef key ) { - return key.substr( sizeof(UID) + sizeof(Tag) + persistTagMessageRefsKeys.begin.size() ); -} - static Version decodeTagMessagesKey( StringRef key ) { return bigEndian64( BinaryReader::fromStringRef( stripTagMessagesKey(key), Unversioned() ) ); } diff --git a/fdbserver/fdbserver.actor.cpp b/fdbserver/fdbserver.actor.cpp index 4d7f58796e..a3c5f927a1 100644 --- a/fdbserver/fdbserver.actor.cpp +++ b/fdbserver/fdbserver.actor.cpp @@ -521,7 +521,7 @@ void* parentWatcher(void *arg) { static void printVersion() { printf("FoundationDB " FDB_VT_PACKAGE_NAME " (v" FDB_VT_VERSION ")\n"); printf("source version %s\n", getHGVersion()); - printf("protocol %" PRIx64 "\n", currentProtocolVersion); + printf("protocol %" PRIx64 "\n", currentProtocolVersion.versionWithFlags()); } static void printHelpTeaser( const char *name ) { diff --git a/fdbserver/sqlite/btree.c b/fdbserver/sqlite/btree.c index 28390d6163..c2e21ea5dc 100644 --- a/fdbserver/sqlite/btree.c +++ b/fdbserver/sqlite/btree.c @@ -2561,7 +2561,9 @@ static int newDatabase(BtShared *pBt){ ** proceed. */ SQLITE_PRIVATE int sqlite3BtreeBeginTrans(Btree *p, int wrflag){ +#ifndef SQLITE_OMIT_SHARED_CACHE sqlite3 *pBlock = 0; +#endif BtShared *pBt = p->pBt; int rc = SQLITE_OK; @@ -4644,10 +4646,10 @@ SQLITE_PRIVATE int sqlite3BtreeMovetoUnpacked( goto moveto_finish; } - int partial_c = c; c = sqlite3VdbeRecordCompare(nCell, pCellKey, pIdxKey, (SQLITE3_BTREE_FORCE_FULL_COMPARISONS ? 0 : nextStartField), NULL); #if SQLITE3_BTREE_FORCE_FULL_COMPARISONS + int partial_c = c; /* If more data was NOT required but the partial comparison produced a different result than full * then something is wrong, log stuff and abort */ if(!moreDataRequired && partial_c != c) { diff --git a/fdbserver/storageserver.actor.cpp b/fdbserver/storageserver.actor.cpp index 28d47fa9cb..58ec60a84c 100644 --- a/fdbserver/storageserver.actor.cpp +++ b/fdbserver/storageserver.actor.cpp @@ -57,7 +57,9 @@ using std::pair; using std::make_pair; +#ifndef __INTEL_COMPILER #pragma region Data Structures +#endif #define SHORT_CIRCUT_ACTUAL_STORAGE 0 @@ -668,10 +670,14 @@ void StorageServer::byteSampleApplyMutation( MutationRef const& m, Version ver ) ASSERT(false); // Mutation of unknown type modfying byte sample } +#ifndef __INTEL_COMPILER #pragma endregion +#endif /////////////////////////////////// Validation /////////////////////////////////////// +#ifndef __INTEL_COMPILER #pragma region Validation +#endif bool validateRange( StorageServer::VersionedData::ViewAtVersion const& view, KeyRangeRef range, Version version, UID id, Version minInsertVersion ) { // * Nonoverlapping: No clear overlaps a set or another clear, or adjoins another clear. // * Old mutations are erased: All items in versionedData.atLatest() have insertVersion() > durableVersion() @@ -742,7 +748,9 @@ void validate(StorageServer* data, bool force = false) { throw; } } +#ifndef __INTEL_COMPILER #pragma endregion +#endif void updateProcessStats(StorageServer* self) @@ -763,7 +771,9 @@ updateProcessStats(StorageServer* self) } ///////////////////////////////////// Queries ///////////////////////////////// +#ifndef __INTEL_COMPILER #pragma region Queries +#endif ACTOR Future waitForVersion( StorageServer* data, Version version ) { // This could become an Actor transparently, but for now it just does the lookup if (version == latestVersion) @@ -1521,10 +1531,14 @@ void getQueuingMetrics( StorageServer* self, StorageQueuingMetricsRequest const& req.reply.send( reply ); } +#ifndef __INTEL_COMPILER #pragma endregion +#endif /////////////////////////// Updates //////////////////////////////// +#ifndef __INTEL_COMPILER #pragma region Updates +#endif ACTOR Future doEagerReads( StorageServer* data, UpdateEagerReadInfo* eager ) { eager->finishKeyBegin(); @@ -2940,10 +2954,14 @@ ACTOR Future updateStorage(StorageServer* data) { } } +#ifndef __INTEL_COMPILER #pragma endregion +#endif ////////////////////////////////// StorageServerDisk /////////////////////////////////////// +#ifndef __INTEL_COMPILER #pragma region StorageServerDisk +#endif void StorageServerDisk::makeNewStorageServerDurable() { storage->set( persistFormat ); @@ -3409,10 +3427,14 @@ Future StorageServerMetrics::waitMetrics(WaitMetricsRequest req, Future metricsCore( StorageServer* self, StorageServerInterface ssi ) { state Future doPollMetrics = Void(); @@ -3778,7 +3800,9 @@ ACTOR Future storageServer( IKeyValueStore* persistentData, StorageServerI } } +#ifndef __INTEL_COMPILER #pragma endregion +#endif /* 4 Reference count diff --git a/fdbserver/workloads/BulkSetup.actor.h b/fdbserver/workloads/BulkSetup.actor.h index 327d6b13fa..e4a248eec9 100644 --- a/fdbserver/workloads/BulkSetup.actor.h +++ b/fdbserver/workloads/BulkSetup.actor.h @@ -155,51 +155,7 @@ Future setupRangeWorker( Database cx, T* workload, std::vector > > trackInsertionCount(Database cx, std::vector countsOfInterest, double checkInterval) -{ - state KeyRange keyPrefix = KeyRangeRef(std::string("keycount"), std::string("keycount") + char(255)); - state KeyRange bytesPrefix = KeyRangeRef(std::string("bytesstored"), std::string("bytesstored") + char(255)); - state Transaction tr(cx); - state uint64_t lastInsertionCount = 0; - state int currentCountIndex = 0; - - state std::vector > countInsertionRates; - - state double startTime = now(); - - while(currentCountIndex < countsOfInterest.size()) - { - try - { - state Future> countFuture = tr.getRange(keyPrefix, 1000000000); - state Future> bytesFuture = tr.getRange(bytesPrefix, 1000000000); - wait(success(countFuture) && success(bytesFuture)); - - Standalone counts = countFuture.get(); - Standalone bytes = bytesFuture.get(); - - uint64_t numInserted = 0; - for(int i = 0; i < counts.size(); i++) - numInserted += *(uint64_t*)counts[i].value.begin(); - - uint64_t bytesInserted = 0; - for(int i = 0; i < bytes.size(); i++) - bytesInserted += *(uint64_t*)bytes[i].value.begin(); - - while(currentCountIndex < countsOfInterest.size() && countsOfInterest[currentCountIndex] > lastInsertionCount && countsOfInterest[currentCountIndex] <= numInserted) - countInsertionRates.emplace_back(countsOfInterest[currentCountIndex++], bytesInserted / (now() - startTime)); - - lastInsertionCount = numInserted; - wait(delay(checkInterval)); - } - catch(Error& e) - { - wait(tr.onError(e)); - } - } - - return countInsertionRates; -} +ACTOR Future > > trackInsertionCount(Database cx, std::vector countsOfInterest, double checkInterval); ACTOR template Future bulkSetup(Database cx, T* workload, uint64_t nodeCount, Promise setupTime, diff --git a/fdbserver/workloads/ReadWrite.actor.cpp b/fdbserver/workloads/ReadWrite.actor.cpp index e5f8a0eb0d..8819a616da 100644 --- a/fdbserver/workloads/ReadWrite.actor.cpp +++ b/fdbserver/workloads/ReadWrite.actor.cpp @@ -679,5 +679,52 @@ struct ReadWriteWorkload : KVWorkload { } }; +ACTOR Future > > trackInsertionCount(Database cx, std::vector countsOfInterest, double checkInterval) +{ + state KeyRange keyPrefix = KeyRangeRef(std::string("keycount"), std::string("keycount") + char(255)); + state KeyRange bytesPrefix = KeyRangeRef(std::string("bytesstored"), std::string("bytesstored") + char(255)); + state Transaction tr(cx); + state uint64_t lastInsertionCount = 0; + state int currentCountIndex = 0; + + state std::vector > countInsertionRates; + + state double startTime = now(); + + while(currentCountIndex < countsOfInterest.size()) + { + try + { + state Future> countFuture = tr.getRange(keyPrefix, 1000000000); + state Future> bytesFuture = tr.getRange(bytesPrefix, 1000000000); + wait(success(countFuture) && success(bytesFuture)); + + Standalone counts = countFuture.get(); + Standalone bytes = bytesFuture.get(); + + uint64_t numInserted = 0; + for(int i = 0; i < counts.size(); i++) + numInserted += *(uint64_t*)counts[i].value.begin(); + + uint64_t bytesInserted = 0; + for(int i = 0; i < bytes.size(); i++) + bytesInserted += *(uint64_t*)bytes[i].value.begin(); + + while(currentCountIndex < countsOfInterest.size() && countsOfInterest[currentCountIndex] > lastInsertionCount && countsOfInterest[currentCountIndex] <= numInserted) + countInsertionRates.emplace_back(countsOfInterest[currentCountIndex++], bytesInserted / (now() - startTime)); + + lastInsertionCount = numInserted; + wait(delay(checkInterval)); + } + catch(Error& e) + { + wait(tr.onError(e)); + } + } + + return countInsertionRates; +} + + WorkloadFactory ReadWriteWorkloadFactory("ReadWrite"); diff --git a/fdbserver/workloads/UnitTests.actor.cpp b/fdbserver/workloads/UnitTests.actor.cpp index 0599218c2b..5d955e69cc 100644 --- a/fdbserver/workloads/UnitTests.actor.cpp +++ b/fdbserver/workloads/UnitTests.actor.cpp @@ -64,10 +64,10 @@ struct UnitTestWorkload : TestWorkload { ACTOR static Future runUnitTests(UnitTestWorkload* self) { state std::vector tests; - for (auto t = g_unittests.tests; t != NULL; t = t->next) { - if (StringRef(t->name).startsWith(self->testPattern)) { + for (auto test = g_unittests.tests; test != NULL; test = test->next) { + if (StringRef(test->name).startsWith(self->testPattern)) { ++self->testsAvailable; - tests.push_back(t); + tests.push_back(test); } } fprintf(stdout, "Found %zu tests\n", tests.size()); diff --git a/flow/Arena.h b/flow/Arena.h index 2028bd1f6b..7697d5cc2d 100644 --- a/flow/Arena.h +++ b/flow/Arena.h @@ -457,7 +457,7 @@ struct union_like_traits> : std::true_type { } template - static const void assign(Member& member, const T& t) { + static void assign(Member& member, const T& t) { member = t; } }; diff --git a/flow/FastAlloc.cpp b/flow/FastAlloc.cpp index e909c470ae..b29c29b7ba 100644 --- a/flow/FastAlloc.cpp +++ b/flow/FastAlloc.cpp @@ -47,6 +47,9 @@ #pragma warning (disable: 4073) #pragma init_seg(lib) #define INIT_SEG +#elif defined(__INTEL_COMPILER) +// intel compiler ignored INIT_SEG for thread local variables +#define INIT_SEG #elif defined(__GNUG__) #ifdef __linux__ #define INIT_SEG __attribute__ ((init_priority (1000))) diff --git a/flow/FastAlloc.h b/flow/FastAlloc.h index 1959816e54..94e76c82be 100644 --- a/flow/FastAlloc.h +++ b/flow/FastAlloc.h @@ -203,7 +203,7 @@ public: static void operator delete( void*, void* ) { } }; -static void* allocateFast(int size) { +inline void* allocateFast(int size) { if (size <= 16) return FastAllocator<16>::allocate(); if (size <= 32) return FastAllocator<32>::allocate(); if (size <= 64) return FastAllocator<64>::allocate(); @@ -214,7 +214,7 @@ static void* allocateFast(int size) { return new uint8_t[size]; } -static void freeFast(int size, void* ptr) { +inline void freeFast(int size, void* ptr) { if (size <= 16) return FastAllocator<16>::release(ptr); if (size <= 32) return FastAllocator<32>::release(ptr); if (size <= 64) return FastAllocator<64>::release(ptr); diff --git a/flow/ObjectSerializerTraits.h b/flow/ObjectSerializerTraits.h index 3301214e76..dc15cd9874 100644 --- a/flow/ObjectSerializerTraits.h +++ b/flow/ObjectSerializerTraits.h @@ -154,7 +154,7 @@ struct union_like_traits : std::false_type { static const index_t& get(const Member&); template - static const void assign(Member&, const Alternative&); + static void assign(Member&, const Alternative&); template static void done(Member&, Context&); @@ -171,7 +171,7 @@ struct struct_like_traits : std::false_type { static const index_t& get(const Member&); template - static const void assign(Member&, const index_t&); + static void assign(Member&, const index_t&); template static void done(Member&, Context&); @@ -190,7 +190,7 @@ struct union_like_traits> : std::true_type { } template - static const void assign(Member& member, const Alternative& a) { + static void assign(Member& member, const Alternative& a) { static_assert(std::is_same_v, Alternative>); member = a; } diff --git a/flow/flat_buffers.h b/flow/flat_buffers.h index a7ff261358..79fd1dcfcc 100644 --- a/flow/flat_buffers.h +++ b/flow/flat_buffers.h @@ -80,7 +80,7 @@ struct struct_like_traits> : std::true_type { } template - static const void assign(Member& m, const Type& t) { + static void assign(Member& m, const Type& t) { std::get(m) = t; } }; @@ -262,6 +262,11 @@ private: } else { return struct_offset_impl) + fb_scalar_size, index - 1, Ts...>::offset; } +#ifdef __INTEL_COMPILER + // ICC somehow things that this method does not return + // see: https://software.intel.com/en-us/forums/intel-c-compiler/topic/799473 + return 1; +#endif } public: @@ -685,15 +690,15 @@ struct SaveVisitorLambda { auto typeVectorWriter = writer.getMessageWriter(num_entries); // type tags are one byte auto offsetVectorWriter = writer.getMessageWriter(num_entries * sizeof(RelativeOffset)); auto iter = VectorTraits::begin(member); - for (int i = 0; i < num_entries; ++i) { + for (int j = 0; j < num_entries; ++j) { uint8_t type_tag = UnionTraits::index(*iter); uint8_t fb_type_tag = UnionTraits::empty(*iter) ? 0 : type_tag + 1; // Flatbuffers indexes from 1. - typeVectorWriter.write(&fb_type_tag, i, sizeof(fb_type_tag)); + typeVectorWriter.write(&fb_type_tag, j, sizeof(fb_type_tag)); if (!UnionTraits::empty(*iter)) { RelativeOffset offset = (SaveAlternative{ writer, vtableset }).save(type_tag, *iter); - offsetVectorWriter.write(&offset, i * sizeof(offset), sizeof(offset)); + offsetVectorWriter.write(&offset, j * sizeof(offset), sizeof(offset)); } ++iter; } @@ -1110,4 +1115,3 @@ struct EnsureTable { private: object_construction t; }; - diff --git a/flow/flow.h b/flow/flow.h index 7ce23eade7..04b68ed04b 100644 --- a/flow/flow.h +++ b/flow/flow.h @@ -221,7 +221,7 @@ struct union_like_traits> : std::true_type { } template - static const void assign(Member& m, const Alternative& a) { + static void assign(Member& m, const Alternative& a) { if constexpr (i == 0) { m = a; } else { diff --git a/flow/genericactors.actor.cpp b/flow/genericactors.actor.cpp index fd24381e3c..e5d200a25b 100644 --- a/flow/genericactors.actor.cpp +++ b/flow/genericactors.actor.cpp @@ -83,3 +83,49 @@ ACTOR Future quorumEqualsTrue( std::vector> futures, int requ } } } + +ACTOR Future shortCircuitAny( std::vector> f ) +{ + std::vector> sc; + for(Future fut : f) { + sc.push_back(returnIfTrue(fut)); + } + + choose { + when( wait( waitForAll( f ) ) ) { + // Handle a possible race condition? If the _last_ term to + // be evaluated triggers the waitForAll before bubbling + // out of the returnIfTrue quorum + for ( auto fut : f ) { + if ( fut.get() ) { + return true; + } + } + return false; + } + when( wait( waitForAny( sc ) ) ) { + return true; + } + } +} + +Future orYield( Future f ) { + if(f.isReady()) { + if(f.isError()) + return tagError(yield(), f.getError()); + else + return yield(); + } + else + return f; +} + +ACTOR Future returnIfTrue( Future f ) +{ + bool b = wait( f ); + if ( b ) { + return Void(); + } + wait( Never() ); + throw internal_error(); +} diff --git a/flow/genericactors.actor.h b/flow/genericactors.actor.h index 7b577b2e4c..0b3302517c 100644 --- a/flow/genericactors.actor.h +++ b/flow/genericactors.actor.h @@ -410,15 +410,7 @@ Future map( FutureStream input, F func, PromiseStream returnIfTrue( Future f ) -{ - bool b = wait( f ); - if ( b ) { - return Void(); - } - wait( Never() ); - throw internal_error(); -} +ACTOR Future returnIfTrue( Future f ); //Returns if the future, when waited on and then evaluated with the predicate, returns true, otherwise waits forever template @@ -972,30 +964,7 @@ Future waitForAny( std::vector> const& results ) { return quorum( results, 1 ); } -ACTOR static Future shortCircuitAny( std::vector> f ) -{ - std::vector> sc; - for(Future fut : f) { - sc.push_back(returnIfTrue(fut)); - } - - choose { - when( wait( waitForAll( f ) ) ) { - // Handle a possible race condition? If the _last_ term to - // be evaluated triggers the waitForAll before bubbling - // out of the returnIfTrue quorum - for ( auto fut : f ) { - if ( fut.get() ) { - return true; - } - } - return false; - } - when( wait( waitForAny( sc ) ) ) { - return true; - } - } -} +ACTOR Future shortCircuitAny( std::vector> f ); ACTOR template Future> getAll( std::vector> input ) { @@ -1132,16 +1101,7 @@ Future orYield( Future f ) { return f; } -static Future orYield( Future f ) { - if(f.isReady()) { - if(f.isError()) - return tagError(yield(), f.getError()); - else - return yield(); - } - else - return f; -} +Future orYield( Future f ); ACTOR template Future chooseActor( Future lhs, Future rhs ) { choose { @@ -1153,7 +1113,7 @@ ACTOR template Future chooseActor( Future lhs, Future rhs ) { // set && set -> set // error && x -> error // all others -> unset -static Future operator &&( Future const& lhs, Future const& rhs ) { +inline Future operator &&( Future const& lhs, Future const& rhs ) { if(lhs.isReady()) { if(lhs.isError()) return lhs; else return rhs; @@ -1428,7 +1388,7 @@ struct YieldedFutureActor : SAV, ActorCallback yieldedFuture(Future f) { +inline Future yieldedFuture(Future f) { if (f.isReady()) return yield(); else diff --git a/flow/serialize.h b/flow/serialize.h index e7431e7205..cde6e027e9 100644 --- a/flow/serialize.h +++ b/flow/serialize.h @@ -282,7 +282,7 @@ struct _IncludeVersion { ar >> v; if (!v.isValid()) { auto err = incompatible_protocol_version(); - TraceEvent(SevError, "InvalidSerializationVersion").error(err).detailf("Version", "%llx", v); + TraceEvent(SevError, "InvalidSerializationVersion").error(err).detailf("Version", "%llx", v.versionWithFlags()); throw err; } if (v > currentProtocolVersion) { @@ -290,7 +290,7 @@ struct _IncludeVersion { // particular data structures (e.g. to support mismatches between client and server versions when the client // must deserialize zookeeper and database structures) auto err = incompatible_protocol_version(); - TraceEvent(SevError, "FutureProtocolVersion").error(err).detailf("Version", "%llx", v); + TraceEvent(SevError, "FutureProtocolVersion").error(err).detailf("Version", "%llx", v.versionWithFlags()); throw err; } ar.setProtocolVersion(v);