Skip to content
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

Immediate start of federates with STA offset under decentralized coordination #469

Merged
merged 2 commits into from
Jul 16, 2024

Conversation

Depetrol
Copy link
Collaborator

@Depetrol Depetrol commented Jul 15, 2024

In decentralized coordination, the behavior used to be to wait for STP_offset before starting the worker threads. With this change, the federates start immediately without waiting for STP_offset.

When the user sets to STP_offset to FOREVER, it enables dataflow-like behavior.

Summary by CodeRabbit

  • Bug Fixes
    • Improved synchronization during startup by handling start time offsets, reducing spurious violations in federated decentralized execution.

@Depetrol Depetrol added the enhancement Enhancement of existing feature label Jul 15, 2024
Copy link
Contributor

coderabbitai bot commented Jul 15, 2024

Walkthrough

The recent changes in reactor_threaded.c address the handling of start time offsets in federated decentralized execution. By managing these time offsets more effectively, the code aims to prevent spurious violations and ensure proper synchronization during the startup phase. This enhancement is crucial for maintaining robust and reliable execution in federated systems.

Changes

Files Change Summary
core/threaded/reactor_threaded.c Adjusted the handling of start time offsets to prevent spurious violations and improve synchronization during startup.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (1)
core/threaded/reactor_threaded.c (1)

Line range hint 209-245: Handling of STA offset is robust, but could use clearer documentation.

The function wait_until manages the STA offset well by adjusting the logical time to include it, which is crucial for correct synchronization in federated decentralized systems. However, the comments could be enhanced to clarify the role and impact of the STA offset in preventing overflows and ensuring timely starts.

// Apply the STA to the logical time
// Prevent an overflow
-  // If wait_time is not forever
+  // Adjust wait time to include STA offset, ensuring it does not exceed FOREVER
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4abce72 and 15c07f9.

Files selected for processing (1)
  • core/threaded/reactor_threaded.c (2 hunks)
Additional comments not posted (2)
core/threaded/reactor_threaded.c (2)

Line range hint 30-58: Well-implemented tag barrier logic.

The function _lf_increment_tag_barrier_locked correctly manages the tag barriers, ensuring logical time synchronization in federated environments. The checks and adjustments for future_tag are appropriately handled.


Line range hint 97-124: Effective management of the FOREVER tag in barriers.

The function _lf_wait_on_tag_barrier properly handles cases where proposed_tag.time == FOREVER, preventing unnecessary waits and aligning with the PR's objective of immediate thread start-up in federated environments when STP_offset is set to FOREVER.

Copy link
Contributor

@cmnrd cmnrd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was the waiting done so far and why is it safe to simply remove it?

@edwardalee
Copy link
Contributor

Why was the waiting done so far and why is it safe to simply remove it?

An STA_offset of T (which should be called STA, safe to advance) means that at physical time t+T the federate can assume it has received all messages with tags less than t. If t is the start time, the federate already knows it has received all messages with tags less than t (because there are no messages with tags less than t). Hence, at the start time, there is no need to wait.

This change enables very simple use of decentralized coordination for a subset of LF programs that do not deal with time, but rather just deal with data flow.

Copy link
Contributor

@edwardalee edwardalee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks right to me.

@Depetrol Depetrol added this pull request to the merge queue Jul 16, 2024
github-merge-queue bot pushed a commit that referenced this pull request Jul 16, 2024
Allow dataflow-like behavior when setting STP_offset to infinity
@lhstrh lhstrh changed the title Allow dataflow-like behavior when setting STP_offset to infinity Immediate start of federates with STA offset under decentralized coordination Jul 16, 2024
@lhstrh
Copy link
Member

lhstrh commented Jul 16, 2024

I adjusted the title of the PR to match what I think this does, but I'm not sure I got it right...

@lhstrh
Copy link
Member

lhstrh commented Jul 16, 2024

@edwardalee please also update the description (it doesn't seem like this PR enables data-flow-like behavior as it only affects the behavior at startup?)

@Depetrol Depetrol removed this pull request from the merge queue due to a manual request Jul 16, 2024
@Depetrol Depetrol added this pull request to the merge queue Jul 16, 2024
Merged via the queue into main with commit 4cdc2f9 Jul 16, 2024
48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement of existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants