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

Add basic internal testing for memory allocations #2097

Merged
merged 12 commits into from
Sep 25, 2024
Merged

Conversation

joelhawksley
Copy link
Member

@joelhawksley joelhawksley commented Sep 17, 2024

What are you trying to accomplish?

This PR adds basic internal testing tooling for memory allocations, giving us a starting point for optimizing memory usage in the project.

What approach did you choose and why?

I copied the assert_allocations helper from Primer ViewComponents, but modified it to target specific Ruby versions to remove ambiguity.

@reeganviljoen
Copy link
Collaborator

@joelhawksley many production set-ups use jemalloc(its even in the default dockerfile for rails) so it may be usefull to test against it aswell

@joelhawksley
Copy link
Member Author

@reeganviljoen hmm. I'd worry about forcing folks to set up jemalloc locally in their dev environment to work against these tests. Do you think that'd be too much to ask?

Copy link
Contributor

@camertron camertron left a comment

Choose a reason for hiding this comment

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

Awesome!

ViewComponent::CompileCache.cache.delete(MyComponent)
MyComponent.ensure_compiled

assert_allocations("3.4.0" => 107, "3.3.5" => 116, "3.3.0" => 129, "3.2.5" => 115, "3.1.6" => 115, "3.0.7" => 125) do
Copy link
Contributor

Choose a reason for hiding this comment

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

Wow, pretty cool there's a ~15% decrease in allocations from Ruby 3.0 to 3.4 🎉

@joelhawksley joelhawksley merged commit def1448 into main Sep 25, 2024
19 checks passed
@joelhawksley joelhawksley deleted the allocations branch September 25, 2024 21:48
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.

3 participants