3 ms·
TL;DR This is about pure Ruby code optimized by JIT vs manual optimization by writing C extensions (native code). There is Ruby code around those extensions bu
by pmontra 3y ago
TL;DR
This is about pure Ruby code optimized by JIT vs manual optimization by writing C extensions (native code). There is Ruby code around those extensions but
> The JIT cannot know what the native code will do to parameters (possibly mutate them), it cannot know what type of Ruby object will be returned, if the native code will look at the stack, or if it will raise an exception, etc. Thus the JIT is forced to have a conservative approach when dealing with native code, essentially forgetting much of what it had learned, and falling back to the most conservative implementation possible.
Hence the JIT often makes pure Ruby code run faster than the code with C extensions.
I think I heard the same argument many times with other JITed languages, interpreted or compiled.
- deleted 3y ago[deleted]
- xxs 3y agoAny managed language - java and go included, pays for trips to external, non-intrinsics calls. The standard way to deal is large portions/buffers to amortize the costs. This has been the case since the late '90s