Skip to content

Commit 40036a9

Browse files
committed
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Austin Clements <[email protected]>
1 parent e30aa16 commit 40036a9

File tree

5 files changed

+196
-131
lines changed

5 files changed

+196
-131
lines changed

src/runtime/export_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,4 +627,5 @@ func (t *Treap) Size() int {
627627

628628
func (t *Treap) CheckInvariants() {
629629
t.mTreap.treap.walkTreap(checkTreapNode)
630+
t.mTreap.treap.validateMaxPages()
630631
}

0 commit comments

Comments
 (0)