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

Stop allocating the same settings keys repeatedly #6963

Merged

Conversation

segiddins
Copy link
Member

Running bundle update --bundler on a rails app locally:

==> memprof.after.txt <==
Total allocated: 301.90 kB (3794 objects)
Total retained:  73.24 kB (698 objects)

==> memprof.before.txt <==
Total allocated: 14.47 MB (196378 objects)
Total retained:  25.93 kB (202 objects)

So for a slight increase in retained memory (all keys are now retained),
we go from about 200k allocations in the settings file to under 4k

What was the end-user or developer problem that led to this PR?

What is your fix for the problem, implemented in this PR?

Make sure the following tasks are checked

@segiddins
Copy link
Member Author

@technicalpickles you might like this one too :)

Running `bundle update --bundler` on a rails app locally:

```
==> memprof.after.txt <==
Total allocated: 301.90 kB (3794 objects)
Total retained:  73.24 kB (698 objects)

==> memprof.before.txt <==
Total allocated: 14.47 MB (196378 objects)
Total retained:  25.93 kB (202 objects)
```

So for a slight increase in retained memory (all keys are now retained),
we go from about 200k allocations in the settings file to under 4k
@segiddins segiddins force-pushed the segiddins/stop-allocating-the-same-settings-keys-repeatedly branch from 750871e to e64debb Compare September 15, 2023 05:01
Copy link
Member

@martinemde martinemde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@indirect
Copy link
Member

Nice work!

@indirect indirect merged commit 92e666f into master Sep 15, 2023
92 checks passed
@indirect indirect deleted the segiddins/stop-allocating-the-same-settings-keys-repeatedly branch September 15, 2023 17:53
Copy link
Contributor

@technicalpickles technicalpickles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love to see it 🚀

I did come across part of this, ie the key_for and those key_to_s, but didn't have a good solution for it yet.

Comment on lines +547 to +548
when Symbol
key.name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh interesting! So this does not end up allocating any extra strings.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup!

deivid-rodriguez pushed a commit that referenced this pull request Oct 13, 2023
…same-settings-keys-repeatedly

Stop allocating the same settings keys repeatedly

(cherry picked from commit 92e666f)
deivid-rodriguez pushed a commit that referenced this pull request Oct 13, 2023
…same-settings-keys-repeatedly

Stop allocating the same settings keys repeatedly

(cherry picked from commit 92e666f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants