-
Notifications
You must be signed in to change notification settings - Fork 710
introduce a freelist interface #775
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
Conversation
d34d691 to
dd2227d
Compare
dd2227d to
7e565c0
Compare
7e565c0 to
72064f9
Compare
| FreePageIds() common.Pgids | ||
|
|
||
| // PendingCount returns the number of pending pages. | ||
| PendingCount() int |
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.
this is unfortunately leaking via stats, ie in db.stats.PendingPageN = db.freelist.PendingCount()
72064f9 to
953d46a
Compare
|
rebased to the latest freelist refactoring |
18a145d to
56634cd
Compare
|
let's see how the benchmarks perform :) |
51cbf71 to
7e8d09b
Compare
a78f337 to
7f65806
Compare
30092a9 to
59c498b
Compare
internal/freelist/freelist.go
Outdated
| FreeCount() int | ||
|
|
||
| // FreePageIds returns all free pages. | ||
| FreePageIds() common.Pgids |
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.
that can be package private now, used only by ReadWriter and unit tests
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.
It seems true. We can just move it right above the pendingPageIds method.
59c498b to
fea911e
Compare
9cca4c6 to
d278e30
Compare
ahrtr
left a comment
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 removed freelist_test.go has 485 lines of code, but the sum of the array_test.go, freelist_test.go and hashmap_test.go have around 360 lines of code, where is the remaining around 120 lines of test code?
yep good catch, there were more hashmap tests at the bottom which are now back in action. Line counts are matching again? |
d9c0ee0 to
b3019ed
Compare
Yes, makes sense now. thx. One minor comment on the order of the methods in
|
3313cf5 to
c5576f1
Compare
|
done, PTAL again |
ahrtr
left a comment
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.
|
Thanks for your patience! I think the best step forward is to test the interface for starters. Then we can check what else we can refactor from there... |
|
@fuweid any comments? |
This introduces an interface for the freelist, splits it into two concrete implementations. fixes etcd-io#773 Signed-off-by: Thomas Jungblut <[email protected]>
c5576f1 to
62e81c0
Compare
|
@tjungblu I will take a look in following two days. sorry for the delay. |
fuweid
left a comment
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.
/lgtm
/approve
|
|
||
| // Copy the list of page ids from the freelist. | ||
| if len(ids) == 0 { | ||
| t.Init(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.
For array type, the original implementation just resets ids. In this patch, array type will updates t.cache as well. It might involve some memory allocation but it looks fine.
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.
yep, I found some inconsistencies also during unit testing between the default implementations init (empty vs. nil). We'll fix them along with the tests.
| NoSyncReload(pgIds common.Pgids) | ||
|
|
||
| // freePageIds returns the IDs of all free pages. | ||
| freePageIds() common.Pgids |
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.
These non-accessable methods could be considered to remove from Interface and we can add a new non-accessable interface for array type and hash type, like.
type pageIDManager interface {
freePageIds() common.Pgids
pendingPageIds() map[common.Txid]*txPending
release(txId common.Txid)
releaseRange(begin, end common.Txid)
mergeSpans(ids common.Pgids)
}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.
We can continue to refactor the interface later.
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ahrtr, fuweid, tjungblu The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
Link to #789 |
This introduces an interface for the freelist, splits it into two concrete implementations.
fixes #773