Skip to content

Commit

Permalink
Async: Do not invoke timers callbacks multiple times on io_uring backend
Browse files Browse the repository at this point in the history
  • Loading branch information
Pagghiu committed Aug 25, 2024
1 parent 9b1b2d0 commit 3735432
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
10 changes: 8 additions & 2 deletions Libraries/Async/Async.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -713,15 +713,21 @@ SC::Result SC::AsyncEventLoop::Internal::dispatchCompletions(SyncMode syncMode,
switch (syncMode)
{
case SyncMode::NoWait: {
invokeExpiredTimers(loopTime);
if (kernelEvents.needsManualTimersProcessing())
{
invokeExpiredTimers(loopTime);
}
}
break;
case SyncMode::ForcedForwardProgress: {
if (expiredTimer)
{
expiredTimer = nullptr;
updateTime();
invokeExpiredTimers(loopTime);
if (kernelEvents.needsManualTimersProcessing())
{
invokeExpiredTimers(loopTime);
}
}
}
break;
Expand Down
4 changes: 3 additions & 1 deletion Libraries/Async/Internal/AsyncLinux.inl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ struct SC::AsyncEventLoop::Internal::KernelEvents
{
return true;
}


bool needsManualTimersProcessing() { return isEpoll; }

template <typename T, typename P> [[nodiscard]] static Result executeOperation(T&, P& p);
// clang-format on
};
Expand Down
2 changes: 2 additions & 0 deletions Libraries/Async/Internal/AsyncPosix.inl
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,8 @@ struct SC::AsyncEventLoop::Internal::KernelEventsPosix

static bool needsSubmissionWhenReactivating(AsyncFilePoll&) { return false; }

static bool needsManualTimersProcessing() { return true; }

//-------------------------------------------------------------------------------------------------------
// File CLOSE
//-------------------------------------------------------------------------------------------------------
Expand Down
7 changes: 3 additions & 4 deletions Libraries/Async/Internal/AsyncWindows.inl
Original file line number Diff line number Diff line change
Expand Up @@ -687,10 +687,9 @@ struct SC::AsyncEventLoop::Internal::KernelEvents

// If False, makes re-activation a no-op, that is a lightweight optimization.
// More importantly it prevents an assert about being Submitting state when async completes during re-activation run cycle.
template<typename T> static bool needsSubmissionWhenReactivating(T&)
{
return true;
}
template<typename T> static bool needsSubmissionWhenReactivating(T&) { return true; }

static bool needsManualTimersProcessing() { return true; }

template <typename T, typename P> [[nodiscard]] static Result executeOperation(T&, P&) { return Result::Error("Implement executeOperation"); }
// clang-format on
Expand Down

0 comments on commit 3735432

Please sign in to comment.