-
Notifications
You must be signed in to change notification settings - Fork 2
Event-driven scheduler: remove 10ms poll floor and 1s dependency-chain stalls #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
andre-merzky
wants to merge
8
commits into
main
Choose a base branch
from
feature/nosleep
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3cfc687
Track futures passed as kwargs as task dependencies
andre-merzky 8a8f304
Make the run loop react to task completion via events, not polling
andre-merzky 500bab4
Address Copilot review; docformatter pass for pre-commit CI
andre-merzky baeaa5a
Merge branch 'main' into feature/nosleep
andre-merzky 0f4b4ed
Merge branch 'main' into feature/nosleep
andre-merzky 16fc72f
linting
andre-merzky e59ab5c
Merge branch 'feature/nosleep' of github.com:radical-cybertools/radic…
andre-merzky 9c5b0a1
linting
andre-merzky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| """Scheduler responsiveness: the run loop must react to component completion | ||
| via events, not a fixed poll interval. | ||
|
|
||
| Regression tests for two latency defects of the former poll-based loop: | ||
|
|
||
| - a hardcoded 10ms sleep after every active pass put a ~10ms floor on each | ||
| task round-trip, and | ||
| - a dependent task behind a dependency running longer than that poll | ||
| interval was only submitted when the 1s event-wait timed out (~1s stall | ||
| per dependency edge). | ||
| """ | ||
|
|
||
| import asyncio | ||
| import time | ||
|
|
||
| import pytest | ||
| import pytest_asyncio | ||
|
|
||
| from radical.asyncflow import LocalExecutionBackend, WorkflowEngine | ||
|
|
||
|
|
||
| class TestSchedulerResponsiveness: | ||
| @pytest_asyncio.fixture | ||
| async def flow(self): | ||
| backend = await LocalExecutionBackend() | ||
| flow = await WorkflowEngine.create(backend=backend) | ||
| yield flow | ||
| await flow.shutdown() | ||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_dependent_starts_promptly_after_dependency(self, flow): | ||
| """A chain behind a 50ms task must not stall in the 1s event-wait.""" | ||
|
|
||
| @flow.function_task | ||
| async def slow(): | ||
| await asyncio.sleep(0.05) | ||
| return 1 | ||
|
|
||
| @flow.function_task | ||
| async def fast(dep): | ||
| return dep + 1 | ||
|
|
||
| start = time.perf_counter() | ||
| result = await fast(slow()) | ||
| elapsed = time.perf_counter() - start | ||
|
|
||
| assert result == 2 | ||
| # poll-based loop needed ~1.05s here; allow generous CI margin | ||
| assert elapsed < 0.5, f"dependent task stalled: {elapsed:.3f}s" | ||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_sequential_latency_below_poll_interval(self, flow): | ||
| """Per-task round-trip must beat the former 10ms poll floor.""" | ||
|
|
||
| @flow.function_task | ||
| async def noop(): | ||
| return None | ||
|
|
||
| n = 20 | ||
| await noop() # warmup | ||
| start = time.perf_counter() | ||
| for _ in range(n): | ||
| await noop() | ||
| avg = (time.perf_counter() - start) / n | ||
|
|
||
| # poll-based loop could not go below 10ms per task | ||
| assert avg < 0.008, f"avg task round-trip too slow: {avg * 1000:.1f}ms" |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.