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

Reduce allocated memory for Module#delegate. #19131

Merged

Conversation

tgxworld
Copy link
Contributor

I used the memory_profiler gem to look at the allocated memory when running a test.

Test Script modified from @eileencodes integration performance test repo:

require 'test_helper'

class DocumentsIntegrationTest < ActionDispatch::IntegrationTest
  test "create" do
    post '/documents', params: { document: { title: "New things", content: "Doing them" } }

    document = Document.last
    assert_equal 'New things', document.title
    assert_equal 'Doing them', document.content
  end
end

report = MemoryProfiler.report do
  Minitest.run_one_method(DocumentsIntegrationTest, 'test_create')
end

report.pretty_print

Before:

allocated memory by gem
-----------------------------------
activesupport/lib x 486470

allocated memory by file
-----------------------------------
/home/guoxiang/work/rails-dev-box/rails/activesupport/lib/active_support/core_ext/module/delegation.rb x 195005

allocated memory by location
-----------------------------------
/home/guoxiang/work/rails-dev-box/rails/activesupport/lib/active_support/core_ext/module/delegation.rb:170 x 136119

After:

allocated memory by gem
-----------------------------------
activesupport/lib x 354170

allocated memory by file
-----------------------------------
/home/guoxiang/work/rails-dev-box/rails/activesupport/lib/active_support/core_ext/module/delegation.rb x 62705

allocated memory by location
-----------------------------------
# Does not show in report

@senny
Copy link
Member

senny commented Feb 28, 2015

@tgxworld thank you, this looks good.

senny added a commit that referenced this pull request Feb 28, 2015
…dule_delegate

Reduce allocated memory for Module#delegate.
@senny senny merged commit daa455f into rails:master Feb 28, 2015
@eileencodes
Copy link
Member

@tgxworld in the future can you put the before and after in the commit so we don't need to track down the github PR. Thanks! 😸 :

@tgxworld
Copy link
Contributor Author

@eileencodes Opps I'll take note in the future! 😄

@tgxworld tgxworld deleted the reduce_allocated_memory_in_module_delegate branch July 1, 2016 01:21
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

3 participants