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

about queue len #909

Open
yangeagle opened this issue Jun 9, 2019 · 5 comments
Open

about queue len #909

yangeagle opened this issue Jun 9, 2019 · 5 comments

Comments

@yangeagle
Copy link
Contributor

file:go/discovery/queue.go

code:

// QueueLen returns the length of the queue (channel size + queued size)
func (q *Queue) QueueLen() int {
  q.Lock()
  defer q.Unlock()

  return len(q.queue) + len(q.queuedKeys)
}

I am confused about the calculation of the queue length.

q.queue and q.queuedKeys are the same.

Is there double counting here?

Thank you!

@MOON-CLJ

@shlomi-noach
Copy link
Collaborator

cc @sjmudd who authored this code.

@MOON-CLJ
Copy link
Contributor

@shlomi-noach @sjmudd any update? It obviously feels like a bug.

@sjmudd
Copy link
Collaborator

sjmudd commented Jun 24, 2020

This is code that's been around for a long time but after looking again I think I would agree. I am tempted to modify this however to reflect the complete length of the discovery queue. That is both the pending (queued) plus being processed (consumed) entries as that is the total size.

e.g.

return len(q.queuedKeys) + len(q.consumedKeys)

So prior to making any changes I wonder what you were looking for?

@MOON-CLJ
Copy link
Contributor

@sjmudd separation's good.

@sjmudd
Copy link
Collaborator

sjmudd commented Jun 24, 2020

@MOON-CLJ: thanks for catching this. I've made a PR which I think should address the issue.

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

No branches or pull requests

4 participants