Ruby 2.0.0 has made a big difference for us in load time. I was wondering if we could get even better load times by caching interpreted ruby code data via c-extension. The idea came to me while reading pickaxe section "Embedding a Ruby Interpreter". Here is a snippet from there with some caching pseudocode added.
#include "ruby.h"
main() {
/* ... our own application stuff ... */
ruby_init();
ruby_script("embedded");
/* HERE IS THE PSEUDOCODE FOR CACHING */
if (ruby_file_previously_loaded_and_cached())
load_marshalled_ruby_data();
else
rb_load_file("start.rb");
cache_all_the_ruby_data();
end
while (1) {
if (need_to_do_ruby) {
ruby_run();
}
/* ... run our app stuff */
}
}
Is something like this possible?