jruby/jruby — pull request #1604 by nirvdrum (2014-04-02 03:10:32+00:00)
Title: Speed up require

This is definitely not in a state to be merged yet, but there was some healthy discussion of my PoC in IRC earlier today. I cleaned up a lot of code and created an actual branch. This PR is just for visibility and tracking discussion.

Should this be accepted, the biggest hurdle at the moment is making the code fail gracefully in Java 6. I had to make use of the Java 7 file watcher API in order to do cache invalidation. This also introduces a slight race condition. Previously as soon as a file was flushed to disk it was ready to be required. Now there's a narrow window between the require statement and the load path watcher thread updating the cache. I really don't know how often the LOAD_PATH entries are both written to and new requires of those files in practice. I'm pretty sure my 4.5 year old Rails app never does it.