-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Fix rb_profile_frame_classpath to handle module singletons #3084
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
Fix rb_profile_frame_classpath to handle module singletons #3084
Conversation
Also I can tell that it's a problem at least since Ruby 2.5, maybe older but there's not point backporting that far back. |
Might relate to #2949 / https://bugs.ruby-lang.org/issues/15608. |
Not sure. What you suggest sounds like a feature request (which I can agree of), whereas here I'm fixing a fairly obvious bug. I think the PR is non-controversial, so it has a good chance to be accepted and backported quickly. Your suggestion need much more consensus. |
This looks good to me, but we should probably add tests for the behavior of anonymous modules and classes too. |
Right now `SomeClass.method` is properly named, but `SomeModule.method` is displayed as `#<Module:0x000055eb5d95adc8>.method` which makes profiling annoying.
4b96fdf
to
e99448b
Compare
@tenderlove done. I added an anonymous module method in the stack. |
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.
seems nice.
Thanks @tenderlove! Can one of you mark it as needing to be backported in https://bugs.ruby-lang.org/issues/16834 ? Would be nice to have this fix is the next minor versions. |
@casperisfine I'll file a ticket to request a back port |
@tenderlove but it's already filed, isn't it? It simply need to have the |
Ah yes, sorry! 🙇 |
…unctions to 2.6 ruby/ruby#3084 fixed the name returned for `qualified_method_name` for module functions, but this fix was never added to 2.6. By backporting the fix to 2.6, the test below now works for 2.6 as well: ``` 1) Backtracie.backtrace_locations when sampling a module_function on a module is expected to eq "ModuleWithFunction.test_function" Failure/Error: expect(backtracie_stack[2].qualified_method_name).to eq "ModuleWithFunction.test_function" expected: "ModuleWithFunction.test_function" got: "#<Module:0x000055fa25b00570>.test_function" (compared using ==) # ./spec/unit/backtracie_spec.rb:301:in `block (4 levels) in <top (required)>' ```
Ruby issue: https://bugs.ruby-lang.org/issues/16834
Right now
SomeClass.method
is properly named, butSomeModule.method
is displayed as
#<Module:0x000055eb5d95adc8>.method
which makesprofiling annoying.
This particularly impact StackProf.
cc @tenderlove @XrXr