3 ms·
> A shame that refinements don't really get much love Their performance is quite awful on MRI. Any method that was refined is tagged as such, which incur a 40%
by byroot 5y ago
> A shame that refinements don't really get much love
Their performance is quite awful on MRI. Any method that was refined is tagged as such, which incur a 40% performance hit (for empty methods)[0]. That alone tend to disqualify them for many use cases.
Then, it might get fixed, but whenever you call `using` all the heap is scanned and all methods caches flushed [1], which is a massive perf hit if it happens often.
TruffleRuby however runs them fast, but since most code out there target MRI, they're not really a good idea except for fringe use cases.
[0] https://gist.github.com/casperisfine/1c46f05cccfa945cd156f445f0d3d6fa https://gist.github.com/casperisfine/1c46f05cccfa945cd156f44...
[1] https://github.com/ruby/ruby/pull/4323 https://github.com/ruby/ruby/pull/4323
- eregon 5y agoInteresting, I did not know that just calling the original method, even when the refinement method is not used occurs such a cost on CRuby. Seems worth reporting if not already done. No such thing on TruffleRuby though, the only peak performance cost would be for megamorphic calls (rare, even more so in combination with refinements).
- byroot 5y ago> Seems worth reporting if not already done. I assumed it is expected overhead.