-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Fix dap stacktrace perf issue #104874
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 dap stacktrace perf issue #104874
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -701,6 +701,8 @@ void request_attach(const llvm::json::Object &request) { | |
GetBoolean(arguments, "enableAutoVariableSummaries", false); | ||
g_dap.enable_synthetic_child_debugging = | ||
GetBoolean(arguments, "enableSyntheticChildDebugging", false); | ||
g_dap.enable_display_extended_backtrace = | ||
GetBoolean(arguments, "enableDisplayExtendedBacktrace", false); | ||
g_dap.command_escape_prefix = | ||
GetString(arguments, "commandEscapePrefix", "`"); | ||
g_dap.SetFrameFormat(GetString(arguments, "customFrameFormat")); | ||
|
@@ -1925,6 +1927,8 @@ void request_launch(const llvm::json::Object &request) { | |
GetBoolean(arguments, "enableAutoVariableSummaries", false); | ||
g_dap.enable_synthetic_child_debugging = | ||
GetBoolean(arguments, "enableSyntheticChildDebugging", false); | ||
g_dap.enable_display_extended_backtrace = | ||
GetBoolean(arguments, "enableDisplayExtendedBacktrace", false); | ||
g_dap.command_escape_prefix = | ||
GetString(arguments, "commandEscapePrefix", "`"); | ||
g_dap.SetFrameFormat(GetString(arguments, "customFrameFormat")); | ||
|
@@ -3111,17 +3115,20 @@ void request_stackTrace(const llvm::json::Object &request) { | |
// This will always return an invalid thread when | ||
// libBacktraceRecording.dylib is not loaded or if there is no extended | ||
// backtrace. | ||
lldb::SBThread queue_backtrace_thread = | ||
thread.GetExtendedBacktraceThread("libdispatch"); | ||
lldb::SBThread queue_backtrace_thread; | ||
if (g_dap.enable_display_extended_backtrace) | ||
queue_backtrace_thread = thread.GetExtendedBacktraceThread("libdispatch"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should check SBProcess::GetNumExtendedBacktraceTypes() / GetExtendedBacktraceTypeAtIndex() instead of hard coding the Would that solve the issue without needing an extra configuration flag? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still will want the option to disable this feature if it is coslty and not everyone needs it. But if all non mac platforms report "SBProcess::GetNumExtendedBacktraceTypes() == 0", then this can be a good work around. If we call this on mac, does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Running an expression every time we stop is not a great thing to do and this is what is happening right now. Are we running one expression for every thread? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According the Jeffrey's profiling, the penalty is up to 1 second in certain targets. I think that's a very reasonable wait time if that can improve the debugger experience, as long as it happens once per user action only in the cases where there's an extended backtrace via There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ashgti, if you look at the profile trace, the hot path does not come from this call ( |
||
if (queue_backtrace_thread.IsValid()) { | ||
// One extra frame as a label to mark the enqueued thread. | ||
totalFrames += queue_backtrace_thread.GetNumFrames() + 1; | ||
} | ||
|
||
// This will always return an invalid thread when there is no exception in | ||
// the current thread. | ||
lldb::SBThread exception_backtrace_thread = | ||
thread.GetCurrentExceptionBacktrace(); | ||
lldb::SBThread exception_backtrace_thread; | ||
if (g_dap.enable_display_extended_backtrace) | ||
exception_backtrace_thread = thread.GetCurrentExceptionBacktrace(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should remove this from the stack trace and add this info to the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems like a better option. What do you think @jeffreytan81 ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This sounds good to me. @ashgti, feel free to create a PR on top of this one to remove the hot path out of regular stepping code path. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that you are on this, why don't you give it a try, @jeffreytan81 ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't have time to work on this. My goal is to quickly fix the performance regression and unblock the business. Frankly, the original PR should have been reverted initially, as it introduced the regression. The reasonable engineering process should involve landing this PR to disable the performance regression. Then, the author of the original PR can fix it in the desired way. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤷 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not understand why you are judging people. Everyone has their own priority and focus. I am doing a favor here to fix a serious performance regression for the community. Please be respectful in communication. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can take a look at moving this into the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Expression evaluation can also take longer than 1 second depending on the amount of total debug info and if there are accelerator tables. |
||
|
||
if (exception_backtrace_thread.IsValid()) { | ||
// One extra frame as a label to mark the exception thread. | ||
totalFrames += exception_backtrace_thread.GetNumFrames() + 1; | ||
|
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.
don't you also need this for request_launch?