- Optimize out the version vector specific code (on the client)

when the version vector feature is disabled.
This commit is contained in:
Sreenath Bodagala 2022-06-28 09:17:53 +00:00
parent 9ac7a1aed8
commit 0da13a7797
2 changed files with 32 additions and 16 deletions

View File

@ -611,6 +611,14 @@ public:
// Cache of the latest commit versions of storage servers.
VersionVector ssVersionVectorCache;
// Introduced mainly to optimize out the version vector related code (on the client side)
// when the version vector feature is disabled (on the server side).
// @param ssVersionVectorDelta version vector changes sent by GRV proxy
bool mayNeedToUpdateVersionVectorCache(const VersionVector& ssVersionVectorDelta) {
return (ssVersionVectorCache.getMaxVersion() != invalidVersion ||
ssVersionVectorDelta.getMaxVersion() != invalidVersion);
}
// Adds or updates the specified (SS, TSS) pair in the TSS mapping (if not already present).
// Requests to the storage server will be duplicated to the TSS.
void addTssMapping(StorageServerInterface const& ssi, StorageServerInterface const& tssi);

View File

@ -3474,10 +3474,12 @@ ACTOR Future<Version> waitForCommittedVersion(Database cx, Version version, Span
cx->minAcceptableReadVersion = std::min(cx->minAcceptableReadVersion, v.version);
if (v.midShardSize > 0)
cx->smoothMidShardSize.setTotal(v.midShardSize);
if (cx->isCurrentGrvProxy(v.proxyId)) {
cx->ssVersionVectorCache.applyDelta(v.ssVersionVectorDelta);
} else {
cx->ssVersionVectorCache.clear();
if (cx->mayNeedToUpdateVersionVectorCache(v.ssVersionVectorDelta)) {
if (cx->isCurrentGrvProxy(v.proxyId)) {
cx->ssVersionVectorCache.applyDelta(v.ssVersionVectorDelta);
} else {
cx->ssVersionVectorCache.clear();
}
}
if (v.version >= version)
return v.version;
@ -3506,10 +3508,12 @@ ACTOR Future<Version> getRawVersion(Reference<TransactionState> trState) {
TransactionPriority::IMMEDIATE,
trState->cx->ssVersionVectorCache.getMaxVersion()),
trState->cx->taskID))) {
if (trState->cx->isCurrentGrvProxy(v.proxyId)) {
trState->cx->ssVersionVectorCache.applyDelta(v.ssVersionVectorDelta);
} else {
trState->cx->ssVersionVectorCache.clear();
if (trState->cx->mayNeedToUpdateVersionVectorCache(v.ssVersionVectorDelta)) {
if (trState->cx->isCurrentGrvProxy(v.proxyId)) {
trState->cx->ssVersionVectorCache.applyDelta(v.ssVersionVectorDelta);
} else {
trState->cx->ssVersionVectorCache.clear();
}
}
return v.version;
}
@ -6640,10 +6644,12 @@ ACTOR Future<GetReadVersionReply> getConsistentReadVersion(SpanContext parentSpa
"TransactionDebug", debugID.get().first(), "NativeAPI.getConsistentReadVersion.After");
ASSERT(v.version > 0);
cx->minAcceptableReadVersion = std::min(cx->minAcceptableReadVersion, v.version);
if (cx->isCurrentGrvProxy(v.proxyId)) {
cx->ssVersionVectorCache.applyDelta(v.ssVersionVectorDelta);
} else {
continue; // stale GRV reply, retry
if (cx->mayNeedToUpdateVersionVectorCache(v.ssVersionVectorDelta)) {
if (cx->isCurrentGrvProxy(v.proxyId)) {
cx->ssVersionVectorCache.applyDelta(v.ssVersionVectorDelta);
} else {
continue; // stale GRV reply, retry
}
}
return v;
}
@ -6830,10 +6836,12 @@ ACTOR Future<Version> extractReadVersion(Reference<TransactionState> trState,
}
metadataVersion.send(rep.metadataVersion);
if (trState->cx->isCurrentGrvProxy(rep.proxyId)) {
trState->cx->ssVersionVectorCache.applyDelta(rep.ssVersionVectorDelta);
} else {
trState->cx->ssVersionVectorCache.clear();
if (trState->cx->mayNeedToUpdateVersionVectorCache(rep.ssVersionVectorDelta)) {
if (trState->cx->isCurrentGrvProxy(rep.proxyId)) {
trState->cx->ssVersionVectorCache.applyDelta(rep.ssVersionVectorDelta);
} else {
trState->cx->ssVersionVectorCache.clear();
}
}
return rep.version;
}