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

Merge common impls of submit_one_event into submit_event_chain #551

Merged
merged 3 commits into from
Apr 25, 2024

Conversation

vmingchen
Copy link
Collaborator

@vmingchen vmingchen commented Apr 18, 2022

What does this PR do?

Address #548

Motivation

Refactor code to reduce code duplication.

Related issues

A list of issues either fixed, containing architectural discussions, otherwise relevant
for this Pull Request.

Additional Notes

Pure refactoring; no behavior change.

Checklist

[] I have added unit tests to the code I am submitting
[] My unit tests cover both failure and success scenarios
[] If applicable, I have discussed my architecture

Comment on lines 919 to 928
fn submit_one_event(&mut self, queue: &mut VecDeque<UringDescriptor>) -> Option<bool> {
let source_map = &mut *self.source_map.borrow_mut();
let now = Instant::now();

while let Some(chain) = peek_one_chain(queue, self.size) {
return if let Some(sqes) = self.ring.sq().prepare_sqes(chain.len() as u32) {
let ops = extract_one_chain(source_map, queue, chain, now);
if ops.is_empty() {
// all the sources in the ring were cancelled
continue;
}

for (op, mut sqe) in ops.into_iter().zip(sqes.into_iter()) {
let allocator = self.allocator.clone();
fill_sqe(
&mut sqe,
&op,
move |size| allocator.new_buffer(size),
source_map,
);
}
Some(true)
} else {
None
};
}
Some(false)
submit_event_chain(
&mut *self.source_map.borrow_mut(),
&mut self.ring,
self.allocator.clone(),
queue,
self.size,
)
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Looks like we could go one step further and remove submit_one_event from the trait and avoid the indirection of the vtable

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

How do we do that? submit_one_event is used inside submit_one_event which is used in the default trait implementation where we cannot refer concrete fields like self.ring.

@bryandmc
Copy link
Collaborator

Hey @vmingchen -- In the future, can you either fill out the pull request template or at least delete it (if it's not relevant, though that's also debatable..)? It was surprising to come read this and realize it was just the template unchanged.

@vmingchen
Copy link
Collaborator Author

Hey @vmingchen -- In the future, can you either fill out the pull request template or at least delete it (if it's not relevant, though that's also debatable..)? It was surprising to come read this and realize it was just the template unchanged.

Sorry about that. Edited the PR description.

@glommer
Copy link
Collaborator

glommer commented Jul 18, 2022

anything missing for merging this ?

@vlovich
Copy link
Contributor

vlovich commented Apr 24, 2024

@glommer this seems OK to merge.

@glommer glommer merged commit 937b610 into DataDog:master Apr 25, 2024
4 of 5 checks passed
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

5 participants