change the first part of the UID to make comparisons cheaper

This commit is contained in:
Evan Tschannen 2020-05-19 16:48:20 -07:00
parent ead17d6a7f
commit 9313e490aa
3 changed files with 17 additions and 4 deletions

View File

@ -85,7 +85,20 @@ struct StorageServerInterface {
// versioned carefully!
if (ar.protocolVersion().hasSmallEndpoints()) {
serializer(ar, uniqueID, locality, getValue, getKey, getKeyValues, getShardState, waitMetrics, splitMetrics, getStorageMetrics, waitFailure, getQueuingMetrics, getKeyValueStoreType, watchValue, getReadHotRanges);
serializer(ar, uniqueID, locality, getValue);
if( Ar::isDeserializing ) {
getKey = RequestStream<struct GetKeyRequest>( base.getAdjustedEndpoint(1) );
getKeyValues = RequestStream<struct GetKeyValuesRequest>( base.getAdjustedEndpoint(2) );
getShardState = RequestStream<struct GetShardStateRequest>( base.getAdjustedEndpoint(3) );
waitMetrics = RequestStream<struct WaitMetricsRequest>( base.getAdjustedEndpoint(4) );
splitMetrics = RequestStream<struct SplitMetricsRequest>( base.getAdjustedEndpoint(5) );
getStorageMetrics = RequestStream<struct GetStorageMetricsRequest>( base.getAdjustedEndpoint(6) );
waitFailure = RequestStream<ReplyPromise<Void>>( base.getAdjustedEndpoint(7) );
getQueuingMetrics = RequestStream<struct StorageQueuingMetricsRequest>( base.getAdjustedEndpoint(8) );
getKeyValueStoreType = RequestStream<ReplyPromise<KeyValueStoreType>>( base.getAdjustedEndpoint(9) );
watchValue = RequestStream<struct WatchValueRequest>( base.getAdjustedEndpoint(10) );
getReadHotRanges = RequestStream<struct ReadHotSubRangeRequest>( base.getAdjustedEndpoint(11) );
}
} else {
ASSERT(Ar::isDeserializing);
if constexpr (is_fb_function<Ar>) {

View File

@ -124,8 +124,8 @@ const Endpoint& EndpointMap::insert( NetworkAddressList localAddresses, std::vec
UID base = deterministicRandom()->randomUniqueID();
for(int i=0; i<streams.size(); i++) {
int index = adjacentStart+i;
streams[i].first->setEndpoint( Endpoint( localAddresses, UID( base.first() | TOKEN_STREAM_FLAG, (base.second()&0xffffffff00000000LL) | index) ) );
data[index].token() = Endpoint::Token( base.first() | TOKEN_STREAM_FLAG, (base.second()&0xffffffff00000000LL) | static_cast<uint32_t>(streams[i].second) );
streams[i].first->setEndpoint( Endpoint( localAddresses, UID( (base.first()+(2*index)) | TOKEN_STREAM_FLAG, (base.second()&0xffffffff00000000LL) | index) ) );
data[index].token() = Endpoint::Token( (base.first()+(2*index)) | TOKEN_STREAM_FLAG, (base.second()&0xffffffff00000000LL) | static_cast<uint32_t>(streams[i].second) );
data[index].receiver = (NetworkMessageReceiver*) streams[i].first;
}

View File

@ -68,7 +68,7 @@ public:
Endpoint getAdjustedEndpoint( uint32_t index ) {
uint32_t newIndex = token.second();
newIndex += index;
return Endpoint( addresses, UID(token.first(), (token.second()&0xffffffff00000000LL) | newIndex) );
return Endpoint( addresses, UID(token.first()+(2*newIndex), (token.second()&0xffffffff00000000LL) | newIndex) );
}
bool operator == (Endpoint const& r) const {