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:
@@ -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)
|
||||
Reference in New Issue
Block a user