fibers yield won't have event loop serviced
- Dominant language
- C++
- Stars
- 30.5k
- Forks
- 5.9k
- PR merge metrics
- No merged PRs in 30d
Description
I have one filber sending a large payload, yield every MB, and keep sending background echo requests to test yield, and see 100ms+ latency for echo requests. strace showes that epoll_wait won't be serviced until send would block.
( EventBase thread for fiberManager, AsyncSocket for socket read/write )
After check the code, I think the related logic is FiberManager::runFibersHelper's ensureLoopScheduled:
```
SCOPE_EXIT {
...
readyFibers_.splice(readyFibers_.end(), yieldedFibers);
RequestContext::setContext(std::move(curCtx));
if (!readyFibers_.empty()) {
ensureLoopScheduled();
}
```
yieldedFibers in this loop were added to readyFibers_ , and trigger ensureLoopScheduled, but always be scheduled in EventBase's thisIteration, so will run another loopUntilNoReadyImpl immediately, until that yielding fiber also blocked.
But FiberManager::yield()'s comment explicitly states that
> ... The calling fiber will be scheduled
> when all other fibers have had a chance to run and the event loop is
> serviced.
Contributor guide
Assessment
This issue has not been assessed yet.