-
Notifications
You must be signed in to change notification settings - Fork 743
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add frozen_string_literal: true magic comment to reduce string allocations in modern Rubies #883
Conversation
Thanks @ashmaroli. Did you add this to all files, or did you encounter any places where this broke something and omitted it on those files? I admit, this is the first I'm learning about the magic comment. I see some information that suggests it has to be the first line of every file. Does it still work as the second line since the utf-8 comments are in most files? |
The comments were added via Rubocop's The test failures I encountered in the intermediate steps above is proof that the magic comment works even when its on the second line. (You can also easily test that on any local Ruby script using Ruby 2.3 and above.) |
@ashmaroli Sorry for the delay on this. Are you interested in fixing this up with the latest master? It would be nice to get going. I just did some memory profiling and I see that this causes memory allocation for the |
@dblessing Yes, I'm 👍 👍 on updating this with the latest
Would love it if the script for that was pushed into this repository.. |
I plan to make it a Rake task(s) once I have something solid. I'm still playing at the moment. Thanks for your willingness to pick this up again. Ping me when ready. |
c76677a
to
a97a342
Compare
@dblessing I've updated the branch with Awaiting your feedback.. 😃 |
Thanks @ashmaroli Testing now |
Nice, albeit modest, improvements in memory usage and number of objects. I'll take it :)
|
Thank you for merging, and yes, for posting the numbers as well 😃 👍 |
Reduce memory usage to allocate duplicate strings in Ruby 2.3 and above by adding the magic comment:
# frozen_string_literal: true