-
Notifications
You must be signed in to change notification settings - Fork 340
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
fix(reserve): evict just enough chunks to reach the capacity #4549
Conversation
@@ -335,6 +360,14 @@ func (r *Reserve) EvictBatchBin( | |||
return 0, err | |||
} | |||
|
|||
// evict oldest chunks first | |||
sort.Slice(evicted, func(i, j int) bool { | |||
return evicted[i].BinID < evicted[j].BinID |
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.
Color me not fully grokking this, but how is sorting by BinID getting us the "oldest chunks first" as the comment states?
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.
binID is an unique, incremented value that is assigned to each chunk in the reserve. So by removing the chunks with the lowest binID, we can at least bring some order (and not just randomly) as to which chunks should be removed first.
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.
So binID has nothing to do with the pullsync bins, nor anything else within bee that is called bin? And since it is unique, I would gather that each "bin" contains but a single chunk? Bizarre.
One of my personal software development mantras is "Naming can make or break a project".
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.
the reserve has "bins", which correspond to the proximity orders of the chunks (bin 0 = po 0, etc). so a "binID" is the unique ID of a chunk in the bin.
pullsync gets chunks from a peer using the peer's binIDs (so called bin intervals) for each bin/po.
32ec942
to
657f7ab
Compare
Checklist
closes #4538
Description
Open API Spec Version Changes (if applicable)
Motivation and Context (Optional)
Related Issue (Optional)
Screenshots (if appropriate):