>And the winner is ... co-routines. > >I'm glancing at the code for rb_yield() and basically Ruby has co-routines >and I see some rather complex #defines around whether this should use >setjmp/longjmp or setcontext()/getcontext() depending on OS and compiler. > >Clearly from your DTrace experiment, your Solaris version is ending up >with the context-based implementation, and that is going to be massively >more expensive (and likely unnecessary). This is something I will point >out to the Solaris ruby people and not sure if Jason or others already have. > >Basically setjmp/longjmp are just inline assembly, whereas the context >stuff is a system call that restores not only your stack pointer but also >a complete register set, signal masks, floating-point state, and about >a hundred other things. Much of that is entirely unnecessary for a co-routine >implementation because you're not changing signal masks and so forth. >Whether you need the rest depends on how the surrounding code is written. > >If nothing else, one immediate optimization I see is that Ruby's context >code doesn't touch uc_flags -- it could at minimum clear out the bits >for things it doesn't need to change. This will save some work in >the kernel, but not the copyin() and the system calls. > >We'll need to get in touch with the Ruby VM team and figure out whether >indeed the context code is necessary on Solaris etc. But you have found >something very interesting. > >-Mike > >-- >Mike Shapiro, Sun Microsystems Fishworks. blogs.sun.com/mws/
That's great news! If it helps, I'm running this on Solaris 10 05/08 with current Blastwave Ruby (1.8.6). BTW: Anybody seen a recent binary of Joyents Ruby CSW package? All I can find is 1.8.5. -- This message posted from opensolaris.org _______________________________________________ dtrace-discuss mailing list [email protected]
