Skip to content

Commit

Permalink
runtime: change the span allocation policy to first-fit
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
mknyszek committed May 1, 2019
1 parent e30aa16 commit 40036a9
Show file tree
Hide file tree
Showing 5 changed files with 196 additions and 131 deletions.
1 change: 1 addition & 0 deletions src/runtime/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -627,4 +627,5 @@ func (t *Treap) Size() int {

func (t *Treap) CheckInvariants() {
t.mTreap.treap.walkTreap(checkTreapNode)
t.mTreap.treap.validateMaxPages()
}
Loading

0 comments on commit 40036a9

Please sign in to comment.