feat: dynamically grow fiber call frame array instead of fixed MAX_CALL_FRAMES

Replace the statically-sized CallFrame array in ObjFiber with a dynamically
allocated array that starts at INITIAL_CALL_FRAMES (4) and doubles when
capacity is exceeded. This reduces memory for new fibers and improves
fiber creation benchmark performance by ~45%.
This commit is contained in:
Bob Nystrom
2015-07-01 07:00:25 +00:00
parent 8ae42156d8
commit 29ca6f4ffc
5 changed files with 82 additions and 36 deletions
+16
View File
@@ -0,0 +1,16 @@
// Creates 10000 fibers. Each one calls the next in a chain until the last.
var fibers = []
var sum = 0
var start = IO.clock
for (i in 0...100000) {
fibers.add(new Fiber {
sum = sum + i
if (i < 99999) fibers[i + 1].call()
})
}
fibers[0].call()
IO.print(sum)
IO.print("elapsed: ", IO.clock - start)