Repository navigation
Conversation
If an entity becomes ready while its mutually exclusive callback group is executing in another thread, the idle executor threads skipped it in get_next_ready_executable() but kept it in their wait set. Level-triggered entities (e.g. a subscription with queued data, or a waitable that re-triggers its guard condition) then woke the wait set immediately, so the idle threads busy waited until the callback group was released. build_entities_collection() already excludes callback groups that cannot be taken from, but nothing requested a rebuild when this happened. Request a rebuild whenever a ready entity is skipped because of its callback group; the group is added back by the rebuild that follows the interrupt guard condition triggered once the group is released. This was the cause of the flaky TestBusyWaiting/MultiThreadedExecutor.test_spin failures in nightly_linux_repeated. Adds a deterministic regression test. Signed-off-by: Michael Carroll <mjcarroll.oss@gmail.com>
ABI Compliance Check✅ Verdict: compatible
✅
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes the remaining flake in
TestBusyWaitingseen innightly_linux_repeated:This is the same symptom as #3154. #3155 fixed a race in the test, but this one is a real busy wait in the
MultiThreadedExecutor.Root cause
When thread A takes an entity from a MutuallyExclusive callback group,
can_be_taken_frombecomesfalse. If the entity (or another one in the group) becomes ready again while A is still executing, the idle thread B:wait_for_work(),get_next_ready_executable()because its group is busy,wait_for_work()again with the same collection, since nothing setentities_need_rebuild_.For level-triggered entities (a subscription with queued data, or
TestWaitable, which re-triggers its guard condition inadd_to_wait_set()whiletrigger_count_ > 0), the wait returns immediately and B spins until A finishes and theinterrupt_guard_condition_triggers a rebuild.build_entities_collection()already excludes groups that can't be taken from, but that only helps if a rebuild happens while the group is busy. Intest_spinthat depends on whether the notify waitable fired in the same wait that picked up the first execution, which is a race. The busy wait then lasts as long as the first callback, which waits on the main thread and is long on a loaded CI machine.Fix
In
Executor::get_next_ready_executable(), setentities_need_rebuild_whenever a ready entity is skipped because its callback group is gone or can't be taken from. The next wait then excludes the busy group, and the existing post-executioninterrupt_guard_condition_trigger inMultiThreadedExecutor::run()adds it back once it is released. The extra rebuild only happens in the case that would otherwise busy wait