Open
Conversation
3c31730 to
742f369
Compare
742f369 to
caa62ad
Compare
67e3b0a to
ee16ae3
Compare
ee16ae3 to
2549212
Compare
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.
Overview
See ASYNC_API.md for a detailed description of the API and design.
The current implementation is tested and ready to merge.
Known Limitations: Head-of-Line Blocking
The scheduler can exhibit head-of-line (HoL) blocking, which may be surprising to users.
In practice, I've worked around this by manually adding extra dependencies between operations to constrain the scheduler's decision space. However, this makes real-world usage of SpikeAsync more involved than the simple model described in ASYNC_API.md.
Why It Happens
The scheduler performs a topological sort at scheduling time. When only logical dependencies are specified, multiple valid topological orderings exist — and some of them are suboptimal. Different scheduling algorithms will select different orderings among the valid ones.
The current algorithm uses FIFO ordering. Consider the following example:
Running 3 instances concurrently:
When
use_resource_*()is called, the request is immediately pushed to the corresponding resource's FIFO queue. Because all 3 instances ofXare enqueued before any instance ofY, the resulting schedule is:Resource B sits idle while resource A drains the backlog — a classic HoL blocking scenario. The ideal interleaving would be:
Workaround
We can achieve optimal interleaving without modifying the scheduler by adding cross-instance dependency edges:
Future Work
I'm considering alternative scheduling algorithms, but there is no one-size-fits-all solution — different algorithms perform best under different workload patterns. I believe this warrants further discussion and is best treated as future work.