4 ms·
Re: the C extensions: Since the performance is so much better, would it make sense to replace gems that use c extensions with pure ruby implementations? Would t
by miloshadzic 10y ago
Re: the C extensions: Since the performance is so much better, would it make sense to replace gems that use c extensions with pure ruby implementations? Would that still yield better performance than MRI?
- ianopolous 10y agoIt's not clear that would result in a speed up as graal + truffle can already do optimisations across language boundaries. So optimising a Ruby function that calls a C one can for example inline the C function and then continue optimising.
- chrisseaton 10y ago> would it make sense to replace gems that use c extensions with pure ruby implementations I think that the best practice for C extensions when used for performance is that Gems have both a pure Ruby reference implementation and a C extension. This means all implementations can run them and more people can read the code. OilyPNG and PSD Native do this and it's been extremely helpful to my research. C extensions, even when run in our interpreter, tend to run faster than Ruby code because C has simpler semantics and needs fewer guards (checks) when running code. I haven't done a careful comparison of C extension performance compared to Ruby performance when both are running on Graal. I should do that.
- miloshadzic 10y agoThanks
- nine_k 10y agoAny chance to use existing Java libs instead of C libs? Pure Java is pretty fast, and an existing library has the advantage of not just already being around, but probably being battle-tested.
- amorphid 10y agoThere's nothing that prevents that. However, Ruby is traditionally thought of as a language written in C, and the gold standard for a Ruby interpreter to be 100% compatible with anything that runs on MRI. So writing JVM specific extensions means losing MRI compatibly, at which point you're deviating from tradition.
- computerwizard 10y agoWhat about using Mirah ( http://www.mirah.org/ http://www.mirah.org/ )? Performance should be the same as Java.