jruby/jruby — pull request #1546 by ratnikov (2014-03-05 23:58:46+00:00)
Title: Implement jar directory snapshot caching.

Currently, when we try to load a jar resource, we go through all the jar entries to figure out if there are any that match the directory information. When doing globbing or Dir.entries it also currently scans the jar again.

This PR optimizes this by creating a static JarCache reference that caches information about loaded jars, including representation of the directory structure. The inform1.7.10: user 1m24.332s
HEAD: user 0m19.604sation is stored in a WeakHashMap which should allow it to be garbage collected. Benchmarking on a jar containing files from jruby.git/core (just over 9000 files) shows about 4x improvement:

```
time bin/jruby -e '5.times { Dir.glob("file:/home/ratnikov/jruby.git/stuff.jar!core/**/*") }'
```

Results for 1.7.10: 1m24.332s
Results for HEAD: 0m19.604s

I have considered doing a per Ruby runtime cache, but that would require resources to have a reference to a Runtime and caching cross-runtime jar contents is also probably okay.