The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Ruby Frozen String Literals Do Not Result in Any Performance Improvement

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Alexander Dymo

Posts: 24
Nickname: adymo
Registered: Feb, 2004

Alexander Dymo is the author of the Ruby Performance Optimization book
Ruby Frozen String Literals Do Not Result in Any Performance Improvement Posted: Apr 6, 2016 1:52 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Alexander Dymo.
Original Post: Ruby Frozen String Literals Do Not Result in Any Performance Improvement
Feed Title: Ruby and Rails Performance Optimization
Feed URL: http://ruby-performance-book.com/blog/feed/
Feed Description: This is the blog about Ruby and Rails performance optimization techniques, tips, and tricks. Learn how the newest Ruby releases perform in the field, see how to reduce memory and CPU usage, discover the world of profiling, measuring, and performance testing.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Alexander Dymo
Latest Posts From Ruby and Rails Performance Optimization

Advertisement

Frozen string literals is the experimental feature that appeared in Ruby 2.3 and will become the default behavior in Ruby 3.0. There's been some talk about how that improves performance. A month ago I ported one of my applications and saw no improvement. Today took another look, and my conclusion still stands.

If you haven't heard about frozen string literals yet, please read my previous blog post to learn more about how they work.

When I last experimented with this feature, my conclusion was that it only adds to the developer's frustration. It's just more work for us to port our applications.

I finally found the time to port Acunote, the application that has decent performance benchmarks. Let's look at some of my before/after measurements:

Benchmark Default Behavior Frozen String Literals
Benchmark Burndown 120 0.91 ± 0.02 0.91 ± 0.02
Benchmark Sprint 20 x (1+5) (C) 0.25 ± 0.00 0.25 ± 0.01
Benchmark Analyze 20 x (1+5) 1.96 ± 0.02 1.95 ± 0.04
Benchmark Task Details Page 0.40 ± 0.01 0.41 ± 0.01
Benchmark Signup 0.30 ± 0.00 0.31 ± 0.01
Benchmark Copy 120 1.47 ± 0.01 1.51 ± 0.02
Benchmark Import 71 2.02 ± 0.02 2.10 ± 0.01
Benchmark Set Field (EP) 0.20 ± 0.00 0.21 ± 0.00

This table is incomplete. The whole performance test suite has more than 60 benchmarks. But not one of them indicated any statistically significant speedup. Worse, the performance actually declined in two of the benchmarks that I highlighted in the table.

I haven't investigated the causes of the slowdown yet, but the conclusion is clear. Frozen string literals do not improve performance of my Rails applications.

The word my is important of course. There might well be a valid case when frozen string literals make your code faster. I just haven't seen it yet. But I have hard times imagining what it might be.

Did you like this post? Follow me on Twitter or Google+ to stay updated on Ruby performance optimization news.

Read: Ruby Frozen String Literals Do Not Result in Any Performance Improvement

Topic: 2016 Rails hosting survey is open Previous Topic   Next Topic Topic: A New Stack for 2016: Getting Started with React, ES6 and Webpack

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use