The https://github.com/simeonwillbanks/busted gem provides some nice helpers around RubyVM.stat for finding cache invalidations. It can also take advantage of the dtrace/systemtap probes that shipped with ruby 2.1 (http://tmm1.net/ruby21-method-cache) which can be used as an alternative to the ftrace technique described in the blog post.
Re:Tuning Ruby's Global Method Cache
by stanislavb on Thursday January 22, 2015 @12:14AM
(#8927653)
Thanks! The idea of adding this to tests or a middleware is very good :)
Re:Tuning Ruby's Global Method Cache
by sshconnection on Wednesday January 21, 2015 @06:15PM
(#8926451)
Does OpenStruct still break caches?
If you're worried about flushing the cache, there's Charlie Somerville's flush-free OpenStruct:
Anyway, the point is that you can get access to the information from Ruby, so I'll use this when testing Rails to ensure we aren't breaking caches. Making a Rack middleware to output this info might be handy, or adding it to tests might be a cool project too (like output a warning if a test method breaks the cache or something).