Skip to content
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: dedupe scanned route fragments #31999

Merged
merged 1 commit into from
Feb 15, 2018
Merged

Conversation

SamSaffron
Copy link
Contributor

@SamSaffron SamSaffron commented Feb 15, 2018

Per: https://bugs.ruby-lang.org/issues/13077 String @- will dedupe strings.

This takes advantage of this by deduping route fragments that are full of duplication usually.

For Discourse:

Before:

Total allocated: 207574305 bytes (2214916 objects)
Total retained: 36470010 bytes (322194 objects)

After

Total allocated: 207556847 bytes (2214711 objects)
Total retained: 36327973 bytes (318627 objects) <- object that GC can not collect

So we save 3500 or so RVALUEs this way, not the largest saving in the world, but worth it especially for large route files.

Per: https://bugs.ruby-lang.org/issues/13077 String @- will dedupe strings. 

This takes advantage of this by deduping route fragments that are full of duplication usually. 

For Discourse:

Before:

Total allocated: 207574305 bytes (2214916 objects)
Total retained:  36470010 bytes (322194 objects)

After 

Total allocated: 207556847 bytes (2214711 objects)
Total retained:  36327973 bytes (318627 objects) <- object that GC can not collect


So we save 3500 or so RVALUES this way, not the largest saving in the world, but worth it especially for large route files.
@rails-bot
Copy link

r? @eileencodes

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

@SamSaffron
Copy link
Contributor Author

cc @matthewd @tenderlove

@tenderlove tenderlove merged commit 9f65d2a into rails:master Feb 15, 2018
@rafaelfranca
Copy link
Member

This PR broke a lot of tests. Reverting

@SamSaffron
Copy link
Contributor Author

SamSaffron commented Feb 15, 2018 via email

@SamSaffron
Copy link
Contributor Author

@rafaelfranca I fixed it in

SamSaffron@67c8742

Confirmed tests are running in local, can you merge it in or do you want me to redo the PR?

@rafaelfranca
Copy link
Member

I can manually apply the two patches. Doing

@rafaelfranca
Copy link
Member

done!

rafaelfranca added a commit that referenced this pull request Feb 15, 2018
This reverts commit 9f65d2a, reversing
changes made to 9668437.

This broken a lot of tests.
rafaelfranca added a commit that referenced this pull request Feb 15, 2018
@SamSaffron
Copy link
Contributor Author

SamSaffron commented Feb 15, 2018 via email

@y-yagi
Copy link
Member

y-yagi commented Feb 16, 2018

String#-@ was added in Ruby 2.3. Therefore, there is no method in 2.2.x, the build is broken.
https://travis-ci.org/rails/rails/jobs/342103442#L1180

Since master is already 6.0, will we stop supporting for 2.2.x?

@SamSaffron
Copy link
Contributor Author

Oh ... I think we should otherwise, just monkey patch in - conditionally on 2.2?

2.2 is EOL in March 31, 2018, I would drop it for master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants