-
Notifications
You must be signed in to change notification settings - Fork 0
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
client/core: OrderBook clarify cache usage #5
base: master
Are you sure you want to change the base?
Conversation
// Must be done with ob.noteQueueMtx locked, otherwise some notes might be sent | ||
// to ob.noteQueue after we are done processing it. Such notes won't be processed | ||
// until next processCachedNotes call when they'll be irrelevant and more | ||
// importantly it means we won't apply them on top of server snapshot they were | ||
// meant to be applied to. | ||
ob.setSynced(true) | ||
|
||
return nil | ||
} |
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.
Since cache isn't used (based on what I observed in the logs, and my current understanding of the relevant code), this fix is non-effectual really if #1 gets merged.
Moreover, we might not even need caching here really, so in the next PR I'll consider getting rid of it. But if OrderBook.noteQueue
cache stays this is very much a necessary fix for it.
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.
Thoughts on whether or not we need (to fix or reimplement) that caching there:
- there is a 1024+128 buffer in
comms
package to hold incoming WS messages, it seems like enough of a buffer to hold those server update notifications off for a while (and probably we can easily increase these number if necessary, probably want to add someTracef
logs to monitor saturation in case it gets dangerously high during network delays and whatnot; on master I'm getting single-digits numbers fornextJob
size during normal operation, don't imagine how this could get significantly worse unless we have ~x100 activity increase on DEX maybe) - ALL server notifications will be waiting behind one that got blocked (waiting on
dc.booksMtx
for example), it doesn't seems to be a big deal here cause we don't have to handle them in real time
ad9d264
to
e298e04
Compare
f9959eb
to
a66bbae
Compare
Working on #1 I got a sense some
OrderBook
stuff looks out of date. For example it hasnoteQueue
that never really gets used because update notifications can't make it there pastdc.booksMtx
when it's locked forReset
, and whendc.booksMtx
is released there is no need for caching anymore (at least it should work like this with changes from #1; on master it might be used because of insufficient locking as per #1, and it's not fully atomic with respect tosynched
as is fixed in this PR).This PR mostly tries to better document those implicit assumptions we currently make about
OrderBook
, and is a prerequisite ground work for the hopefully final step (which is to reduce the reliance ondc.booksMtx
, effectively parallelising subscribe functionality by Market) meant to finish chain of changes #1 kicked off.