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

Access wrapper duplicate type #273

Merged
merged 4 commits into from
Aug 1, 2023
Merged

Conversation

mbaker3
Copy link
Member

@mbaker3 mbaker3 commented Jul 21, 2023

Add the ability to require multiple data stream writers of the same type on a task driver job.
The API proposed here provides a solution until a proper solution can be devised during #224

This solution takes advantage of the fact that all data stream pending collections share the same access handle this means that, from a job dependency perspective, getting write access to a stream instance also provides write access to all other stream instances of the same type (shared/wide writing).

What is the current behaviour?

Developers are unable to include writers to multiple data streams of the same type in their job. This most commonly comes up when there are cancel requests to multiple task drivers that a job may want to make during execution.

What is the new behaviour?

Developers can now include multiple data streams of the same type in their job.

  • Require the two stream instances in your job configuration as you normally would
  • When calling jobData.Fulfill() provide the specific stream instance after the out parameter.

How it works

On the first write request we create an access wrapper as we normally would.
For all other write requests after the first one we keep the same access wrapper and track the specific instance request for safety checks. (only if ANVIL_DEBUG_SAFETY is enabled)

During fulfill we use the provided stream instance to generate a writer and make a safety check to ensure that instance was required during job config.

Edge Case Behaviour (WhenANVIL_DEBUG_SAFETY is enabled)

  • Including the explicit stream in Fulfill() when only one instance of the stream type has been requested emits a warning. The default Fulfill() without the explicit stream should be preferred when possible.
  • Forgetting to include the explicit stream when multiple instances have been requested will throw an error. There is no default resolution when multiple instances have been required.

What issues does this resolve?

Resolve: #245

What PRs does this depend on?

  • None

Does this introduce a breaking change?

  • Yes
  • No

Add the ability to require multiple cancel streams in a single job. Requiring is done as you would expect, just target the different streams on the JobConfig. Fulfilling the writer/instance is done by passing the stream instance into the `Fulfill` method.

The access wrappers now represent access to the cancel type not a specific cancel stream instance. This works because all of the cancel streams share the same SharedWrite Pending collection so getting write access for one stream grants write access for all. The instance passed through `Fulfill` will get safety checked in the access wrapper and delivered back to be used for writer creation.

Behaviour:
 - One cancel request stream required: `jobData.Fulfill` behaves as normal, no explicit instance required.
 - N cancel request stream required: `jobData.Fulfill` must be provided the instance for each stream to fulfill otherwise the safety system will throw an exception.

Note: This is a workaround implementation. #224 will make this cleaner.

This approach can be applied to all write wide (shard write) types. Support will be added in an upcoming commit.
@mbaker3 mbaker3 requested a review from jkeon July 21, 2023 20:31
@jkeon jkeon self-assigned this Jul 28, 2023
Copy link
Member

@jkeon jkeon left a comment

Choose a reason for hiding this comment

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

Looks good, just some minor comments

@mbaker3
Copy link
Member Author

mbaker3 commented Aug 1, 2023

All comments addressed. Ready for re-review

@mbaker3 mbaker3 requested a review from jkeon August 1, 2023 14:05
Copy link
Member

@jkeon jkeon left a comment

Choose a reason for hiding this comment

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

Looks good!

@mbaker3 mbaker3 merged commit af8e951 into main Aug 1, 2023
@mbaker3 mbaker3 deleted the access-wrapper-duplicate-type branch August 1, 2023 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multiple Data Streams of the same type in the same job
2 participants