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

rt: add new api for oneshot op submission and creation #244

Merged
merged 8 commits into from
Feb 21, 2023

Conversation

Noah-Kennedy
Copy link
Contributor

This change adds a new API for creating and submitting oneshot operations. This new API is intended to obsolete the existing system, however transferring over has been left out of this PR to keep the change small.

It is intended that a similar API for multishot operations be landed in a followup PR as well. This was also left out of this PR to keep the change small.

This refactoring paves the way for further work on SQE linking, multishot operations, and other improvements and additions.

The goal of this change is to allow us to split up the oneshot and multishot logic to allow for a cleaner and more extensible system, allow for user-provided operations, and allow users to control when and how their ops get submitted to the squeue.

This change adds a new API for creating and submitting oneshot operations. This new API is intended to obsolete the existing system, however transferring over has been left out of this PR to keep the change small.

It is intended that a similar API for multishot operations be landed in a followup PR as well. This was also left out of this PR to keep the change small.

This refactoring paves the way for further work on SQE linking, multishot operations, and other improvements and additions.

The goal of this change is to allow us to split up the oneshot and multishot logic to allow for a cleaner and more extensible system, allow for user-provided operations, and allow users to control when and how their ops get submitted to the squeue.
@@ -54,7 +55,7 @@ impl Socket {

async fn write_all_slice<T: IoBuf>(&self, mut buf: Slice<T>) -> crate::BufResult<(), T> {
while buf.bytes_init() != 0 {
let res = self.write(buf).await;
let res = self.write(buf).submit().await;
Copy link
Collaborator

Choose a reason for hiding this comment

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

That's interesting.

Copy link
Collaborator

@FrankReh FrankReh left a comment

Choose a reason for hiding this comment

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

Nice. Very nice how you kept the old mechanism working while introducing the new one next to it.

pub struct UnsubmittedOneshot<D: 'static, T: OneshotOutputTransform<StoredData = D>> {
stable_data: D,
post_op: T,
sqe: squeue::Entry,
Copy link
Collaborator

Choose a reason for hiding this comment

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

If this is made pub, does that let callers then add bits to the sqe as they see fit? Or maybe a public method that gives a mutable reference?

self.submit_with_driver(&handle)
}

fn submit_with_driver(self, driver: &driver::Handle) -> InFlightOneshot<D, T> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh this is cool.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This helps set the stage for adding public handles.

post_op: self.post_op,
};

InFlightOneshot { inner: Some(inner) }
Copy link
Collaborator

Choose a reason for hiding this comment

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

So is this. A specific type representing the kind of inflight operation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My thinking was that these could have cancellation semantics added to them in the future as well as being awaitable as they currently are.

}
}

/// Submit an operation to the driver for batched entry to the kernel.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe add that a Future is being returned by this function?

src/runtime/driver/mod.rs Show resolved Hide resolved
src/runtime/driver/mod.rs Show resolved Hide resolved
}
}

impl<T: BoundedBuf> UnsubmittedWrite<T> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would prefer to see this impl that starts at line 38 which is responsible for the struct being init and the squeue Entry being created appearing right after the struct, at line 18. That would make this file better mirror the layout it used to have.

@@ -41,7 +41,7 @@ fn main() {
break;
}

let (res, b) = socket.write(b).await;
let (res, b) = socket.write(b).submit().await;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would InfoFuture have avoided these changes being required?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Generally yes

@Noah-Kennedy Noah-Kennedy merged commit a021be7 into master Feb 21, 2023
@Noah-Kennedy Noah-Kennedy deleted the noah/ops-refactor branch February 21, 2023 20:29
@ollie-etl
Copy link
Contributor

@Noah-Kennedy I feel somewhat put out having not begin requested for input here, given the history (especially #165, #171, #120, #218).

In addition, this PR appears to have had a lifespan of 8 hours, with minimal discussion, and all other Pr's on this subject have met a (deserved) wall of "let us discuss". It would appear there is a very distinct weighting of opinions here, which I think is a shame. Its certainly discouraging for future involvement.

@FrankReh
Copy link
Collaborator

FrankReh commented Feb 22, 2023

@ollie-etl It is understandable you feel that way but it is just a difference of working for Noah at the moment. Your input is very valuable. We hadn't heard from you in a while and this is just one of several PRs Noah wants to get in and he's very amenable to changing things quickly as we see fit. What's going in is by no means the final. It's just a way for him and I to make progress while we work on things in parallel for a few days. Please don't feel put out.

@FrankReh
Copy link
Collaborator

@ollie-etl I'll add for myself, another reason I often push back harder on others than on Noah in cases like this is I feel bad if I let someone's PR go through and then Noah or I go about changing it in a few days anyway. It muddies the git blame output and doesn't give full credit to the person who did all the work going in.

@FrankReh
Copy link
Collaborator

FrankReh commented Feb 22, 2023

@ollie-etl Also, hopefully you noticed I didn't wait for Noah to address my questions with the first PR.

And coincidentally, I'm getting my old multi-shot work from before your submissions to line with up at least your recent submissions, just so it compiles again and has a test case working. Knowing I will have to change it again when Noah has the multi version of the new API ready.

@FrankReh
Copy link
Collaborator

@ollie-etl Not getting an official review request just means the next step for us isn't gated by a third party. The GitHub Notifications page shows anyone watching this when things are being proposed.

When I haven't totally agreed with you or others, I have meant to step out of the way and let @Noah-Kennedy form the second opinion for approval. In a project like this; it's just not possible to wait for three or more confirmations, there are too many ways of getting something good done. That doesn't mean three or more reviews aren't welcome. Multiple reviews are very welcome. There is a lot to learn from each other - obviously.

@ollie-etl
Copy link
Contributor

@FrankReh I get notification, but 8 hours is quite a turn around time.

@FrankReh
Copy link
Collaborator

FrankReh commented Feb 22, 2023

@FrankReh I get notification, but 8 hours is quite a turn around time.

Yes. But I would have made it even shorter if I had had the energy when the PR was first put in.

I realize, probably Noah does too, that later PRs are harder to fully comment on because the page doesn't show all the diffs. We'll have to work around that somehow. We can't let GitHub's javascript, as great as it is, totally dictate things for us.

I suspect it's not too late to still make comments on this PR that Noah and I will see.

@FrankReh
Copy link
Collaborator

@ollie-etl One more thing. All that being said. Is there a double standard? Well yes. Noah is the tokio core team member. Ultimately things go the way he wants. If you and I don't like it, there are other options. But you have to admit, he is one of the most welcoming people on the tokio team and when he has time, he is very thoughtful in his responses. So he's not a benevolent dictator on the project, but he could be if he wanted to be. The project is only here because he kept it alive for well over a year by himself.

@ollie-etl
Copy link
Contributor

@FrankReh

  • We're broadly in agreement that this change is a good thing ™️

  • Pull requests for things which are useful to me have languished for months, with endless requests for discussion and changes, which I've mostly accommodated, albeit with gritted teeth at times. I cannot argue that process hasn't made the code better / introduced things which I hadn't considered.

  • This is a PR into an area with known existing discussion. There is not even a mention of prior art or why this approach is favored in the PR or in the feedback.

  • 8 hours for a new feature probably isn't enough time, for a project with contributors in multiple timezones. Bug fixes are obviously somewhat different. I have little interest is also monitoring chat forums, in addition to github notifications.

  • The question now, which I'm going to have to consider very hard for the next week or so is: given its very apparent the merit of a feature is weighted by contributor, and the significant time it takes to get Pr's into a state where they can be merged here (for me), would I just be better off forking / reevaluating one of the alternatives / starting afresh / or just accepting the significant time required to contribute features I see as required to this project? 🤷

@FrankReh
Copy link
Collaborator

@ollie-etl That's very understandable from your side. I don't begrudge you that if you have a better option you should take it - especially because you've said you're doing this for your work and your company is paying you to make wise choices - but I hope you don't come to that decision. And I agree you've had some PRs that take a long time. And anything that had an endless discussion in it was because I was on the other end, I know that - if Noah had ever thought I was making too fine a point on something, he would have chimed in (was my feeling). In my own defense, I think if I wasn't at that end, you might not have heard anything for a while.

Again, ironically, in between this thread, I am literally copying, modifying your excellent work on the MultiCQEFuture to get a MultiCQEStream working. Knowing it is better than what I had cobbled together back in Sept and also knowing when it's done, it will live in one or two branches just long enough to then go through another change.

You can also take your time to decide what to do. If you care to review things in the meantime anyway, that would be great.

Stepping back even further for a moment. This is a very hard open source project. It marries Linux io_uring with Rust and async Rust and tokio async Rust - which also makes a very interesting intersection to be at (and why I'm here, even without a job at the moment). There are a ton of ways to get things done in Rust and async Rust. I look at hyper and there is a single maintainer and they move fast and get a lot of feedback from users but they don't wait for all users to agree. And axum which I think has essentially two maintainers where there are lots of PRs submitted by others that can't all be accepted.

I am not trying to have the last word. Your last comment stood very well on it's own. You would be missed if you leave.

@Noah-Kennedy Noah-Kennedy restored the noah/ops-refactor branch July 14, 2023 19:57
@Noah-Kennedy Noah-Kennedy deleted the noah/ops-refactor branch July 14, 2023 20:01
@Noah-Kennedy Noah-Kennedy restored the noah/ops-refactor branch July 14, 2023 20:02
@Noah-Kennedy Noah-Kennedy deleted the noah/ops-refactor branch July 14, 2023 20:02
@ileixe
Copy link

ileixe commented Jan 22, 2024

Hi guys and @Noah-Kennedy.

Is there any following work or further discussion to introduce link ops here based on this API? (I tried to find but nothing found on my side.)

If not, we're willing to continue follow-ups for link ops on our own and want to hear what were previous design choices, idea and gaps in here.

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.

4 participants