Skip to content

Commit 154d35e

Browse files
BenHuddlestondaverigby
authored andcommitted
MB-32107: Reduce cache line contention by moving DcpProducer acquisition
Currently the cache line that holds the control block of the DcpProducer is one of the top three most contentious when running the daily kv/kv_max_ops_writes.test. This is because in ActiveStream::notifyStreamReady we lock the weak_ptr to the DcpProducer before checking if we have any items to send. We don't need the DcpProducer to check if we have any items to send, so swap the ordering of these checks. With this commit, there is no contention (hit modifieds) in the cahce line containing the control block of the DcpProducer. Perf testing of this commit was done against a build based on MadHatter build 1553 + the performance regressing commit identified in MB-32107 + the fix for the performance regressing commit as perf averages were already known. Average results for runs: 1553 - 1973894 ops/s (8 runs) Build without this commit - 1972524 (9 runs) (MH - 1553 + regressing commit + fix for regressing commit) Build with this commit - 1984044.625 (8 runs) (MH - 1553 + regressing commit + fix for regressing commit) Change-Id: Ib0c65100f8de52d2e2a06b4666d8d14ddb7ec1bc Reviewed-on: http://review.couchbase.org/104255 Tested-by: Build Bot <[email protected]> Reviewed-by: Dave Rigby <[email protected]>
1 parent 694319f commit 154d35e

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

engines/ep/src/dcp/active_stream.cc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,13 +1604,12 @@ spdlog::level::level_enum ActiveStream::getTransitionStateLogLevel(
16041604
}
16051605

16061606
void ActiveStream::notifyStreamReady(bool force) {
1607-
auto producer = producerPtr.lock();
1608-
if (!producer) {
1609-
return;
1610-
}
1611-
16121607
bool inverse = false;
16131608
if (force || itemsReady.compare_exchange_strong(inverse, true)) {
1609+
auto producer = producerPtr.lock();
1610+
if (!producer) {
1611+
return;
1612+
}
16141613
producer->notifyStreamReady(vb_);
16151614
}
16161615
}

0 commit comments

Comments
 (0)