mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-09 13:33:39 +00:00
runtime (gc_blocks.go): use best-fit allocation
The allocator originally just looped through the blocks until it found a sufficiently-long range. This is simple, but it fragments very easily and can degrade to a full heap scan for long requests. Instead, we now maintain a sorted nested list of free ranges by size. The allocator will select the shortest sufficient-length range, generally reducing fragmentation. This data structure can find a range in time directly proportional to the requested length.
This commit is contained in:
@@ -42,9 +42,9 @@ func TestBinarySize(t *testing.T) {
|
||||
// This is a small number of very diverse targets that we want to test.
|
||||
tests := []sizeTest{
|
||||
// microcontrollers
|
||||
{"hifive1b", "examples/echo", 3568, 280, 0, 2268},
|
||||
{"microbit", "examples/serial", 2630, 342, 8, 2272},
|
||||
{"wioterminal", "examples/pininterrupt", 7175, 1493, 116, 6912},
|
||||
{"hifive1b", "examples/echo", 3808, 280, 0, 2268},
|
||||
{"microbit", "examples/serial", 2790, 342, 8, 2272},
|
||||
{"wioterminal", "examples/pininterrupt", 7327, 1493, 116, 6912},
|
||||
|
||||
// TODO: also check wasm. Right now this is difficult, because
|
||||
// wasm binaries are run through wasm-opt and therefore the
|
||||
|
||||
Reference in New Issue
Block a user