Skip to content

Instantly share code, notes, and snippets.

@luislavena
Created December 17, 2011 15:52
Show Gist options
  • Save luislavena/1490555 to your computer and use it in GitHub Desktop.
Save luislavena/1490555 to your computer and use it in GitHub Desktop.
Compare different performance patches for Ruby 2.0.0dev under Windows
Environment information:
CPU: Core 2 Duo T7500 2.2 GHz
RAM: 4 GB
OS: Windows 7 x64 Ultimate
AV: Windows Security Essentials 2.1.1116.0 (WSE)
Profile: High Performance
HDD: ImDisk 1.5GB, 0% fragmentation
Bench on emptyapp were perform against Rails 3.1.3 with sqlite3 1.3.5
Bench on Enki application were using it's Gemfile and slightly modified to use sqlite3 1.3.5
NOTE: This is the RAW information I've collected, there has been no alteration or further analysis on it. Make your own conclusions about it.
Patches tested:
Feature #5767 - Cache expanded_load_path to reduce startup time
http://bugs.ruby-lang.org/issues/5767
Feature #5427 - Not complex patch to improve `require` time (load.c)
http://bugs.ruby-lang.org/issues/5427
load_ok performance improvements
https://groups.google.com/group/thecodeshop/browse_thread/thread/a684b15cb54a33dd
Fenix
https://github.com/luislavena/fenix
# ruby 2.0.0dev (2011-12-17 trunk 34060) [i386-mingw32]
# default build
V:\emptyapp>ruby script\rails runner -e development "puts $LOAD_PATH.size, $LOADED_FEATURES.size"
62
729
V:\emptyapp>ruby script\rails runner -e production "puts $LOAD_PATH.size, $LOADED_FEATURES.size"
62
740
real 7.488
system 4.820
user 2.636
real 7.472
system 4.773
user 2.620
real 7.503
system 4.976
user 2.511
real 7.425
system 4.914
user 2.496
real 7.612
system 4.726
user 2.854
V:\emptyapp>ruby script\rails runner -e production "0"
$LOAD_PATH: 62
$LOADED_FEATURES: 743
expanded_count: 134276
absolute_count: 0
realpath_count: 716
V:\measurements>rci --disable-gems bench core_require_empty
ruby 2.0.0dev (2011-12-17 trunk 34060) [i386-mingw32]
RubyGems disabled
Rehearsal ------------------------------------------------------
core_require_empty 1.139000 3.463000 4.602000 ( 4.700006)
--------------------------------------------- total: 4.602000sec
user system total real
core_require_empty 1.170000 3.463000 4.633000 ( 4.670007)
V:\measurements>rci --disable-gems bench core_require_empty
ruby 2.0.0dev (2011-12-17 trunk 34060) [i386-mingw32]
RubyGems disabled
Rehearsal ------------------------------------------------------
core_require_empty 1.295000 3.260000 4.555000 ( 4.660006)
--------------------------------------------- total: 4.555000sec
user system total real
core_require_empty 1.107000 3.463000 4.570000 ( 4.650007)
V:\measurements>rci --disable-gems bench core_require_empty
ruby 2.0.0dev (2011-12-17 trunk 34060) [i386-mingw32]
RubyGems disabled
Rehearsal ------------------------------------------------------
core_require_empty 1.357000 3.245000 4.602000 ( 4.680006)
--------------------------------------------- total: 4.602000sec
user system total real
core_require_empty 1.217000 3.354000 4.571000 ( 4.670007)
V:\measurements>rci --disable-gems bench core_require_nested
ruby 2.0.0dev (2011-12-17 trunk 34060) [i386-mingw32]
RubyGems disabled
Rehearsal -------------------------------------------------------
core_require_nested 1.513000 3.682000 5.195000 ( 5.280007)
---------------------------------------------- total: 5.195000sec
user system total real
core_require_nested 1.654000 3.494000 5.148000 ( 5.230008)
V:\measurements>rci --disable-gems bench core_require_nested
ruby 2.0.0dev (2011-12-17 trunk 34060) [i386-mingw32]
RubyGems disabled
Rehearsal -------------------------------------------------------
core_require_nested 1.217000 4.040000 5.257000 ( 5.310008)
---------------------------------------------- total: 5.257000sec
user system total real
core_require_nested 1.357000 3.760000 5.117000 ( 5.270007)
V:\measurements>rci --disable-gems bench core_require_nested
ruby 2.0.0dev (2011-12-17 trunk 34060) [i386-mingw32]
RubyGems disabled
Rehearsal -------------------------------------------------------
core_require_nested 1.404000 3.837000 5.241000 ( 5.280007)
---------------------------------------------- total: 5.241000sec
user system total real
core_require_nested 1.467000 3.729000 5.196000 ( 5.240008)
# enki : https://github.com/xaviershay/enki
V:\enki>SET RUBYOPT=-rV:/replace
V:\enki>ruby -rV:/replace script\rails runner -e production ""
$LOAD_PATH: 71
$LOADED_FEATURES: 1040
expanded_count: 206601
absolute_count: 0
realpath_count: 1011
V:\enki>SET RUBYOPT=
V:\enki>timer ruby script\rails runner -e production "0"
real 12.101
system 7.753
user 4.274
real 12.142
system 7.472
user 4.617
real 12.157
system 7.410
user 4.711
real 12.161
system 7.394
user 4.680
real 12.224
system 7.690
user 4.430
# ruby 2.0.0dev (2011-12-17 trunk 34060) [i386-mingw32]
# CACHED_LOAD_PATH
V:\>SET RUBY_CACHED_LOAD_PATH=1
V:\emptyapp>ruby script\rails runner -e production "puts $LOAD_PATH.size, $LOADED_FEATURES.size"
62
740
real 2.589
system 1.138
user 1.466
real 2.636
system 1.060
user 1.544
real 2.605
system 1.045
user 1.544
real 2.589
system 1.170
user 1.404
real 2.605
system 1.076
user 1.513
V:\emptyapp>ruby script\rails runner -e production "0"
$LOAD_PATH: 62
$LOADED_FEATURES: 743
expanded_count: 27124
absolute_count: 0
realpath_count: 716
V:\measurements>rci --disable-gems bench core_require_empty
ruby 2.0.0dev (2011-12-17 trunk 34060) [i386-mingw32]
RubyGems disabled
Rehearsal ------------------------------------------------------
core_require_empty 0.687000 1.841000 2.528000 ( 2.630003)
--------------------------------------------- total: 2.528000sec
user system total real
core_require_empty 0.905000 1.513000 2.418000 ( 2.600004)
V:\measurements>rci --disable-gems bench core_require_empty
ruby 2.0.0dev (2011-12-17 trunk 34060) [i386-mingw32]
RubyGems disabled
Rehearsal ------------------------------------------------------
core_require_empty 0.733000 1.903000 2.636000 ( 2.770004)
--------------------------------------------- total: 2.636000sec
user system total real
core_require_empty 0.562000 1.888000 2.450000 ( 2.590004)
V:\measurements>rci --disable-gems bench core_require_empty
ruby 2.0.0dev (2011-12-17 trunk 34060) [i386-mingw32]
RubyGems disabled
Rehearsal ------------------------------------------------------
core_require_empty 0.717000 1.810000 2.527000 ( 2.590004)
--------------------------------------------- total: 2.527000sec
user system total real
core_require_empty 0.890000 1.575000 2.465000 ( 2.580003)
V:\measurements>rci --disable-gems bench core_require_nested
ruby 2.0.0dev (2011-12-17 trunk 34060) [i386-mingw32]
RubyGems disabled
Rehearsal -------------------------------------------------------
core_require_nested 0.811000 2.325000 3.136000 ( 3.200004)
---------------------------------------------- total: 3.136000sec
user system total real
core_require_nested 0.780000 2.230000 3.010000 ( 3.160005)
V:\measurements>rci --disable-gems bench core_require_nested
ruby 2.0.0dev (2011-12-17 trunk 34060) [i386-mingw32]
RubyGems disabled
Rehearsal -------------------------------------------------------
core_require_nested 0.936000 2.152000 3.088000 ( 3.180004)
---------------------------------------------- total: 3.088000sec
user system total real
core_require_nested 0.874000 2.106000 2.980000 ( 3.150005)
V:\measurements>rci --disable-gems bench core_require_nested
ruby 2.0.0dev (2011-12-17 trunk 34060) [i386-mingw32]
RubyGems disabled
Rehearsal -------------------------------------------------------
core_require_nested 0.890000 2.169000 3.059000 ( 3.190004)
---------------------------------------------- total: 3.059000sec
user system total real
core_require_nested 0.827000 2.246000 3.073000 ( 3.160005)
# enki : https://github.com/xaviershay/enki
V:\enki>SET RUBYOPT=-rV:/replace
V:\enki>ruby script\rails runner -e production "0"
$LOAD_PATH: 71
$LOADED_FEATURES: 1040
expanded_count: 41053
absolute_count: 0
realpath_count: 1011
V:\enki>SET RUBYOPT=
V:\enki>timer ruby script\rails runner -e production "0"
real 5.989
system 2.839
user 3.104
real 5.970
system 3.213
user 2.714
real 5.904
system 3.088
user 2.776
real 5.988
system 2.823
user 3.104
real 5.923
system 2.808
user 3.042
# ruby 2.0.0dev (2011-12-17 trunk 34060) [i386-mingw32]
# load_ok + CACHED_LOAD_PATH + Fenix
V:\>SET RUBY_CACHED_LOAD_PATH=1
V:\>SET RUBY_USE_ATTRIBUTE=1
V:\>SET RUBYOPT=-rfenix/replace
V:\emptyapp>ruby script\rails runner -e production "puts $LOAD_PATH.size, $LOADED_FEATURES.size"
62
742
real 2.254
system 0.780
user 1.435
real 2.278
system 0.624
user 1.622
real 2.289
system 0.561
user 1.700
real 2.277
system 0.702
user 1.528
real 2.277
system 0.624
user 1.560
$LOAD_PATH: 62
$LOADED_FEATURES: 745
expanded_count: 27124
absolute_count: 0
realpath_count: 716
V:\measurements>rci --disable-gems bench core_require_empty
ruby 2.0.0dev (2011-12-17 trunk 34060) [i386-mingw32]
RubyGems disabled
Rehearsal ------------------------------------------------------
core_require_empty 0.593000 0.827000 1.420000 ( 1.476082)
--------------------------------------------- total: 1.420000sec
user system total real
core_require_empty 0.671000 0.686000 1.357000 ( 1.445672)
V:\measurements>rci --disable-gems bench core_require_empty
ruby 2.0.0dev (2011-12-17 trunk 34060) [i386-mingw32]
RubyGems disabled
Rehearsal ------------------------------------------------------
core_require_empty 0.578000 0.795000 1.373000 ( 1.465061)
--------------------------------------------- total: 1.373000sec
user system total real
core_require_empty 0.717000 0.733000 1.450000 ( 1.447079)
V:\measurements>rci --disable-gems bench core_require_empty
ruby 2.0.0dev (2011-12-17 trunk 34060) [i386-mingw32]
RubyGems disabled
Rehearsal ------------------------------------------------------
core_require_empty 0.484000 0.920000 1.404000 ( 1.468082)
--------------------------------------------- total: 1.404000sec
user system total real
core_require_empty 0.437000 0.905000 1.342000 ( 1.442465)
V:\measurements>rci --disable-gems bench core_require_nested
ruby 2.0.0dev (2011-12-17 trunk 34060) [i386-mingw32]
RubyGems disabled
Rehearsal -------------------------------------------------------
core_require_nested 0.889000 1.248000 2.137000 ( 2.216921)
---------------------------------------------- total: 2.137000sec
user system total real
core_require_nested 0.733000 1.248000 1.981000 ( 2.161667)
V:\measurements>rci --disable-gems bench core_require_nested
ruby 2.0.0dev (2011-12-17 trunk 34060) [i386-mingw32]
RubyGems disabled
Rehearsal -------------------------------------------------------
core_require_nested 0.858000 1.186000 2.044000 ( 2.062685)
---------------------------------------------- total: 2.044000sec
user system total real
core_require_nested 0.718000 1.232000 1.950000 ( 2.044879)
V:\measurements>rci --disable-gems bench core_require_nested
ruby 2.0.0dev (2011-12-17 trunk 34060) [i386-mingw32]
RubyGems disabled
Rehearsal -------------------------------------------------------
core_require_nested 0.764000 1.248000 2.012000 ( 2.064114)
---------------------------------------------- total: 2.012000sec
user system total real
core_require_nested 0.624000 1.295000 1.919000 ( 2.036914)
# enki : https://github.com/xaviershay/enki
V:\enki>SET RUBYOPT=-rfenix/replace -rV:/replace-fenix
V:\enki>ruby script\rails runner -e production "0"
$LOAD_PATH: 71
$LOADED_FEATURES: 1042
expanded_count: 41053
absolute_count: 0
realpath_count: 1011
V:\enki>SET RUBYOPT=-rfenix/replace
V:\enki>timer ruby script\rails runner -e production "0"
real 3.613
system 0.858
user 2.745
real 3.645
system 0.936
user 2.714
real 3.642
system 0.826
user 2.761
real 3.651
system 0.842
user 2.745
real 3.643
system 0.920
user 2.698
# ruby 2.0.0dev (2011-12-17 trunk 34060) [i386-mingw32]
# load_ok + CACHED_LOAD_PATH + SORTED_FEATURES + Fenix
V:\>SET RUBY_CACHED_LOAD_PATH=1
V:\>SET RUBY_USE_ATTRIBUTE=1
V:\>SET RUBYOPT=-rfenix/replace
V:\emptyapp>ruby script\rails runner -e production "puts $LOAD_PATH.size, $LOADED_FEATURES.size"
62
742
real 2.131
system 0.577
user 1.513
real 2.083
system 0.546
user 1.450
real 2.123
system 0.624
user 1.482
real 2.129
system 0.639
user 1.482
real 2.093
system 0.577
user 1.497
V:\emptyapp>ruby script\rails runner -e production ""
$LOAD_PATH: 62
$LOADED_FEATURES: 745
expanded_count: 27124
absolute_count: 0
realpath_count: 716
V:\measurements>rci --disable-gems bench core_require_empty
ruby 2.0.0dev (2011-12-17 trunk 34060) [i386-mingw32]
RubyGems disabled
Rehearsal ------------------------------------------------------
core_require_empty 0.500000 0.951000 1.451000 ( 1.527085)
--------------------------------------------- total: 1.451000sec
user system total real
core_require_empty 0.686000 0.687000 1.373000 ( 1.459083)
V:\measurements>rci --disable-gems bench core_require_empty
ruby 2.0.0dev (2011-12-17 trunk 34060) [i386-mingw32]
RubyGems disabled
Rehearsal ------------------------------------------------------
core_require_empty 0.624000 0.765000 1.389000 ( 1.472069)
--------------------------------------------- total: 1.389000sec
user system total real
core_require_empty 0.437000 0.889000 1.326000 ( 1.451073)
V:\measurements>rci --disable-gems bench core_require_empty
ruby 2.0.0dev (2011-12-17 trunk 34060) [i386-mingw32]
RubyGems disabled
Rehearsal ------------------------------------------------------
core_require_empty 0.718000 0.764000 1.482000 ( 1.581888)
--------------------------------------------- total: 1.482000sec
user system total real
core_require_empty 0.655000 0.749000 1.404000 ( 1.452078)
V:\measurements>rci --disable-gems bench core_require_nested
ruby 2.0.0dev (2011-12-17 trunk 34060) [i386-mingw32]
RubyGems disabled
Rehearsal -------------------------------------------------------
core_require_nested 0.671000 1.248000 1.919000 ( 2.067114)
---------------------------------------------- total: 1.919000sec
user system total real
core_require_nested 0.717000 1.248000 1.965000 ( 2.042912)
V:\measurements>rci --disable-gems bench core_require_nested
ruby 2.0.0dev (2011-12-17 trunk 34060) [i386-mingw32]
RubyGems disabled
Rehearsal -------------------------------------------------------
core_require_nested 0.842000 1.264000 2.106000 ( 2.176486)
---------------------------------------------- total: 2.106000sec
user system total real
core_require_nested 0.843000 1.201000 2.044000 ( 2.069119)
V:\measurements>rci --disable-gems bench core_require_nested
ruby 2.0.0dev (2011-12-17 trunk 34060) [i386-mingw32]
RubyGems disabled
Rehearsal -------------------------------------------------------
core_require_nested 0.734000 1.263000 1.997000 ( 2.061913)
---------------------------------------------- total: 1.997000sec
user system total real
core_require_nested 0.765000 1.279000 2.044000 ( 2.053082)
# enki : https://github.com/xaviershay/enki
V:\enki>SET RUBYOPT=-rfenix/replace -rV:/replace-fenix
V:\enki>ruby script\rails runner -e production "0"
$LOAD_PATH: 71
$LOADED_FEATURES: 1042
expanded_count: 41053
absolute_count: 0
realpath_count: 1011
V:\enki>SET RUBYOPT=-rfenix/replace
V:\enki>timer ruby script\rails runner -e production "0"
real 3.527
system 0.889
user 2.558
real 3.511
system 0.889
user 2.558
real 3.506
system 0.811
user 2.605
real 3.487
system 0.842
user 2.574
real 3.519
system 0.920
user 2.574
$expanded_count = 0
$absolute_count = 0
$realpath_count = 0
class File < IO
class << self
alias_method :orig_expand_path, :expand_path
def expand_path(file_name, dir_string = nil)
$expanded_count += 1
# for replace-fenix we use Fenix::File.expand_path instead
orig_expand_path file_name, dir_string
end
alias_method :orig_absolute_path, :absolute_path
def absolute_path(file_name, dir_string = nil)
$absolute_count += 1
orig_absolute_path(file_name, dir_string)
end
alias_method :orig_realpath, :realpath
def realpath(pathname, dir_string = nil)
$realpath_count += 1
orig_realpath pathname, dir_string
end
def results
puts "$LOAD_PATH: #{$LOAD_PATH.size}"
puts "$LOADED_FEATURES: #{$LOADED_FEATURES.size}"
puts "expanded_count: #{$expanded_count}"
puts "absolute_count: #{$absolute_count}"
puts "realpath_count: #{$realpath_count}"
end
end
end
at_exit { File.results }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment