-
Notifications
You must be signed in to change notification settings - Fork 605
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
DTrace/SystemTap object allocation hooks, method cache reset hooks and some housekeeping #3214
Conversation
This currently only traces classes allocated in the Ruby side of things. String, Array and other allocations are not yet tracked.
For whatever reason this will either 1) report file names as method names 2) crash once in a while. Either way, it's a start.
This means that instead of doing const_cast<RBX_DTRACE_CONST char*> you can write const_cast<RBX_DTRACE_CHAR>.
Worth noting: in 1df5a70 I mentioned that the probe might sometimes crash Rubinius. I haven't really experienced it lately and I don't really remember if it was related in the first place (e.g. it could've been an unrelated crash). |
In general, it's good to separate clean up like As for the additional hooks, I don't want to add these yet because allocation is going to change significantly and I'd rather not add an API that we're going to immediately change. |
What's the timeline for the allocation process changing? Is this something that will happen within the new few weeks, or are we walking about multiple months from now? |
@yorickpeterse very soon, it's a critical building block for a bunch of 3.0 stuff. |
@brixen Fair enough. For the DTrace char macro, do you first want to further review it or can I just yank that into master right away? |
The const char * stuff has been extracted into commit 7da4c6d. I'll close this PR due to the upcoming changes regarding allocations, once those are in place can revise adding extra dtrace/systemtap hooks. |
NOTE: This pull-request is still a work in progress, I'm creating it to get some early feedback.
This pull-request adds the following:
RBX_DTRACE_CONST char*
with justRBX_DTRACE_CHAR
The first item is the most interesting: it allows you to trace allocations using the "object__allocate" probe. For example (this is a SystemTap script):
This would count the amount of object allocations per class and file and display the results upon exiting SystemTap. While still in an early stage this has already proven useful in finding allocation patterns for #3205 .
Right now there are hooks for the following classes:
Array::allocate
is used)Class::allocate
)String::allocate
is used)The tricky part here, and this is something I'll need some feedback on, is to where exactly add the hooks. Some C++ classes have an
allocate
methods while others use acreate
method, sometimes even both. Ideally all allocated objects that are exposed to Ruby should be traceable using these hooks. Because I'm not really sure where exactly to add the hooks I've so far only added them to the classes noted above.The second thing changes is the introduction of
RBX_DTRACE_CHAR
. This is mostly a cleanup thing. I got tired of having to typeRBX_DTRACE_CONST char*
all the time, thus I introduced this little macro.Last, I added a hook for tracing method cache resets. This is pretty self-explanatory, the probe is called
method__cache__reset
.