-
Notifications
You must be signed in to change notification settings - Fork 10
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
When priority is equal, use FIFO #16
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(one small change but the logic looks good)
peertracker/peertracker.go
Outdated
@@ -59,14 +60,15 @@ type PeerTracker struct { | |||
} | |||
|
|||
// New creates a new PeerTracker | |||
func New(target peer.ID, taskMerger TaskMerger, maxActiveWorkPerPeer int) *PeerTracker { | |||
func New(target peer.ID, taskMerger TaskMerger, maxActiveWorkPerPeer int, clock clock.Clock) *PeerTracker { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that this clock is just for testing... can we use a private global one? Otherwise, it becomes a part of the API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea fair I think.
peertracker/peertracker_test.go
Outdated
defer func() { | ||
clockInstance = oldClock | ||
}() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: use t.Cleanup
to make sure this always runs.
Goals
I had been assuming in a peer task queue, if I queue tasks for a given peer with equal priority over time, that they will dequeue in FIFO order. As it turns out, this is not the case. This makes me super concerned -- we use this in Graphsync and it's a major bummer if requests don't queue in the order received for a given peer. Not sure the Bitswap implications but I can't imagine they are great.
Implementation
For Discussion
Alternative idea would be to allow custom specification of priority order.