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

Fix Redispatch method of Redispatcher #6668

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

Conversation

Shaddoll
Copy link
Member

What changed?

  • Update redispatcher to use 1 priority queue to store tasks
  • Fix Redispatch method to redispatch the given number of tasks immediately

Why?

  • Redispatcher redispatches tasks based on redispatch time, it's unnecessary to store tasks in separate priority queues. Getting rid of the priority queue map can reduce the complexity of the codebase.
  • The original implementation of Redispatch method doesn't redispatch the target number of tasks immediately, and the target size is not used as expected.

How did you test it?
unit tests

Potential risks
Redispatcher might be broken

Release notes

Documentation Changes

}
}
}

func (r *redispatcherImpl) redispatchTasks(notification redispatchNotification) {
func (r *redispatcherImpl) redispatchTasks() {
Copy link
Member

Choose a reason for hiding this comment

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

Can the Redispatch() function call this redispatchTasks()? The logic looks similar except:

  • Redispatch() caps it to targetSize
  • redispatchTasks() updates item.redispatchTime
  • redispatchTasks() updates timer gate

Are these differences intentional? Even if some of them are intentional, we can make those configurable and still have a single task redispatch function doing all this to avoid redundancy

Copy link
Member

Choose a reason for hiding this comment

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

+1

if item.redispatchTime.After(now) {
break
}
submitted, err := r.taskProcessor.TrySubmit(item.task)
Copy link
Member

Choose a reason for hiding this comment

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

so, I guess the plan for those tasks that couldn't be submitted is to rely on the redispatch timer?

The core semantic change - as I understand it - is that you're making a function that may fail to redispatch the tasks via the async loop, but then puts it in a in-memory queue for redispatch next tick?

that seems reasonble, but just making sure I'm following.

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.

3 participants