rubinius/rubinius — pull request #2353 by LTe (2013-05-17 13:32:49+00:00)
Title: Add cache for $LOAD_FEATURES and $LOAD_PATH

Rubinius will create cache for require short paths. When user
require file ie:

require 'path'
CodeLoader.loaded_features_index => { 'path' => '/real/path' }

When we try require 'path' once again Rubinius will not travel via
$LOAD_PATH because loaded_features_index include 'path'. But when user
will try require '/real/path' Rubinius will find this feature in
$LOADED_FEATURES. In the case of not finding the file anywhere Rubinius
will try find file in $LOAD_PATH and fill in cache.

When $LOADED_FEATURES change we need to invalidate cache!

New Rubinius::LoadPath keep cache array with expanded paths. When
$LOAD_PATH change we need to invalidate cache and recreate expanded
array of paths.

**Benchmark**

```ruby
require 'benchmark'

`mkdir f`

1000.times do |time|
`mkdir -p f/dir#{time}`
end

`touch f/dir888/single_file.rb

Benchmark.bm do |b|
1000.times do |time|
$LOAD_PATH << "f/dir#{time}"
end

b.report { 1000.times { require "single_file.rb" }}
end

`rm -rf ./f`
```

Before patch:
```
user system total real
1.940122 1.112070 3.052192 ( 3.059322)
```

After patch:
```
user system total real
0.100006 0.024002 0.124008 ( 0.143300)
```