-
Notifications
You must be signed in to change notification settings - Fork 28
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
Use frozen_string_literal: true #220
Use frozen_string_literal: true #220
Conversation
This can help reduce memory, by making string literals frozen. That means they are only allocated once in the file, instead of each time the code executes.
I generated this using |
@technicalpickles Thanks for the proposed PR. I added this to review in our backlog. Do you have stats showing how much memory reduction you see in your test suite? More or less? |
I was able to use memory_profile before and after. Including the comparison below, but basically this allocates 4.8% less memory for the benchmarking I was doing. SummaryBefore
After
254,987,726 byte reduction of allocated memory (4.8%). 2,162,311 reduction of allocated objects (4.6%) 1,156,738 byte reduction of retained memory (0.2%). 5380 reduction of retained objects (0.1%). memory allocationby gembefore
after
3253223 reduction of allocated memory (7%). by filebefore
after
object allocationby gembefore
after
76953 reduction of allocated objects (26%) by filebefore
after
|
@technicalpickles Thanks for the stats. |
@technicalpickles We released the knapsack_pro 5.6.0 version. Please update it. |
This can help reduce memory, by making string literals frozen. That means they are only allocated once in the file, instead of each time the code executes.
Noticed this while starting to profile for #200