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

perf(buffer): Move system check to precondition #4275

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jjbayer
Copy link
Member

@jjbayer jjbayer commented Nov 21, 2024

Reduce overhead on the buffer service by checking preconditions for dequeueing without polling a future.

#skip-changelog

@@ -775,4 +756,20 @@ mod tests {
5
);
}

#[tokio::test(start_paused = true)]
async fn precondition_no_future() {
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
async fn precondition_no_future() {
async fn precondition_no_poll() {

@@ -434,7 +414,7 @@ impl Service for EnvelopeBufferService {
// On the one hand, we might want to prioritize dequeuing over enqueuing
// so we do not exceed the buffer capacity by starving the dequeue.
// on the other hand, prioritizing old messages violates the LIFO design.
Some(permit) = self.ready_to_pop(&buffer, dequeue.load(Ordering::Relaxed)) => {
Some(permit) = self.ready_to_pop(), if should_dequeue.load(Ordering::Relaxed) && self.system_ready(&buffer) => {
Copy link
Member Author

Choose a reason for hiding this comment

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

Note: with this, we should probably have a default sleep in the main loop to prevent busy looping or breaking out of the loop.

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.

1 participant