-
Notifications
You must be signed in to change notification settings - Fork 375
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 memory footprint and GC pressure #446
Reduce memory footprint and GC pressure #446
Conversation
Could you explain some of the issues you suspect are taking up the most memory and how you're solving them? It would be great to have some context to consider these changes in. |
56cb6ff
to
69039b3
Compare
Maybe that's not the point in this pull request, but shouldn't Processes like ntp can change the time, and the value returned by This article goes in depth about this topic. |
@cbliard That's a good suggestion. I think we might address any changes to handling time in a different pull request altogether, given the complexity it introduces, and the impact it could have. We do already have #424 open as an implementation of |
…y_footprint_and_gc_pressure
f3f2cdc
to
b312af5
Compare
b312af5
to
2161915
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all looks pretty good to me! 👍
This PR tries to optimize memory used by enabled integrations.
Each traced operation creates a span to store the data about it. Each created span has associated cost, both related to creation time and memory footprint of Span object.
Inspecting code and looking at measurements produced by
derailed
gem helped identify spots of unnecessary temporary object creation.This PR reduces the incidence of temporary object creation and by switching storing of timestamps to much smaller
Floats
(before they were full Time objects, with some temporary objects created in between.It reduces the maximum memory used by test application by up to 50%.
Examples of changes:
Proxy
objects, now they are cached.freeze
-ing those solved that problem (at least for rubies 2.2+)Utils.truncate
was used to truncate Strings, however it did so by creating around 3 temporary strings each with a copy of truncated string. New#truncate!
method uses the fact that all those Strings can be safely modified to truncate the object without any temporary object creation.Time.now.utc
requires 2 Time objects to be created.Process.clock_gettime(Process::CLOCK_REALTIME)
only creates one Float which has much negligible footprint compared to Time.