Hacker News new | ask | show | jobs
by bascule 3901 days 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

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.

1 comments

It was merged for MRI 2.1: https://bugs.ruby-lang.org/issues/8426
I insist, it's mostly solved: http://tmm1.net/ruby21-method-cache/