📜 ⬆️ ⬇️

Speed ​​up Ruby on Rails launch using the RVM railsexpress patch set

This article is for those who want to speed up the launch of the rail, and at the same time speed up the work of the ruby ​​interpreter.
There are a lot of articles already written about how to install RVM (Ruby version manager), so I’ll go straight to the point.
List of patches in RailsExpress for Ruby 1.9.3-p362
(This is the latest version of Ruby at the time of this writing)
Applying patch railsexpress/01-fix-make-clean.patch Applying patch railsexpress/02-railsbench-gc.patch Applying patch railsexpress/03-display-more-detailed-stack-trace.patch Applying patch railsexpress/04-fork-support-for-gc-logging.patch Applying patch railsexpress/05-track-live-dataset-size.patch Applying patch railsexpress/06-webrick_204_304_keep_alive_fix.patch Applying patch railsexpress/07-export-a-few-more-symbols-for-ruby-prof.patch Applying patch railsexpress/08-thread-variables.patch Applying patch railsexpress/09-faster-loading.patch Applying patch railsexpress/10-falcon-st-opt.patch Applying patch railsexpress/11-falcon-sparse-array.patch Applying patch railsexpress/12-falcon-array-queue.patch 


1. We specify RVM with what parameters it is necessary to compile Ruby

To do this, create a .rvmrc file in your home directory.
 $ nano -e $HOME/.rvmrc 

And explicitly tell RVM with which options to compile Ruby.
 CFLAGS="-march=native -O2 -pipe -fomit-frame-pointer" rvm_configure_env=(CFLAGS="-march=native -O2 -pipe -fomit-frame-pointer") 

Here, the -march = native parameter instructs the compiler to automatically select the type of processor and the capabilities supported by this processor. If you know the exact type of your processor, you can specify, for example, -march = prescott

Save changes: [ctrl + X], then [Y] - to exit and save to nano.

2. Update the lists of available Ruby versions in RVM

 $ rvm get head 

')
3. Install / reinstall ruby ​​using railsexpress patches

for Ruby version 1.9.3-p362
 $ rvm reinstall 1.9.3-p362 --patch railsexpress -n railsexpress -j 3 $ rvm list $ rvm use ruby-1.9.3-p362-railsexpress --default 

If you always need the latest version, then instead of p362 you must specify the head ,
but for the latest version patches appear with a delay, it must be borne in mind.

4. Bonus

 export RUBY_HEAP_MIN_SLOTS=1000000 export RUBY_HEAP_FREE_MIN=500000 export RUBY_HEAP_SLOTS_INCREMENT=1000000 export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1 export RUBY_GC_MALLOC_LIMIT=100000000 


5. We measure speed

The launch speed of the rail can be measured as follows:
 $ time bundle exec rake routes 

In my case:
before
real 0m42.547s
user 0m36.502s
sys 0m2.248s

after
real 0m17.200s
user 0m15.089s
sys 0m1.072s


Here you can read additional info on patches https://github.com/skaes/rvm-patchsets

Source: https://habr.com/ru/post/165627/


All Articles