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

We should only consider the connection with rdyCount ==0. For the active connection, RDY should not be updated again. #268

Closed
neezhe opened this issue Sep 23, 2019 · 2 comments
Labels

Comments

@neezhe
Copy link

neezhe commented Sep 23, 2019

how about this ?

change

for len(possibleConns) > 0 && availableMaxInFlight > 0 {
		availableMaxInFlight--
		r.rngMtx.Lock()
		i := r.rng.Int() % len(possibleConns)
		r.rngMtx.Unlock()
		c := possibleConns[i]
		// delete
		possibleConns = append(possibleConns[:i], possibleConns[i+1:]...)
		r.log(LogLevelDebug, "(%s) redistributing RDY", c.String())
		r.updateRDY(c, 1) 
}

into

for len(possibleConns) > 0 && availableMaxInFlight > 0 {
		availableMaxInFlight--
		r.rngMtx.Lock()
		i := r.rng.Int() % len(possibleConns)
		r.rngMtx.Unlock()
		c := possibleConns[i]
		// delete
		possibleConns = append(possibleConns[:i], possibleConns[i+1:]...)
		r.log(LogLevelDebug, "(%s) redistributing RDY", c.String())
		if c.rdyCount > 0 {
			continue
		}
		r.updateRDY(c, 1) 
}
@ploxiln
Copy link
Member

ploxiln commented Sep 25, 2019

If you would like to propose a change, it is much easier to read it in context if you open a pull request.

This logic is the trickiest in nsq consumer libraries, so I do not know, without digging in quite a bit, whether this is appropriate or not. So it will be a while until you get a proper reply.

@mreiferson
Copy link
Member

The change looks like it is specifically looking to "optimize" for a case where a connection already has a non-zero rdyCount. But for this loop, that doesn't make sense, if anything you'd want a connection where rdyCount == 0.

Thanks for the suggestion, but I'm going to close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants