laverdet/node-fibers — Issue #43: Fiber performance
Author: scriby
Created: 2011-12-28 15:14:59+00:00
State: open

Hi,

In your fibers 0.2.0 nodejs google groups post, you show two code blocks:

```javascript
function F1() {
var fiber = Fiber(function() {
yield();
});
fiber.run();
fiber.run();
}

function F2() {
var buf = new Buffer(5);
buf.write('hello');
var buf2 = new Buffer(5);
buf2.write('world');
}
```

And you make the claim "To put this in perspective, these two functions are about the same in terms
of cpu time spent. In fact F2() is slightly slower. "

I tried running 100,000 iterations of F1 & F2 myself. When I run the benchmarks on my OSX machine, I get these results:

F1: 1200ms
F2: 250ms

And on Ubuntu:

F1: 825ms
F2: 250ms

Did fibers get slower, did buffers get faster, or is there something wrong with my benchmarks? Assuming those numbers are correct, it looks like the JS to C++ interop is not the majority of the cost with fibers now.

I'm interested in the raw performance of creating & running new fibers, as it directly affects asyncblock. I understand that fibers can't be as fast as solutions built on pure node, but there might be some room for improvement.

Thanks for looking at this,

Chris