Issue #5427 has been updated by Yura Sokolov.


11.10.2011 06:42, Urabe Shyouhei ????:
> On 10/10/2011 07:51 PM, Yura Sokolov wrote:
>> Anyway, is idea looks good?
> 
> The approach is interesting.  Do you have any benchmarks for how fast is it?
> 
Before patch:

RAILS_ENV=production rails runner 'puts $LOADED_FEATURES.size'
985

real	0m6.089s
user	0m5.644s
sys	0m0.308s


After patch:

RAILS_ENV=production rails runner 'puts $LOADED_FEATURES.size'
985

real	0m5.059s
user	0m4.552s
sys	0m0.336s
----------------------------------------
Feature #5427: Not complex patch to improve `require` time (load.c)
http://redmine.ruby-lang.org/issues/5427

Author: Yura Sokolov
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 


Currently `loaded_features` are unsorted, so that `rb_feature_p` ought to iterate over all `loaded_features` to figure: is requested feature loaded?

After this patch `loaded_features` is kept sorted by basename without extension (/usr/lib/ruby/asdf.rb => asdf). When `rb_feature_p` start its check, it goes straight to the first item with matching basename (using binary search) and stops after last.

Methods `$LOADED_FEATURES.<<` and `$LOADED_FEATURES.push` are overriden to keep sort order. `push` accepts only 1 parameter, but it seems that no one pass more to it.

Currently I choose to consider characters of basename in right to left order, but it could be changed, I think.

https://gist.github.com/1272991
https://github.com/ruby/ruby/pull/51


-- 
http://redmine.ruby-lang.org