mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: change the span allocation policy to first-fit
This change modifies the treap implementation to be address-ordered instead of size-ordered, and further augments it so it may be used for allocation. It then modifies the find method to implement a first-fit allocation policy. This change to the treap implementation consequently makes it so that spans are scavenged in highest-address-first order without any additional changes to the scavenging code. Because the treap itself is now address ordered, and the scavenging code iterates over it in reverse, the highest address is now chosen instead of the largest span. This change also renames the now wrongly-named "scavengeLargest" method on mheap to just "scavengeLocked" and also fixes up logic in that method which made assumptions about size. For #30333. Change-Id: I94b6f3209211cc1bfdc8cdaea04152a232cfbbb4 Reviewed-on: https://go-review.googlesource.com/c/go/+/164101 Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
This commit is contained in:
parent
e30aa166ea
commit
40036a99a0
5 changed files with 196 additions and 131 deletions
|
|
@ -627,4 +627,5 @@ func (t *Treap) Size() int {
|
|||
|
||||
func (t *Treap) CheckInvariants() {
|
||||
t.mTreap.treap.walkTreap(checkTreapNode)
|
||||
t.mTreap.treap.validateMaxPages()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue