-
Notifications
You must be signed in to change notification settings - Fork 127
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
Improve method breakpoint performance. #703
Conversation
lib/debug/session.rb
Outdated
def singleton_method_added mid; end | ||
end | ||
|
||
def self.method_added_tracekr_create mod, method_added_id, method_accessor = :method |
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.
Should this be method_added_tracker_create
instead?
lib/debug/session.rb
Outdated
end | ||
end | ||
|
||
def self.method_added_tracekr_activate |
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.
method_added_tracker_activate
?
I'd also recommend putting the verb activate
in front of the method. So it'd be activate_method_added_tracker
.
lib/debug/session.rb
Outdated
end | ||
end | ||
|
||
def self.method_added_tracekr_deactivate |
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.
method_added_tracker_deactivate
?
With pending method breakpoints, track all method invocation to track `method_added` and `singleton_method_added`. Of course, this approach slows down the debuggee's performance. This patch tracks all `method_added` and `singleton_method_added` methods and further defined such methods for the classes/modules. This approach doesn't have performance penalty any more. This patch also fix the message at registering the pending method breakpoint. ```ruby binding.b do: 'b C#foo' unless ENV['NO_PENDING_BP'] def fib n if n<2 n else fib(n-1)+fib(n-2) end end require 'benchmark' Benchmark.bm{|x| x.report{ fib(35) } } ``` Results: ``` Without pending breakpoints: $ NO_PENDING_BP=1 exe/rdbg -n target.rb user system total real 0.929580 0.000000 0.929580 ( 0.929682) With pending breakpoints - Before this patch: $ exe/rdbg -n target.rb [1, 10] in target.rb => 1| binding.b do: <<~DBG 2| b C#foo 3| DBG 4| 5| def fib n 6| if n<2 7| n 8| else 9| fib(n-1)+fib(n-2) 10| end =>#0 <main> at target.rb:1 (rdbg:binding.break) b C#foo uninitialized constant C C ^ user system total real 3.276217 0.000000 3.276217 ( 3.276299) With pending breakpoints - After this patch: [master]$ exe/rdbg -n target.rb [1, 10] in target.rb => 1| binding.b do: <<~DBG 2| b C#foo 3| DBG 4| 5| def fib n 6| if n<2 7| n 8| else 9| fib(n-1)+fib(n-2) 10| end =>#0 <main> at target.rb:1 (rdbg:binding.break) b C#foo Unknown name `C` for `Object` user system total real 0.933402 0.002353 0.935755 ( 0.935757) ```
319cd2e
to
c390872
Compare
Thank you for the typo report. I fixed it.
The name |
It's not confusing. But in English we usually say |
With pending method breakpoints, track all method invocation to track
method_added
andsingleton_method_added
.Of course, this approach slows down the debuggee's performance.
This patch tracks all
method_added
andsingleton_method_added
methodsand further defined such methods for the classes/modules. This approach
doesn't have performance penalty any more.
This patch also fix the message at registering the pending method
breakpoint.
Results: