feat(hydro_lang): add sim_atomic_input with scheduler support#2851
Open
shadaj wants to merge 1 commit into
Open
feat(hydro_lang): add sim_atomic_input with scheduler support#2851shadaj wants to merge 1 commit into
shadaj wants to merge 1 commit into
Conversation
d30aa7d to
0826e9f
Compare
Deploying hydro with
|
| Latest commit: |
a804d81
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://3f6b5466.hydroflow.pages.dev |
| Branch Preview URL: | https://sandbox-15952e72-fc63-4b8e-a.hydroflow.pages.dev |
dd3fe00 to
87ae805
Compare
87ae805 to
0022399
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Adds Process::sim_atomic_input() for the Hydro simulator, returning a SimAtomicSender paired with a Stream whose source is placed directly inside an Atomic<Process> location. A new AtomicSourceHook lets the scheduler treat pending atomic-input items as a non-trivial reason to advance the tick, enabling exhaustive exploration of both same-tick and later-tick interleavings between the atomic input and other inputs. Existing request_response tests are ported off the ack pattern to the simpler synchronous API.
Changes:
- New
SimAtomicSenderwrapper with synchronoussend_atomic/send_many_atomic[_unordered]methods. - New
AtomicSourceHookand dedicatedcreate_external_sourcebranch in the sim builder that buffers items at the root location and releases them into the tick graph via the hook. - New
Process::sim_atomic_inputconstructor andsim_atomic_input_same_tickregression test;hydro_std::request_responsetests migrated to the new API.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| hydro_lang/src/sim/mod.rs | Declares the SimAtomicSender wrapper type. |
| hydro_lang/src/sim/compiled.rs | Implements synchronous send_atomic / send_many*_atomic on SimAtomicSender. |
| hydro_lang/src/sim/runtime.rs | Adds AtomicSourceHook that drains all pending items on each scheduler decision. |
| hydro_lang/src/sim/builder.rs | Special-cases LocationId::Atomic in create_external_source to install the hook and bridge buffer→tick. |
| hydro_lang/src/location/process.rs | Adds Process::sim_atomic_input constructing an ExternalInput directly at the Atomic location. |
| hydro_lang/src/location/tick.rs | Adds sim_atomic_input_same_tick regression test asserting both interleavings are explored. |
| hydro_std/src/request_response.rs | Ports four tests from the ack pattern to sim_atomic_input / send_atomic. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
shadaj
added a commit
that referenced
this pull request
May 20, 2026
Places the ExternalInput source directly at the Atomic location and adds an AtomicSourceHook that signals readiness when items are pending. This allows the sim scheduler to explore both orderings: the batch for the regular input being non-empty on the first tick (same tick as atomic write) or empty (read comes in a later tick). send_atomic is synchronous — values are immediately available in the next atomic slice without requiring a separate tick or ack pattern. Closes #2380 PR: #2851
0022399 to
023ed3b
Compare
shadaj
added a commit
that referenced
this pull request
Jun 4, 2026
Places the ExternalInput source directly at the Atomic location and adds an AtomicSourceHook that signals readiness when items are pending. This allows the sim scheduler to explore both orderings: the batch for the regular input being non-empty on the first tick (same tick as atomic write) or empty (read comes in a later tick). send_atomic is synchronous — values are immediately available in the next atomic slice without requiring a separate tick or ack pattern. Closes #2380 PR: #2851
023ed3b to
fcb5065
Compare
shadaj
added a commit
that referenced
this pull request
Jun 4, 2026
Places the ExternalInput source directly at the Atomic location and adds an AtomicSourceHook that signals readiness when items are pending. This allows the sim scheduler to explore both orderings: the batch for the regular input being non-empty on the first tick (same tick as atomic write) or empty (read comes in a later tick). send_atomic is synchronous — values are immediately available in the next atomic slice without requiring a separate tick or ack pattern. Closes #2380 PR: #2851
fcb5065 to
38665cb
Compare
Places the ExternalInput source directly at the Atomic location and adds an AtomicSourceHook that signals readiness when items are pending. This allows the sim scheduler to explore both orderings: the batch for the regular input being non-empty on the first tick (same tick as atomic write) or empty (read comes in a later tick). send_atomic is synchronous — values are immediately available in the next atomic slice without requiring a separate tick or ack pattern. Closes #2380 PR: #2851
38665cb to
a804d81
Compare
a15a670 to
e70eab6
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.
Summary
Adds
Process::sim_atomic_input()which returns aSimAtomicSender<T, O, R>and aStream<T, Atomic<Process>, ...>. The sender'ssend_atomicmethod is synchronous — values are immediately available in the next atomic slice without requiring a separate tick or ack pattern.The sim scheduler now properly explores both orderings when an atomic input and a regular input are sent together.
Implementation
Source placement: The
ExternalInputnode is placed directly at theAtomiclocation (not at the top-level process with a batch into the tick).AtomicSourceHook: A new sim hook type that monitors the external input channel. When items are pending,
can_make_nontrivial_decision()returnstrue, which forces the scheduler to consider the tick as ready. On release, all pending items are emitted (no batching choice).Scheduler integration: The hook is registered in
create_external_sourcewhen the source location isAtomic. Items from the external channel are buffered at the process level and released into the tick graph via the hook.Usage
Tests
sim_atomic_input_api: verifies basic send + scheduler explores both orderings (2 instances)sim_atomic_input_same_tick: verifies the scheduler explores the same-tick scenariorequest_responsetests inhydro_stdto use the new APICloses #2380