Juicy Ruby 2.1

  • 656 views
Uploaded on

Overview of Ruby 2.1 features

Overview of Ruby 2.1 features

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
656
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
3
Comments
0
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. JUICY RUBY 2.1 David Paluy Founder of Azorly @dpaluy 
 blog: david.paluy.org Jan 2014
  • 2. AGENDA • Overview • Performance • Internal Improvements • Should we migrate?
  • 3. POLL • Ruby 1.8.7 • JRuby • Rubinius • Ruby 1.9.2 -1.9.3 • Ruby 2.0.0 • Ruby 2.1.0
  • 4. RUBY 2.1OVERVIEW • Refinements Advice: Don’t use it, unless you really need it!
  • 5. RUBY 2.1OVERVIEW • Decimals ! • Required Keyword Arguments
  • 6. RUBY 2.1 OVERVIEW Method Definition returns Method Name • ! StringScanner supports Named Captures
 • 
 
 (check references)
  • 7. PERFORMANCE - 
 HOW TO MEASURE but better use:
  • 8. HOW TO MEASURE - HITIMES gem install hitimes
  • 9. RUBY 2.1 PERFORMANCE … Source: http://miguelcamba.com/blog/2013/10/05/benchmarking-the-ruby-2-dot-1-and-rubinius-2-dot-0/
  • 10. RUBY 2.1 INTERNAL IMPROVEMENTS • Profiling support • Improved ObjectSpace • Improved GC • Improved method caching
  • 11. PROFILING SUPPORT - (C API) stackprof (perftools.rb replacement) https://github.com/tmm1/stackprof ! ! ! Sampling modes: cpu, wall, :object, :custom Read more: http://tmm1.net/ruby21-profiling/
  • 12. OBJECTSPACE - 
 HEAP DEBUGGING UTILITIES
  • 13. RGenGC: Restricted Generational Garbage Collection New generational GC algorithm permits
 Write-barrier (WB) protected objects AND WB un-protected object in the same heap
  • 14. RGenGC - Key Idea • Separate Objects ! ! • Shady Object points to new Object?
 We don’t know! • Decide at Creation
 Class cares about WB and don’t cares about non-WB • Normal objects can be changed to Shady objects
  • 15. OLDGEN AND MINOR MARKING ! ! • Only protected objects can be promoted to oldgen • Unprotected objects cannot be promoted, but if referenced from oldgen they are added to a remembered set. • Minor marks are much faster because they only have to traverse references from the remembered set
  • 16. TUNING THE GC IN RUBY 2.1 Memory allocation → GC • Every time allocate n size memory (call malloc(n)) 
 increase malloc_increase with n • If malloc_increase > malloc_limit, then cause GC ! Adaptive tuning • If malloc_increase exceeds malloc_limit, then increase malloc_limit
 (by a factor of GC_MALLOC_LIMIT_GROWTH_FACTOR) up to GC_MALLOC_LIMIT_MAX
  • 17. GC ENVIRONMENT PARAMS
  • 18. GITHUB TWEAKS
  • 19. METHODS CACHE Ruby 2.1 introduces a hierarchical class cache similar to the what Rubinius and JRuby use Aman Gupta: 
 “Early numbers show up to 5-10% improvements” ! More improvements in Ruby 2.2
  • 20. PRODUCTION READY? • breaks the faraday gem • affects the sass gem • segv inside active_support_4 and other gems • Performance Patches by funny-falcon
  • 21. PRODUCTION READY? ! ! Aman Gupta’s summary: 
 https://gist.github.com/tmm1/8393897 Github uses Ruby 2.1 in Production
  • 22. REFERENCES • Konstantin Haase - http://rkh.im/ruby-2.1 • Aaron Patterson - https://practicingruby.com/articles/parsing-json-the-hard-way?u=90296723ac • Hitimes - https://github.com/copiousfreetime/hitimes • Ruby Benchmark - https://github.com/acangiano/ruby-benchmark-suite • Aman Gupta:
 production summary - https://gist.github.com/tmm1/8393897
 Ruby 2.1 - http://tmm1.net/ruby21/ • Koichi Sasada - http://rvm.jp/~ko1/activities/rubyconf2013-ko1_pub.pdf • James Golick - http://jamesgolick.com/2013/4/14/mris-method-caches.html
  • 23. THANK YOU! @DPALUY