FDB compiling with intel compiler

This commit is contained in:
mpilman 2019-06-20 09:29:01 -07:00
parent df0baa0066
commit 844dd60202
38 changed files with 306 additions and 299 deletions

View File

@ -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
#endif

View File

@ -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($<$<BOOL:${GCC}>:-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(

View File

@ -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<bool> fileConfigure(Database db, std::string filePath, bool isNewDa
ACTOR Future<bool> coordinators( Database db, std::vector<StringRef> 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;
}

View File

@ -24,7 +24,7 @@
#include "fdbclient/CommitTransaction.h"
static ValueRef doLittleEndianAdd(const Optional<ValueRef>& existingValueOptional, const ValueRef& otherOperand, Arena& ar) {
inline ValueRef doLittleEndianAdd(const Optional<ValueRef>& 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<ValueRef>& existingValueOptiona
return StringRef(buf, i);
}
static ValueRef doAnd(const Optional<ValueRef>& existingValueOptional, const ValueRef& otherOperand, Arena& ar) {
inline ValueRef doAnd(const Optional<ValueRef>& 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<ValueRef>& existingValueOptional, const Val
return StringRef(buf, i);
}
static ValueRef doAndV2(const Optional<ValueRef>& existingValueOptional, const ValueRef& otherOperand, Arena& ar) {
inline ValueRef doAndV2(const Optional<ValueRef>& existingValueOptional, const ValueRef& otherOperand, Arena& ar) {
if (!existingValueOptional.present())
return otherOperand;
return doAnd(existingValueOptional, otherOperand, ar);
}
static ValueRef doOr(const Optional<ValueRef>& existingValueOptional, const ValueRef& otherOperand, Arena& ar) {
inline ValueRef doOr(const Optional<ValueRef>& 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<ValueRef>& existingValueOptional, const Valu
return StringRef(buf, i);
}
static ValueRef doXor(const Optional<ValueRef>& existingValueOptional, const ValueRef& otherOperand, Arena& ar) {
inline ValueRef doXor(const Optional<ValueRef>& 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<ValueRef>& existingValueOptional, const Val
return StringRef(buf, i);
}
static ValueRef doAppendIfFits(const Optional<ValueRef>& existingValueOptional, const ValueRef& otherOperand, Arena& ar) {
inline ValueRef doAppendIfFits(const Optional<ValueRef>& 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<ValueRef>& existingValueOptional,
return StringRef(buf, i+j);
}
static ValueRef doMax(const Optional<ValueRef>& existingValueOptional, const ValueRef& otherOperand, Arena& ar) {
inline ValueRef doMax(const Optional<ValueRef>& 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<ValueRef>& existingValueOptional, const Val
return otherOperand;
}
static ValueRef doByteMax(const Optional<ValueRef>& existingValueOptional, const ValueRef& otherOperand, Arena& ar) {
inline ValueRef doByteMax(const Optional<ValueRef>& 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<ValueRef>& existingValueOptional, const
return otherOperand;
}
static ValueRef doMin(const Optional<ValueRef>& existingValueOptional, const ValueRef& otherOperand, Arena& ar) {
inline ValueRef doMin(const Optional<ValueRef>& 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<ValueRef>& existingValueOptional, const Val
return otherOperand;
}
static ValueRef doMinV2(const Optional<ValueRef>& existingValueOptional, const ValueRef& otherOperand, Arena& ar) {
inline ValueRef doMinV2(const Optional<ValueRef>& existingValueOptional, const ValueRef& otherOperand, Arena& ar) {
if (!existingValueOptional.present())
return otherOperand;
return doMin(existingValueOptional, otherOperand, ar);
}
static ValueRef doByteMin(const Optional<ValueRef>& existingValueOptional, const ValueRef& otherOperand, Arena& ar) {
inline ValueRef doByteMin(const Optional<ValueRef>& 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<ValueRef>& existingValueOptional, const
return otherOperand;
}
static Optional<ValueRef> doCompareAndClear(const Optional<ValueRef>& existingValueOptional,
inline Optional<ValueRef> doCompareAndClear(const Optional<ValueRef>& existingValueOptional,
const ValueRef& otherOperand, Arena& ar) {
if (!existingValueOptional.present() || existingValueOptional.get() == otherOperand) {
// Clear the value.
@ -232,7 +232,7 @@ static Optional<ValueRef> doCompareAndClear(const Optional<ValueRef>& 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));

View File

@ -92,7 +92,7 @@ struct struct_like_traits<Tag> : std::true_type {
}
template <int i, class Type>
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 <class T>
static std::string describe( Reference<T> const& item ) {
std::string describe( Reference<T> const& item ) {
return item->toString();
}
template <class T>
static std::string describe( T const& item ) {
std::string describe( T const& item ) {
return item.toString();
}
template <class K, class V>
static std::string describe( std::map<K, V> const& items, int max_items = -1 ) {
std::string describe( std::map<K, V> const& items, int max_items = -1 ) {
if(!items.size())
return "[no items]";
@ -159,7 +159,7 @@ static std::string describe( std::map<K, V> const& items, int max_items = -1 ) {
}
template <class T>
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 <class T>
static std::string describe( std::vector<T> const& items, int max_items = -1 ) {
std::string describe( std::vector<T> const& items, int max_items = -1 ) {
return describeList(items, max_items);
}
template <class T>
static std::string describe( std::set<T> const& items, int max_items = -1 ) {
std::string describe( std::set<T> const& items, int max_items = -1 ) {
return describeList(items, max_items);
}
@ -492,7 +492,7 @@ struct KeyRangeWith : KeyRange {
}
};
template <class Val>
static inline KeyRangeWith<Val> keyRangeWith( const KeyRangeRef& range, const Val& value ) {
KeyRangeWith<Val> keyRangeWith( const KeyRangeRef& range, const Val& value ) {
return KeyRangeWith<Val>(range, value);
}
@ -757,7 +757,7 @@ struct AddressExclusion {
}
};
static bool addressExcluded( std::set<AddressExclusion> const& exclusions, NetworkAddress const& addr ) {
inline bool addressExcluded( std::set<AddressExclusion> const& exclusions, NetworkAddress const& addr ) {
return exclusions.count( AddressExclusion(addr.ip, addr.port) ) || exclusions.count( AddressExclusion(addr.ip) );
}

View File

@ -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<uint32_t>());}
int32_t consumeNetworkInt32() { return (int32_t)bigEndian32((uint32_t)consume< int32_t>());}
uint32_t consumeNetworkUInt32() { return bigEndian32( consume<uint32_t>());}
bool eof() { return rptr == end; }

View File

@ -104,8 +104,8 @@ std::map<std::string, std::string> 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;
}

View File

@ -36,7 +36,9 @@ Future<Void> monitorLeader( Reference<ClusterConnectionFile> 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<Void> monitorLeaderInternal( Reference<ClusterConnectionFile> const& connFile, Reference<AsyncVar<Value>> const& outSerializedLeaderInfo, Reference<AsyncVar<int>> const& connectedCoordinatorsNum );
@ -69,6 +71,8 @@ Future<Void> monitorLeader(Reference<ClusterConnectionFile> const& connFile,
return m || deserializer( serializedInfo, outKnownLeader );
}
#ifndef __INTEL_COMPILER
#pragma endregion
#endif
#endif

View File

@ -252,24 +252,6 @@ ACTOR Future<Void> databaseLogger( DatabaseContext *cx ) {
}
}
ACTOR static Future<Standalone<StringRef> > getSampleVersionStamp(Transaction *tr) {
loop{
try {
tr->reset();
tr->setOption(FDBTransactionOptions::PRIORITY_SYSTEM_IMMEDIATE);
wait(success(tr->get(LiteralStringRef("\xff/StatusJsonTestKey62793"))));
state Future<Standalone<StringRef> > vstamp = tr->getVersionstamp();
tr->makeSelfConflicting();
wait(tr->commit());
Standalone<StringRef> val = wait(vstamp);
return val;
}
catch (Error& e) {
wait(tr->onError(e));
}
}
}
struct TrInfoChunk {
ValueRef value;
Key key;

View File

@ -334,31 +334,31 @@ ACTOR Standalone<RangeResultRef> 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);

View File

@ -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<JSONDoc>(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<std::string> to_find) {
inline bool findMessagesByName(StatusObjectReader object, std::set<std::string> to_find) {
if (!object.has("messages") || object.last().type() != json_spirit::array_type)
return false;

View File

@ -53,9 +53,9 @@ Reference<ITransaction> ThreadSafeDatabase::createTransaction() {
void ThreadSafeDatabase::setOption( FDBDatabaseOptions::Option option, Optional<StringRef> value) {
DatabaseContext *db = this->db;
Standalone<Optional<StringRef>> 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;

View File

@ -252,10 +252,10 @@ static std::string describe(
}
return s;
}
static std::string describeZones( std::vector<LocalityData> const& items, int max_items = -1 ) {
inline std::string describeZones( std::vector<LocalityData> const& items, int max_items = -1 ) {
return describe(items, LocalityData::keyZoneId, max_items);
}
static std::string describeDataHalls( std::vector<LocalityData> const& items, int max_items = -1 ) {
inline std::string describeDataHalls( std::vector<LocalityData> const& items, int max_items = -1 ) {
return describe(items, LocalityData::keyDataHallId, max_items);
}

View File

@ -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());
}
}

View File

@ -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. */

View File

@ -262,14 +262,20 @@ Future<Void> switchTest( FutureStream<A> as, Future<B> oneb ) {
class TestBuffer : public ReferenceCounted<TestBuffer> {
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];
};

View File

@ -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)

View File

@ -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<KeyRangeMap<Version>> keyVersion;
};
static Reference<StorageInfo> getStorageInfo(UID id, std::map<UID, Reference<StorageInfo>>* storageCache, IKeyValueStore* txnStateStore) {
inline Reference<StorageInfo> getStorageInfo(UID id, std::map<UID, Reference<StorageInfo>>* storageCache, IKeyValueStore* txnStateStore) {
Reference<StorageInfo> storageInfo;
auto cacheItr = storageCache->find(id);
if(cacheItr == storageCache->end()) {
@ -59,7 +59,7 @@ static Reference<StorageInfo> getStorageInfo(UID id, std::map<UID, Reference<Sto
// It is incredibly important that any modifications to txnStateStore are done in such a way that
// the same operations will be done on all proxies at the same time. Otherwise, the data stored in
// txnStateStore will become corrupted.
static void applyMetadataMutations(UID const& dbgid, Arena &arena, VectorRef<MutationRef> const& mutations, IKeyValueStore* txnStateStore, LogPushData* toCommit, bool *confChange, Reference<ILogSystem> logSystem = Reference<ILogSystem>(), Version popVersion = 0,
inline void applyMetadataMutations(UID const& dbgid, Arena &arena, VectorRef<MutationRef> const& mutations, IKeyValueStore* txnStateStore, LogPushData* toCommit, bool *confChange, Reference<ILogSystem> logSystem = Reference<ILogSystem>(), Version popVersion = 0,
KeyRangeMap<std::set<Key> >* vecBackupKeys = NULL, KeyRangeMap<ServerCacheInfo>* keyInfo = NULL, std::map<Key, applyMutationsData>* uid_applyMutationsData = NULL, RequestStream<CommitTransactionRequest> commit = RequestStream<CommitTransactionRequest>(),
Database cx = Database(), NotifiedVersion* commitVersion = NULL, std::map<UID, Reference<StorageInfo>>* storageCache = NULL, std::map<Tag, Version>* tag_popped = NULL, bool initialCommit = false ) {
for (auto const& m : mutations) {

View File

@ -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 {

View File

@ -47,7 +47,9 @@ Future<Void> tryBecomeLeader( ServerCoordinators const& coordinators,
Future<Void> 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<Void> tryBecomeLeaderInternal( ServerCoordinators const& coordinators, Value const& proposedSerializedInterface, Reference<AsyncVar<Value>> const& outSerializedLeader, bool const& hasConnected, Reference<AsyncVar<ClusterControllerPriorityInfo>> const& asyncPriorityInfo );
@ -66,6 +68,8 @@ Future<Void> tryBecomeLeader( ServerCoordinators const& coordinators,
return m || asyncDeserialize(serializedInfo, outKnownLeader, g_network->useObjectSerializer());
}
#ifndef __INTEL_COMPILER
#pragma endregion
#endif // __INTEL_COMPILER
#endif

View File

@ -88,7 +88,7 @@ void SlowConflictSet::add( const VectorRef<KeyRangeRef>& 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; t<PARALLEL_THREAD_COUNT; t++) {
cs->worker_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; i<PARALLEL_THREAD_COUNT; i++)
done[i].block();
} else {
cs->versionHistory.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<StringRef,StringRef> >::iterator begin, std::vector< std::pair<StringRef,StringRef> >::iterator end,SkipList* part) {
@ -1258,7 +1259,7 @@ void ConflictBatch::addConflictRanges(Version now, std::vector< std::pair<String
}
void ConflictBatch::mergeWriteConflictRanges(Version now) {
if (!combinedWriteConflictRanges.size())
if (!combinedWriteConflictRanges.size())
return;
if (PARALLEL_THREAD_COUNT) {

View File

@ -1961,7 +1961,7 @@ ACTOR Future<StatusReply> 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<DatabaseConfiguration> configuration;

View File

@ -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<Version>( stripTagMessagesKey(key), Unversioned() ) );
}

View File

@ -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 ) {

View File

@ -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) {

View File

@ -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<Version> 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<Void> doEagerReads( StorageServer* data, UpdateEagerReadInfo* eager ) {
eager->finishKeyBegin();
@ -2940,10 +2954,14 @@ ACTOR Future<Void> 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<Void> StorageServerMetrics::waitMetrics(WaitMetricsRequest req, Future<Vo
return ::waitMetrics(this, req, delay);
}
#ifndef __INTEL_COMPILER
#pragma endregion
#endif
/////////////////////////////// Core //////////////////////////////////////
#ifndef __INTEL_COMPILER
#pragma region Core
#endif
ACTOR Future<Void> metricsCore( StorageServer* self, StorageServerInterface ssi ) {
state Future<Void> doPollMetrics = Void();
@ -3778,7 +3800,9 @@ ACTOR Future<Void> storageServer( IKeyValueStore* persistentData, StorageServerI
}
}
#ifndef __INTEL_COMPILER
#pragma endregion
#endif
/*
4 Reference count

View File

@ -155,51 +155,7 @@ Future<uint64_t> setupRangeWorker( Database cx, T* workload, std::vector<std::pa
//to reach that mark. Returns a vector of times (in seconds) corresponding to the counts in the countsOfInterest vector.
//Expects countsOfInterest to be sorted in ascending order
ACTOR static Future<std::vector<std::pair<uint64_t, double> > > trackInsertionCount(Database cx, std::vector<uint64_t> 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<std::pair<uint64_t, double> > countInsertionRates;
state double startTime = now();
while(currentCountIndex < countsOfInterest.size())
{
try
{
state Future<Standalone<RangeResultRef>> countFuture = tr.getRange(keyPrefix, 1000000000);
state Future<Standalone<RangeResultRef>> bytesFuture = tr.getRange(bytesPrefix, 1000000000);
wait(success(countFuture) && success(bytesFuture));
Standalone<RangeResultRef> counts = countFuture.get();
Standalone<RangeResultRef> 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<std::vector<std::pair<uint64_t, double> > > trackInsertionCount(Database cx, std::vector<uint64_t> countsOfInterest, double checkInterval);
ACTOR template <class T>
Future<Void> bulkSetup(Database cx, T* workload, uint64_t nodeCount, Promise<double> setupTime,

View File

@ -679,5 +679,52 @@ struct ReadWriteWorkload : KVWorkload {
}
};
ACTOR Future<std::vector<std::pair<uint64_t, double> > > trackInsertionCount(Database cx, std::vector<uint64_t> 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<std::pair<uint64_t, double> > countInsertionRates;
state double startTime = now();
while(currentCountIndex < countsOfInterest.size())
{
try
{
state Future<Standalone<RangeResultRef>> countFuture = tr.getRange(keyPrefix, 1000000000);
state Future<Standalone<RangeResultRef>> bytesFuture = tr.getRange(bytesPrefix, 1000000000);
wait(success(countFuture) && success(bytesFuture));
Standalone<RangeResultRef> counts = countFuture.get();
Standalone<RangeResultRef> 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<ReadWriteWorkload> ReadWriteWorkloadFactory("ReadWrite");

View File

@ -64,10 +64,10 @@ struct UnitTestWorkload : TestWorkload {
ACTOR static Future<Void> runUnitTests(UnitTestWorkload* self) {
state std::vector<UnitTest*> 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());

View File

@ -457,7 +457,7 @@ struct union_like_traits<Optional<T>> : std::true_type {
}
template <size_t i>
static const void assign(Member& member, const T& t) {
static void assign(Member& member, const T& t) {
member = t;
}
};

View File

@ -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)))

View File

@ -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);

View File

@ -154,7 +154,7 @@ struct union_like_traits : std::false_type {
static const index_t<i, alternatives>& get(const Member&);
template <int i, class Alternative>
static const void assign(Member&, const Alternative&);
static void assign(Member&, const Alternative&);
template <class Context>
static void done(Member&, Context&);
@ -171,7 +171,7 @@ struct struct_like_traits : std::false_type {
static const index_t<i, types>& get(const Member&);
template <int i>
static const void assign(Member&, const index_t<i, types>&);
static void assign(Member&, const index_t<i, types>&);
template <class Context>
static void done(Member&, Context&);
@ -190,7 +190,7 @@ struct union_like_traits<std::variant<Alternatives...>> : std::true_type {
}
template <size_t i, class Alternative>
static const void assign(Member& member, const Alternative& a) {
static void assign(Member& member, const Alternative& a) {
static_assert(std::is_same_v<index_t<i, alternatives>, Alternative>);
member = a;
}

View File

@ -80,7 +80,7 @@ struct struct_like_traits<std::tuple<Ts...>> : std::true_type {
}
template <int i, class Type>
static const void assign(Member& m, const Type& t) {
static void assign(Member& m, const Type& t) {
std::get<i>(m) = t;
}
};
@ -262,6 +262,11 @@ private:
} else {
return struct_offset_impl<RightAlign(o, fb_scalar_size<T>) + fb_scalar_size<T>, 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, UnionTraits>{ 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> t;
};

View File

@ -221,7 +221,7 @@ struct union_like_traits<ErrorOr<T>> : std::true_type {
}
template <int i, class Alternative>
static const void assign(Member& m, const Alternative& a) {
static void assign(Member& m, const Alternative& a) {
if constexpr (i == 0) {
m = a;
} else {

View File

@ -83,3 +83,49 @@ ACTOR Future<bool> quorumEqualsTrue( std::vector<Future<bool>> futures, int requ
}
}
}
ACTOR Future<bool> shortCircuitAny( std::vector<Future<bool>> f )
{
std::vector<Future<Void>> sc;
for(Future<bool> 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<Void> orYield( Future<Void> f ) {
if(f.isReady()) {
if(f.isError())
return tagError<Void>(yield(), f.getError());
else
return yield();
}
else
return f;
}
ACTOR Future<Void> returnIfTrue( Future<bool> f )
{
bool b = wait( f );
if ( b ) {
return Void();
}
wait( Never() );
throw internal_error();
}

View File

@ -410,15 +410,7 @@ Future<Void> map( FutureStream<T> input, F func, PromiseStream<typename std::res
}
//Returns if the future returns true, otherwise waits forever.
ACTOR static Future<Void> returnIfTrue( Future<bool> f )
{
bool b = wait( f );
if ( b ) {
return Void();
}
wait( Never() );
throw internal_error();
}
ACTOR Future<Void> returnIfTrue( Future<bool> f );
//Returns if the future, when waited on and then evaluated with the predicate, returns true, otherwise waits forever
template<class T, class F>
@ -972,30 +964,7 @@ Future<Void> waitForAny( std::vector<Future<T>> const& results ) {
return quorum( results, 1 );
}
ACTOR static Future<bool> shortCircuitAny( std::vector<Future<bool>> f )
{
std::vector<Future<Void>> sc;
for(Future<bool> 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<bool> shortCircuitAny( std::vector<Future<bool>> f );
ACTOR template <class T>
Future<std::vector<T>> getAll( std::vector<Future<T>> input ) {
@ -1132,16 +1101,7 @@ Future<T> orYield( Future<T> f ) {
return f;
}
static Future<Void> orYield( Future<Void> f ) {
if(f.isReady()) {
if(f.isError())
return tagError<Void>(yield(), f.getError());
else
return yield();
}
else
return f;
}
Future<Void> orYield( Future<Void> f );
ACTOR template <class T> Future<T> chooseActor( Future<T> lhs, Future<T> rhs ) {
choose {
@ -1153,7 +1113,7 @@ ACTOR template <class T> Future<T> chooseActor( Future<T> lhs, Future<T> rhs ) {
// set && set -> set
// error && x -> error
// all others -> unset
static Future<Void> operator &&( Future<Void> const& lhs, Future<Void> const& rhs ) {
inline Future<Void> operator &&( Future<Void> const& lhs, Future<Void> const& rhs ) {
if(lhs.isReady()) {
if(lhs.isError()) return lhs;
else return rhs;
@ -1428,7 +1388,7 @@ struct YieldedFutureActor : SAV<Void>, ActorCallback<YieldedFutureActor, 1, Void
}
};
static Future<Void> yieldedFuture(Future<Void> f) {
inline Future<Void> yieldedFuture(Future<Void> f) {
if (f.isReady())
return yield();
else

View File

@ -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);