Skip to content

Commit

Permalink
SERVER-95072 Reintroduce runOnDataAvailable to SessionWorkflow (#27330)
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 719c05ac8dae71f39c7a74669ab0575b1ef1bece
  • Loading branch information
mbroadst authored and MongoDB Bot committed Oct 1, 2024
1 parent 53ac03e commit 5c59972
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
3 changes: 3 additions & 0 deletions src/mongo/transport/service_executor_bm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "mongo/transport/service_executor.h"
#include "mongo/transport/service_executor_synchronous.h"
#include "mongo/unittest/barrier.h"
#include "mongo/unittest/log_test.h"
#include "mongo/util/duration.h"
#include "mongo/util/processinfo.h"

Expand Down Expand Up @@ -92,6 +93,8 @@ class ServiceExecutorSynchronousBm : public benchmark::Fixture {
}

void lastTearDown() {
unittest::MinimumLoggedSeverityGuard suppressNetworkInfoGuard{
logv2::LogComponent::kNetwork, logv2::LogSeverity::Warning()};
(void)executor()->shutdown(Hours{1});
setGlobalServiceContext({});
}
Expand Down
1 change: 0 additions & 1 deletion src/mongo/transport/service_executor_reserved.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ void ServiceExecutorReserved::_runOnDataAvailable(const std::shared_ptr<Session>
Task task) {
invariant(session);
_schedule([this, session, callback = std::move(task)](Status status) {
yieldIfAppropriate();
if (!status.isOK()) {
callback(std::move(status));
return;
Expand Down
1 change: 0 additions & 1 deletion src/mongo/transport/service_executor_synchronous.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ auto ServiceExecutorSyncImpl::makeTaskRunner() -> std::unique_ptr<TaskRunner> {

void runOnDataAvailable(std::shared_ptr<Session> session, Task task) override {
invariant(session);
_e->yieldIfAppropriate();
_e->_sharedState->schedule(std::move(task), _e->getName());
}

Expand Down
15 changes: 10 additions & 5 deletions src/mongo/transport/session_workflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -790,23 +790,28 @@ Future<void> SessionWorkflow::Impl::_doOneIteration() {

void SessionWorkflow::Impl::_scheduleIteration() try {
_work = nullptr;
taskRunner()->schedule(_captureContext([&](Status status) {
auto runOneIteration = _captureContext([&](Status status) {
if (MONGO_unlikely(!status.isOK())) {
_cleanupSession(status);
return;
}

try {
// All available service executors use dedicated threads, so it's okay to
// run eager futures in an ordinary loop to bypass scheduler overhead.
while (true) {
// run eager futures in an ordinary loop to bypass scheduler overhead. Loop
// while we have `_nextWork` in case there have been synthetic exhaust
// requests produced on this iteration.
do {
_doOneIteration().get();
_work = nullptr;
}
} while (_nextWork);
_scheduleIteration();
} catch (const DBException& ex) {
_onLoopError(ex.toStatus());
}
}));
});

taskRunner()->runOnDataAvailable(session(), std::move(runOneIteration));
} catch (const DBException& ex) {
auto error = ex.toStatus();
LOGV2_WARNING_OPTIONS(22993,
Expand Down

0 comments on commit 5c59972

Please sign in to comment.