6 ms·
Defining instance-specific behavior of any kind is catastrophic to method caching. JRuby has a hierarchical method cache so it can clear only what's needed, but
by bascule 11y ago
Defining instance-specific behavior of any kind is catastrophic to method caching. JRuby has a hierarchical method cache so it can clear only what's needed, but MRI does not:
http://jamesgolick.com/2013/4/14/mris-method-caches.html http://jamesgolick.com/2013/4/14/mris-method-caches.html
The late, great James Golick had a patch to add one once, but it never got merged upstream.
If you care about performance even the tiniest bit at all whatsoever, please don't use the techniques discussed in the OP in production code or in your gems. It may make your memos 30% faster on a microbenchmark... while causing the rest of your program to run considerably slower.
- byroot 11y agoIt was merged for MRI 2.1: https://bugs.ruby-lang.org/issues/8426 https://bugs.ruby-lang.org/issues/8426
- bascule 11y agoThat change was reverted: https://bugs.ruby-lang.org/projects/ruby-trunk/repository/revisions/43027 https://bugs.ruby-lang.org/projects/ruby-trunk/repository/re... It remains an open issue: https://bugs.ruby-lang.org/issues/9262 https://bugs.ruby-lang.org/issues/9262
- byroot 11y agoI insist, it's mostly solved: http://tmm1.net/ruby21-method-cache/ http://tmm1.net/ruby21-method-cache/