-
Notifications
You must be signed in to change notification settings - Fork 170
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
Newrelic RPM Performance Regression #59
Comments
👍 thanks @mnelson ! |
Trying makara v0.3.0rc3 for the first time with AR 4.1.8 and newrelic_rpm 3.9.7.266, I can confirm performance problems |
Another for you Makara 0.3.x + AR 4.x + RPM 3.9.6.257 = regression yes |
Hey there! I'm a developer on newrelic_rpm and got linked to these perf issues today. Major bummer! I'd like to help get to the bottom of it if we can. I haven't used makara in earnest before, and plugging it into my basic Rails 4 test app didn't show me much perf difference yet. I'm sure I'm missing something in my configuration, though. Does anyone have a relatively simple duplication case that I could use to dig in? Ideal would be a repo with a Rails app that I could toggle between the versions and see the perf differences, but any indicator where to head would be appreciated. |
Here you go! https://github.com/taskrabbit/makara_newrelic_test
Let me know if there's anything I can do to help. |
#71 will likely be of interest as well. |
Based on the rubygem releases I believe the issue will be found between |
I'm seeing an improvement in this branch - but it's still 4x slower
|
Thanks @mnelson, that's going to be super helpful in tracking this down! I probably won't be able to dig deep on this until next week, but having those dups will be huge in getting to the bottom of this. Thanks again! |
As expected, that repro case was awesome ✨. Thanks again @mnelson for putting it together! The slowdown is happening at this point in Here's a slightly nicer version of the same code from the Ruby agent that you can put in a task or script to run:
When I run this in a Rails project with the
Running that with makara instead (doesn't matter if New Relic's in the picture for this), yields this:
I haven't dug into makara to see about why this path is slow. Stackprof gives some slightly confusing results, but points to FWIW, we don't really like this connection lookup, and are continuing to look for a solution from the Rails end to avoid it. But even if we get an update it'll only be available in some as-yet-unavailable Rails version, so this code is likely to live on even then as a fallback on Rails 4.x. Any thoughts where to go from here @mnelson? |
@jasonrclark Is there an issue with using Oh, just remembered I use id2ref for the makara logging as well: https://github.com/taskrabbit/makara/blob/master/lib/makara/logging/subscriber.rb#L25 |
Btw, the repro is updated with some id2ref rake tasks https://github.com/taskrabbit/makara_newrelic_test |
@mnelson There actually are problems with The two issues were that 1) Given those constraints, we can't go back to using Failing that, I've got an idea or two about how we could let you override the connection retrieval. It's a little awkward because of load ordering (I expect |
With a little more digging I've determine that the bottleneck occurs due to the |
FWIW, this is a potential fix for the NR codebase - even though I understand the real problem is in Makara. connection = ActiveRecord::Base.connection_handler.connection_pool_list.detect do |l|
l.connections.detect do |c|
c.object_id == 4
end
end |
That's a great idea @mnelson. Tested it out, and with a little tweaking (can't use the outer It also neatly avoids a couple extra object allocations, so in addition to helping makara out, it's a small win for every ActiveRecord 4.x client using This isn't likely to make it in the next release of the agent which is baking internally already for release, but I'll ping here when we have a branch of the agent to test against directly. |
Based on instacart/makara#59, there were perf issues in looking up the connection from the pool when on ActiveRecord 4.x using the makara adapter. While this was a problem with makara itself, @mnelson suggested alternate lookup code which works with makara and actually allocates less, so we're updating to use that.
Hi guys. I just got into the same issue. What is the workaround while it is not fixed? |
With reference to the table above, you can use one of the makara or rpm versions which does not have the performance issue. I have a branch which somewhat improves the situation but it does not fix it completely. You can absolutely give that branch a try but, as I said, it won't completely fix the issue. The underlying perf issue seems to be in ruby's Delegator class and I'm still working on finding a solution which at the very least avoids the problem. |
I have tested makara 0.3.x (latest version) with rpm 3.6.6.147 and AR 4.x and it is working fine! |
Thanks @danicuki, added to the table. |
Hey y'all - we've just released version 3.11.2 of the newrelic_rpm gem, which should address this issue. Thanks again for your help in isolating and fixing it! |
Makara Version ---> 0.3.3 |
@jasonrclark done. Thanks. |
Issues #45 and #51 have both reported issues when using Makara alongside certain versions of newrelic/rpm. In an attempt to be as transparent as possible as well as potentially isolate the issue, the following table will hold the information required to check your stack against other community reports.
Newrelic has released a fix
The range of newrelic releases affected is 3.7.2 <= X < 3.11.2
The text was updated successfully, but these errors were encountered: