Skip to content
Snippets Groups Projects
Commit 2abd53e0 authored by Florian Fischer's avatar Florian Fischer
Browse files

load CQ->tail only once during lockless stealing

Currently we load the CQ->tail with acquire semantic to determine
if we should steal from teh victim and load it again in the actual
stealing logic which will also immediately abort if there are no
CQEs to steal.

Keep the optimization for the locked case.
parent a892f8f1
No related branches found
No related tags found
No related merge requests found
...@@ -413,6 +413,12 @@ class IoContext : public Logger<LogSubsystem::IO> { ...@@ -413,6 +413,12 @@ class IoContext : public Logger<LogSubsystem::IO> {
return reapCompletionsLockless<callerEnvironment>(continuations, toReap); return reapCompletionsLockless<callerEnvironment>(continuations, toReap);
} }
// CallerEnvironment::EMPER means we are in a stealing worker.
// Check if the victim's CQ is empty before taking the lock.
if constexpr (callerEnvironment == CallerEnvironment::EMPER) {
if (!cqeCount()) return 0;
}
return reapCompletionsLocked<callerEnvironment>(continuations, toReap); return reapCompletionsLocked<callerEnvironment>(continuations, toReap);
} }
......
...@@ -139,14 +139,12 @@ popTop: ...@@ -139,14 +139,12 @@ popTop:
if constexpr (emper::IO_STEALING) { if constexpr (emper::IO_STEALING) {
auto* victimIo = runtime.ioContexts[victim]; auto* victimIo = runtime.ioContexts[victim];
if (victimIo->cqeCount()) {
fiber = victimIo->reapSingleCompletion<CallerEnvironment::EMPER>(); fiber = victimIo->reapSingleCompletion<CallerEnvironment::EMPER>();
if (fiber) { if (fiber) {
emper::statsIncr(awss::stats.nextIoFiberStolen); emper::statsIncr(awss::stats.nextIoFiberStolen);
return std::make_pair(fiber, FiberSource::ioStolen); return std::make_pair(fiber, FiberSource::ioStolen);
} }
} }
}
return std::nullopt; return std::nullopt;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment