-
Notifications
You must be signed in to change notification settings - Fork 75
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
Gem object allocation #36
Comments
Hi @sergey-alekseev, I actually ran into this also when I was looking at Skylight itself. |
I don't think |
@sergey-alekseev when i run
Here is the line in the @schneems do you have any idea if this is mis-assigned or something? |
That seems really high. @halorgium can you give me a gist with a |
I just tried things out with a fresh Rails app: https://gist.github.com/wagenet/9d09e79b1cd73491c1c6. Without Skylight:
With Skylight:
The top gems in terms of allocated memory are:
@halorgium is out of town otherwise I'd pull him in on this for more clarification. |
I just ran this under codetriage.com and don't even see skylight in my "top" list after adding "skylight" to the gemfile:
|
noticed the same thing while running the
@schneems codetriage is running an old version of the
|
@lucasmazza @schneems The main thing that |
Maybe, we're doing some meta programming magic to hook into require: https://github.com/schneems/derailed_benchmarks/blob/master/lib/derailed_benchmarks/core_ext/kernel_require.rb |
Just realized that require code I linked doesn't get called with
|
So the actual code generating this information is
Where line 81 is: https://github.com/skylightio/skylight-ruby/blob/v0.8.0/lib/skylight/probes.rb#L81. So basically the issue is just that technically, a bunch of the |
It's worth noting that, if I take this line out, I end up with the following at the top:
This then points to a place where Rails overwrites the |
To provide further detail, one can see the line where the "source file" is being obtained here: |
This appears to be a bug in Ruby, see https://bugs.ruby-lang.org/issues/11490 |
Anyhow, I should also point out that all of these allocation/memory usage analysis are describing what happens at load-time (when your app boots). While this is a useful information to know, it doesn't actually directly affect your runtime performance and is completely different from what the blog post describes (and what Skylight tells you about). |
@chancancode Thanks for the script and the bug report to Ruby. It does look like this is an issue with Ruby's It's still strange I wasn't able to see this behavior in codetriage. |
@schneems I think the top line (activesupport/lib) is still "wrong", it probably points to the AS dependencies line Peter mentioned? There seems to be more to this bug, because both the Skylight patch and the Rails patch are most likely calling another Ruby-land implementation of |
In my personal experience, |
@wagenet it's definitely designed to track the source of the allocations (so that you can fix them like Richard did) by taking a snapshot of the information at allocation time (which is why it's slow and you probably won't want to run it in production, I think objspace advise against that). It actually does this successfully most of the time if you look at the output part of my gist (especially if it's actually allocated in Ruby-land) |
After further investigation, I've determined that the blame falls on the file that calls the built-in |
@schneems I think this means that both |
@wagenet Generally speaking, @schneems originally used it to discover require-time garbage that was not associated with code structures, which is pretty useful! The fact that the VM junk is incorrectly attributed to Skylight (or ActiveSupport, or Rubygems) is an issue, but so is counting VM junk in the first place, which makes |
I wasn't intending to imply that derailed and memory_profiler weren't useful overall, just that it the usefulness is limited in this specific situation. I didn't state that clearly enough. |
According to http://blog.skylight.io/announcing-memory-traces/:
However I found that
skylight
gem itself allocates a lot of objects. 75 times more thannewrelic_rpm
.Are you going to reduce the amount of allocated objects or it's considered not a problem?
The text was updated successfully, but these errors were encountered: