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

PERF: reduce retained objects in Journey #32016

Merged
merged 1 commit into from Feb 16, 2018

Conversation

Projects
None yet
5 participants
@SamSaffron
Copy link
Contributor

SamSaffron commented Feb 16, 2018

Before:

Total allocated: 209050523 bytes (2219202 objects)
Total retained: 36580305 bytes (323462 objects)

After:

Total allocated: 209180253 bytes (2222455 objects)
Total retained: 36515599 bytes (321850 objects)


Modest saving of 1612 RVALUEs in the heap on Discourse boot

PERF: reduce retained objects in Journey
Before:

Total allocated: 209050523 bytes (2219202 objects)
Total retained:  36580305 bytes (323462 objects)

After:

Total allocated: 209180253 bytes (2222455 objects)
Total retained:  36515599 bytes (321850 objects)

---

Modest saving of 1612 RVALUEs in the heap on Discourse boot

The larger the route file the better the results.

Saving will only be visible on Ruby 2.5 and up.
@rails-bot

This comment has been minimized.

Copy link

rails-bot commented Feb 16, 2018

r? @eileencodes

(@rails-bot has picked a reviewer for you, use r? to override)

@eileencodes eileencodes merged commit c0e055c into rails:master Feb 16, 2018

1 of 2 checks passed

continuous-integration/travis-ci/pr The Travis CI build failed
Details
codeclimate All good!
Details
@@ -32,7 +32,7 @@ def to_sym
end

def name
left.tr "*:".freeze, "".freeze
-(left.tr "*:", "")

This comment has been minimized.

@schneems

schneems Feb 23, 2018

Member

What is going on here? i'm not familiar with -() invocation, is that what's saving memory?

This comment has been minimized.

@rafaelfranca

rafaelfranca Feb 23, 2018

Member

http://ruby-doc.org/core-2.5.0/String.html#method-i-2D-40.

It is equivalent to left.tr("*:", "").freeze, except that it only freeze if it is not frozen already.

This comment has been minimized.

@SamSaffron

SamSaffron Feb 23, 2018

Contributor

oh... you got to read https://samsaffron.com/archive/2018/02/16/reducing-string-duplication-in-ruby carefully, and https://bugs.ruby-lang.org/issues/14478 ... left.tr("*:", "").freeze will not de-duplicate in Ruby 2.5 ... -(left.tr("*:", "")) will ... and amusingly -(left.tr("*:", "").freeze) will not until my bug is fixed and backported, which is a 3 line change ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment