Skip to content

Commit 0da13a7

Browse files
committed
- Optimize out the version vector specific code (on the client)
when the version vector feature is disabled.
1 parent 9ac7a1a commit 0da13a7

File tree

2 files changed

+32
-16
lines changed

2 files changed

+32
-16
lines changed

fdbclient/DatabaseContext.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,14 @@ class DatabaseContext : public ReferenceCounted<DatabaseContext>, public FastAll
611611
// Cache of the latest commit versions of storage servers.
612612
VersionVector ssVersionVectorCache;
613613

614+
// Introduced mainly to optimize out the version vector related code (on the client side)
615+
// when the version vector feature is disabled (on the server side).
616+
// @param ssVersionVectorDelta version vector changes sent by GRV proxy
617+
bool mayNeedToUpdateVersionVectorCache(const VersionVector& ssVersionVectorDelta) {
618+
return (ssVersionVectorCache.getMaxVersion() != invalidVersion ||
619+
ssVersionVectorDelta.getMaxVersion() != invalidVersion);
620+
}
621+
614622
// Adds or updates the specified (SS, TSS) pair in the TSS mapping (if not already present).
615623
// Requests to the storage server will be duplicated to the TSS.
616624
void addTssMapping(StorageServerInterface const& ssi, StorageServerInterface const& tssi);

fdbclient/NativeAPI.actor.cpp

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3474,10 +3474,12 @@ ACTOR Future<Version> waitForCommittedVersion(Database cx, Version version, Span
34743474
cx->minAcceptableReadVersion = std::min(cx->minAcceptableReadVersion, v.version);
34753475
if (v.midShardSize > 0)
34763476
cx->smoothMidShardSize.setTotal(v.midShardSize);
3477-
if (cx->isCurrentGrvProxy(v.proxyId)) {
3478-
cx->ssVersionVectorCache.applyDelta(v.ssVersionVectorDelta);
3479-
} else {
3480-
cx->ssVersionVectorCache.clear();
3477+
if (cx->mayNeedToUpdateVersionVectorCache(v.ssVersionVectorDelta)) {
3478+
if (cx->isCurrentGrvProxy(v.proxyId)) {
3479+
cx->ssVersionVectorCache.applyDelta(v.ssVersionVectorDelta);
3480+
} else {
3481+
cx->ssVersionVectorCache.clear();
3482+
}
34813483
}
34823484
if (v.version >= version)
34833485
return v.version;
@@ -3506,10 +3508,12 @@ ACTOR Future<Version> getRawVersion(Reference<TransactionState> trState) {
35063508
TransactionPriority::IMMEDIATE,
35073509
trState->cx->ssVersionVectorCache.getMaxVersion()),
35083510
trState->cx->taskID))) {
3509-
if (trState->cx->isCurrentGrvProxy(v.proxyId)) {
3510-
trState->cx->ssVersionVectorCache.applyDelta(v.ssVersionVectorDelta);
3511-
} else {
3512-
trState->cx->ssVersionVectorCache.clear();
3511+
if (trState->cx->mayNeedToUpdateVersionVectorCache(v.ssVersionVectorDelta)) {
3512+
if (trState->cx->isCurrentGrvProxy(v.proxyId)) {
3513+
trState->cx->ssVersionVectorCache.applyDelta(v.ssVersionVectorDelta);
3514+
} else {
3515+
trState->cx->ssVersionVectorCache.clear();
3516+
}
35133517
}
35143518
return v.version;
35153519
}
@@ -6640,10 +6644,12 @@ ACTOR Future<GetReadVersionReply> getConsistentReadVersion(SpanContext parentSpa
66406644
"TransactionDebug", debugID.get().first(), "NativeAPI.getConsistentReadVersion.After");
66416645
ASSERT(v.version > 0);
66426646
cx->minAcceptableReadVersion = std::min(cx->minAcceptableReadVersion, v.version);
6643-
if (cx->isCurrentGrvProxy(v.proxyId)) {
6644-
cx->ssVersionVectorCache.applyDelta(v.ssVersionVectorDelta);
6645-
} else {
6646-
continue; // stale GRV reply, retry
6647+
if (cx->mayNeedToUpdateVersionVectorCache(v.ssVersionVectorDelta)) {
6648+
if (cx->isCurrentGrvProxy(v.proxyId)) {
6649+
cx->ssVersionVectorCache.applyDelta(v.ssVersionVectorDelta);
6650+
} else {
6651+
continue; // stale GRV reply, retry
6652+
}
66476653
}
66486654
return v;
66496655
}
@@ -6830,10 +6836,12 @@ ACTOR Future<Version> extractReadVersion(Reference<TransactionState> trState,
68306836
}
68316837

68326838
metadataVersion.send(rep.metadataVersion);
6833-
if (trState->cx->isCurrentGrvProxy(rep.proxyId)) {
6834-
trState->cx->ssVersionVectorCache.applyDelta(rep.ssVersionVectorDelta);
6835-
} else {
6836-
trState->cx->ssVersionVectorCache.clear();
6839+
if (trState->cx->mayNeedToUpdateVersionVectorCache(rep.ssVersionVectorDelta)) {
6840+
if (trState->cx->isCurrentGrvProxy(rep.proxyId)) {
6841+
trState->cx->ssVersionVectorCache.applyDelta(rep.ssVersionVectorDelta);
6842+
} else {
6843+
trState->cx->ssVersionVectorCache.clear();
6844+
}
68376845
}
68386846
return rep.version;
68396847
}

0 commit comments

Comments
 (0)