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

Implement Async IO Select Hostcalls #188

Merged
merged 5 commits into from Nov 16, 2022
Merged

Conversation

mgattozzi
Copy link
Contributor

@mgattozzi mgattozzi commented Oct 6, 2022

This commit adds the fastly_async_io hostcalls select and is_ready
to Viceroy. Up to this point we only would do select for things like
PendingRequest. Now we abstract over an AsyncItem which could be a
PendingRequest, StreamingBody, or Body and you can call select
over any of these async io operations. Most of this code is to
accomodate these changes while maintaining the behavior of select for
PendingRequest utilizing these new calls and creating the AsyncItem
enum to hold all of these differing types in the same async_item map.

We also add an integration test similar to the C@E platform's to make
sure that we implement the behavior correctly. With this we can be
confident that select works the way we intend it too! As a bonus side
effect of these changes we also add async support for hosts in our
testing code in Viceroy which gives us some more flexibility in what we
can accomplish or use!

@JakeChampion
Copy link
Contributor

I've used this to run the tests for the JS SDK which use the async_io module and everything looks to be working correctly 🙌 -- fastly/js-compute-runtime#293

@mgattozzi mgattozzi marked this pull request as ready for review November 4, 2022 16:52
@mgattozzi
Copy link
Contributor Author

I finally fixed up the PR to work for all items again and the tests should be passing and with it working on the JS SDK side I'm reasonably confident the code works as intended.

@mgattozzi mgattozzi requested review from a team and awortman-fastly and removed request for a team November 4, 2022 16:53
@aturon aturon requested review from aturon and removed request for awortman-fastly November 4, 2022 18:33
@@ -0,0 +1 @@

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like an empty file, should be removed.

.await? as u32;

let item =
self.take_async_item(pending_req_handles.get(done_index).unwrap().read()?.into())?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
self.take_async_item(pending_req_handles.get(done_index).unwrap().read()?.into())?;
self.take_async_item(pending_req_handles[done_index].read()?.into())?;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought this would work but turns out pending_req_handles is a &GuestPtr<[PendingReqHandle]> and we can't index directly. I tried out some other things but they were either longer or even more complex for little gain and so I think we need to just keep this unfortunately @aturon

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah ok, no worries!

Copy link
Contributor

@aturon aturon left a comment

Choose a reason for hiding this comment

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

Looks great!

However, there aren't tests of the new async_io functionality. We should be able to re-use the C@E tests directly here, so it should be easy to add. While the existing tests give coverage of select over pending requests, I think it's important to have fuller of the new API.

@mgattozzi
Copy link
Contributor Author

Update for todays work: I'm still working on it. The C@E tests have some functionality around handling when to accept requests as well as synchronizing that's a bit hard to replicate. I've got something started, but it's slow going for now. Hopefully I'll have something by tomorrow as I don't expect to get it done in the next hour before I clock out today.

@mgattozzi
Copy link
Contributor Author

Figured it all out! Squashed all my WIP commits to make the history cleaner!

@mgattozzi
Copy link
Contributor Author

And updated the code to remove uneeded printlns and make sure we reinsert items using a Drop guard

aturon
aturon previously approved these changes Nov 15, 2022
Copy link
Contributor

@aturon aturon left a comment

Choose a reason for hiding this comment

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

AWESOME WORK! 🎉

Thank you for seeing this through, it'll be great to get it merged.

@aturon
Copy link
Contributor

aturon commented Nov 15, 2022

AWESOME WORK! 🎉

Thank you for seeing this through, it'll be great to get it merged.

mgattozzi and others added 4 commits November 16, 2022 15:47
This commit adds the fastly_async_io hostcalls `select` and `is_ready`
to Viceroy. Up to this point we only would do `select` for things like
`PendingRequest`. Now we abstract over an `AsyncItem` which could be a
`PendingRequest`, `StreamingBody`, or `Body` and you can call `select`
over any of these async io operations. Most of this code is to
accomodate these changes while maintaining the behavior of `select` for
`PendingRequest` utilizing these new calls and creating the `AsyncItem`
enum to hold all of these differing types in the same `async_item` map.

We also add an integration test similar to the C@E platform's to make
sure that we implement the behavior correctly. With this we can be
confident that select works the way we intend it too! As a bonus side
effect of these changes we also add async support for hosts in our
testing code in Viceroy which gives us some more flexibility in what we
can accomplish or use!
This change refines the comment on why we've cfged out a test on windows with a link to the issue tracker for those curious as to why this is the case.

Co-authored-by: Aaron Turon <aturon@fastly.com>
Copy link
Contributor

@aturon aturon left a comment

Choose a reason for hiding this comment

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

🎉 💯

@mgattozzi mgattozzi merged commit dc9e8d9 into main Nov 16, 2022
@mgattozzi mgattozzi deleted the mgattozzi/async-hostcall branch November 16, 2022 22:39
@mgattozzi mgattozzi mentioned this pull request Nov 17, 2022
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.

None yet

3 participants