Skip to content

Instantly share code, notes, and snippets.

@luislavena
Created November 2, 2011 23:07
Show Gist options
  • Save luislavena/1335240 to your computer and use it in GitHub Desktop.
Save luislavena/1335240 to your computer and use it in GitHub Desktop.
ruby 1.8.7 (2011-06-30 patchlevel 352) [i386-mingw32]
rails 3.1.1
C:\>rails new empty-187 -d sqlite3
C:\empty-187>timer ruby script\rails runner "puts $LOADED_FEATURES.size"
705
real 4.538
system 2.667
user 1.794
ruby 1.9.2p290 (2011-07-09) [i386-mingw32]
rails 3.1.1
C:\>rails new empty-192 -d sqlite3
C:\empty-192>timer ruby script\rails runner "puts $LOADED_FEATURES.size"
719
real 9.083
system 5.272
user 3.775
ruby 1.9.3p0 (2011-10-30) [i386-mingw32]
rails 3.1.1
C:\>rails new empty-193 -d sqlite3
C:\empty-193>timer ruby script\rails runner "puts $LOADED_FEATURES.size"
724
real 4.786
system 2.808
user 1.856
tcs-ruby 1.9.3p0 (2011-10-30 revision 33569) [i386-mingw32]
rails 3.1.1
C:\>rails new empty-tcs -d sqlite3
C:\empty-tcs>timer ruby script\rails runner "puts $LOADED_FEATURES.size"
724
real 3.349
system 1.918
user 1.341
ruby 1.9.3p0 (2011-10-30 revision 33569) [i386-mingw32]
rails 3.1.1
C:\>rails new empty-[redacted] -d sqlite3
C:\>SET RUBYOPT=[redacted]
C:\empty-[redacted]>timer ruby script\rails runner "puts $LOADED_FEATURES.size"
726
real 2.658
system 0.686
user 1.903
@luislavena
Copy link
Author

@luislavena
Copy link
Author

And just for reference:

ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]

$ time ruby script/rails runner "puts \$LOADED_FEATURES.size"
722

real    0m1.812s
user    0m1.200s
sys     0m0.570s
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]

$ time ruby script/rails runner "puts \$LOADED_FEATURES.size"
735

real    0m3.885s
user    0m3.330s
sys     0m0.500s
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]

$ time ruby script/rails runner "puts \$LOADED_FEATURES.size"
741

real    0m2.427s
user    0m2.120s
sys     0m0.270s

@jarmo
Copy link

jarmo commented Nov 3, 2011

what is this redacted?

also, reading from that tcs post it seems that they're dealing all files as binary... which is not a fix as they state themselves

@luislavena
Copy link
Author

Can't comment about what tcs is doing, just included in the comparison because it contains some optimizations.

As for redacted, something I have been working on but is not yet ready for public. Maybe next week.

@luislavena
Copy link
Author

More details, now from Slow Leopard:

ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin10.8.0]

$ time ruby script/rails runner "puts \$LOADED_FEATURES.size"
703

real    0m2.239s
user    0m1.687s
sys 0m0.479s
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]

$ time ruby script/rails runner "puts \$LOADED_FEATURES.size"
716

real    0m3.460s
user    0m2.779s
sys 0m0.693s
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin10.8.0]

$ time ruby script/rails runner "puts \$LOADED_FEATURES.size"
722

real    0m2.044s
user    0m1.711s
sys 0m0.339s

@jarmo
Copy link

jarmo commented Nov 5, 2011

By public you mean that it will be part of RubyInstaller or part of Ruby core itself eventually?

@luislavena
Copy link
Author

luislavena commented Nov 5, 2011 via email

@luislavena
Copy link
Author

@jarmo the source of this is now open:

https://github.com/luislavena/fenix

Remember: is an experiment.

@jarmo
Copy link

jarmo commented Nov 9, 2011

Nice!

I thought that i can already do something like this:

require "fenix"
File = Fenix::File

And then all my existing code would use Fenix::File instead... but it failed:

C:/Ruby193/lib/ruby/1.9.1/rubygems/specification.rb:962:in `block (2 levels) in contains_requirable_file?': undefined method `file?' for Fenix::File:Class (NoMethodError)

Also, what is the Fenix::File.replace! method in replace.rb?

Running rake bench seems to be awesome! :)

@luislavena
Copy link
Author

luislavena commented Nov 9, 2011 via email

@jonforums
Copy link

@jarmo take a look at https://gist.github.com/1352096 for one way to get started playing with fenix.

I'm also looking forward to seeing Luis' blog on how best to integrate fenix with MRI source for more testing.

@jarmo
Copy link

jarmo commented Nov 9, 2011

On my small non-rails project this didn't seem to have any effect. Although i have 116 lines in my Gemfile.lock there.

I also tried it out with Rails without seeing any effect either (since i don't have any timer, i did it differently - maybe that has something to do with the fact also):

C:\empty-193>ruby -e "ts = []; 5.times {t = Time.now; system 'ruby -rfenix/replace script\rails runner \"puts $LOADED_FEATURES.size\"'; ts << Time.now - t}; puts ts.reduce(&:+) / ts.size.to_f"
732
732
732
732
732
17.3241898

C:\empty-193>ruby -e "ts = []; 5.times {t = Time.now; system 'ruby script\rails runner \"puts $LOADED_FEATURES.size\"'; ts << Time.now - t}; puts ts.reduce(&:+) / ts.size.to_f"
730
730
730
730
730
16.2904982

C:\empty-193>ruby -v
ruby 1.9.3p0 (2011-10-30) [i386-mingw32]

@luislavena
Copy link
Author

On my small non-rails project this didn't seem to have any effect. Although i have 116 lines in my Gemfile.lock there.

It will not have any effect because Ruby require is using the internal file_expand_path internally and not File.expand_path

You need to patch Ruby:

https://gist.github.com/1258289

You will need to apply that patch to the source code and perhaps compile using RubyInstaller repository, like I do:

rake ruby19 NOGEMS=1 NOTK=1 LOCAL=C:\Path\To\ruby

Where ruby is your clone of ruby/ruby repository and the patch shown in the previous gist.

Again, be careful, the code is just a proof of concept, it might not work for your environment, in which case feedback will be appreciated at the project repository.

@jarmo
Copy link

jarmo commented Nov 9, 2011

Can't add the patch for some reason:
C:\rubyinstaller\ruby>git apply -v 0001-make-load-and-require-use-file-expand_path-and-file-realpath.diff
Checking patch file.c...
error: while searching for:
if (!ext[0]) return 0;

if (f[0] == '~') {
    fname = file_expand_path_1(fname);
    if (safe_level &gt;= 1 &amp;&amp; OBJ_TAINTED(fname)) {
        rb_raise(rb_eSecurityError, "loading from unsafe file %s", f);
    }

error: patch failed: file.c:5117
error: file.c: patch does not apply
Checking patch load.c...
error: while searching for:

ary = rb_ary_new2(RARRAY_LEN(load_path));
for (i = 0; i &lt; RARRAY_LEN(load_path); ++i) {
    VALUE path = rb_file_expand_path(RARRAY_PTR(load_path)[i], Qnil);
    rb_str_freeze(path);
    rb_ary_push(ary, path);
}

error: patch failed: load.c:43
error: load.c: patch does not apply

@luislavena
Copy link
Author

Can't add the patch for some reason:

Did you setup your close of ruby as core.autocrlf=false ? if not, patch will fail.

Also, you need to apply against ruby_1_9_3 branch.

C:\Users\Luis\Projects\oss\ruby>git branch
  ruby_1_8_6
  ruby_1_8_7
  ruby_1_9_2
* ruby_1_9_3
  trunk

C:\Users\Luis\Projects\oss\ruby>git apply ..\0001-make-load-and-require-use-file-expand_path-and-file-realpath.diff

C:\Users\Luis\Projects\oss\ruby>git status
# On branch ruby_1_9_3
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   file.c
#       modified:   load.c
#

@jarmo
Copy link

jarmo commented Nov 9, 2011

Yup, i was on trunk :/

Trying to build now...

@jarmo
Copy link

jarmo commented Nov 9, 2011

Not much luck:

C:\rubyinstaller>rake ruby19 NOGEMS=1 NOTK=1 LOCAL=ruby --trace
Loading 001_dkcompiler_init.rb
Initializing DevKit compilers
...
** Extracting C:/rubyinstaller/downloads/coreutils-5.97-3-msys-1.0.13-ext.tar.lzma into sandbox/devkit
"C:/rubyinstaller/sandbox/extract_utils/basic-bsdtar.exe" -xf "C:/rubyinstaller/downloads/coreutils-5.97-3-msys-1.0.13-ext.tar.lzma" > NUL 2>&1
rake aborted!
Command failed with status (1): ["C:/rubyinstaller...]
C:/Ruby193/lib/ruby/1.9.1/rake/file_utils.rb:53:in `block in create_shell_runner'
C:/Ruby193/lib/ruby/1.9.1/rake/file_utils.rb:45:in `call'
C:/Ruby193/lib/ruby/1.9.1/rake/file_utils.rb:45:in `sh'
C:/Ruby193/lib/ruby/1.9.1/rake/file_utils_ext.rb:39:in `sh'
C:/rubyinstaller/rake/extracttask.rb:93:in `block in bsd_tar_extract'
C:/rubyinstaller/rake/extracttask.rb:92:in `chdir'
C:/rubyinstaller/rake/extracttask.rb:92:in `bsd_tar_extract'
C:/rubyinstaller/rake/extracttask.rb:27:in `extract'
C:/rubyinstaller/recipes/devkit/msys.rake:32:in `block (4 levels) in <top (required)>'
C:/rubyinstaller/recipes/devkit/msys.rake:30:in `each'
C:/rubyinstaller/recipes/devkit/msys.rake:30:in `block (3 levels) in <top (required)>'
C:/rubyinstaller/rake/checkpoint.rb:6:in `block in checkpoint'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:203:in `call'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:203:in `block in execute'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:200:in `each'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:200:in `execute'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:158:in `block in invoke_with_call_chain'
C:/Ruby193/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:151:in `invoke_with_call_chain'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:176:in `block in invoke_prerequisites'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:174:in `each'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:174:in `invoke_prerequisites'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:157:in `block in invoke_with_call_chain'
C:/Ruby193/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:151:in `invoke_with_call_chain'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:176:in `block in invoke_prerequisites'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:174:in `each'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:174:in `invoke_prerequisites'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:157:in `block in invoke_with_call_chain'
C:/Ruby193/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:151:in `invoke_with_call_chain'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:176:in `block in invoke_prerequisites'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:174:in `each'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:174:in `invoke_prerequisites'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:157:in `block in invoke_with_call_chain'
C:/Ruby193/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:151:in `invoke_with_call_chain'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:176:in `block in invoke_prerequisites'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:174:in `each'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:174:in `invoke_prerequisites'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:157:in `block in invoke_with_call_chain'
C:/Ruby193/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:151:in `invoke_with_call_chain'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:176:in `block in invoke_prerequisites'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:174:in `each'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:174:in `invoke_prerequisites'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:157:in `block in invoke_with_call_chain'
C:/Ruby193/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:151:in `invoke_with_call_chain'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:176:in `block in invoke_prerequisites'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:174:in `each'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:174:in `invoke_prerequisites'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:157:in `block in invoke_with_call_chain'
C:/Ruby193/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:151:in `invoke_with_call_chain'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:144:in `invoke'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:116:in `invoke_task'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:94:in `block (2 levels) in top_level'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:94:in `each'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:94:in `block in top_level'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handling'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:88:in `top_level'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:66:in `block in run'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handling'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:63:in `run'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/bin/rake:32:in `<top (required)>'
C:/Ruby193/bin/rake:19:in `load'
C:/Ruby193/bin/rake:19:in `<main>'
Tasks: TOP => ruby19 => interpreter:ruby19:configure => compiler => devkit:activate => devkit:msys => devkit:msys:extract => C:/rubyinstaller/sandbox/.checkpoints/.msys-extract

Can't see any error reasons here either...

@jonforums
Copy link

If this is the first time you've built with the recipes, go to the RubyInstaller's downloads directory and make sure there are no 0-byte downloads. If there are, delete them and try again.

@jarmo
Copy link

jarmo commented Nov 9, 2011

It's first time and there isn't any 0-byte files in downloads...

@luislavena
Copy link
Author

luislavena commented Nov 9, 2011 via email

@jonforums
Copy link

is the C:/rubyinstaller/downloads/coreutils-5.97-3-msys-1.0.13-ext.tar.lzma file 270,336 bytes for Size on disk: when you right-click and show properties?

@jarmo
Copy link

jarmo commented Nov 9, 2011

Yes, i have same size. Moving conversation to http://groups.google.com/group/rubyinstaller/browse_thread/thread/d615a6c63f65194c as suggested by Luis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment