-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
feat(bitswap.decision.Engine) use PriorityQueue for Engine.Outbox #568
Conversation
I was planning a refactor in bitswap that would hold a queue for each partner, and then hold a priority queue of the partners to decide who we service next. The idea behind it is that we need to try and avoid 'slow' peers holding up the entire system. Thats not to say that this interferes with that in any way, just letting you know my plans. |
RFCR @jbenet @whyrusleeping |
e.peerRequestQueue.Push(entry.Entry, p) | ||
newWorkExists = true |
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.
is there a strong reason to order these? if so maybe comment it? at first glance i wouldn't know and maybe screw up
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.
There isn't. I switched the order because I mistakenly believed that assigning to the variable would magically signal to the other goroutine immediately. In the moment, I had forgotten how to write software.
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.
❤️ 👍
@briantigerchow RFM (though see comment above) |
6d5891b
to
54bd592
Compare
License: MIT Signed-off-by: Brian Tiger Chow <brian@perfmode.com> Conflicts: exchange/bitswap/decision/taskqueue.go
License: MIT Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
refactor: peerRequestQueue it's a mistake to make one queue to fit all. Go's lack of algebraic types turns a generalized queue into a monstrosity of type checking/casting. Better to have individual queues for individual purposes. Conflicts: exchange/bitswap/decision/bench_test.go exchange/bitswap/decision/tasks/task_queue.go fix(bitswap.decision.PRQ): if peers match, always return result of pri comparison fix(bitswap.decision.Engine): push to the queue before notifying TOCTOU bug 1. client notifies 2. worker checks (finds nil) 3. worker sleeps 3. client pushes (worker missed the update) test(PQ): improve documentation and add test test(bitswap.decision.Engine): handling received messages License: MIT Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
54bd592
to
76bea9b
Compare
Since RFM, Merging. |
feat(bitswap.decision.Engine) use PriorityQueue for Engine.Outbox
This PR makes bitswap's decision engine more intelligent. Now, incoming block requests are pushed into a priority queue and sorted using a pluggable comparator.
The default comparator (provisionally-titled V1) is defined as follows:
The engine interface remains the same:
It's built ontop of a generic
pq
that could probably be used elsewhere: