Skip to content
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

[release/7.0-staging][wasm][debugger] Improve debugger performance #88602

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 33 additions & 38 deletions src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1475,61 +1475,56 @@ public IEnumerable<SourceFile> Add(SessionId id, string name, byte[] assembly_da
}
}

public async IAsyncEnumerable<SourceFile> Load(SessionId id, string[] loaded_files, ExecutionContext context, bool useDebuggerProtocol, [EnumeratorCancellation] CancellationToken token)
public async IAsyncEnumerable<SourceFile> Load(SessionId id, string[] loaded_files, ExecutionContext context, bool tryUseDebuggerProtocol, [EnumeratorCancellation] CancellationToken token)
{
var asm_files = new List<string>();
List<DebugItem> steps = new List<DebugItem>();

if (!useDebuggerProtocol)
var pdb_files = new List<string>();
foreach (string file_name in loaded_files)
{
var pdb_files = new List<string>();
foreach (string file_name in loaded_files)
{
if (file_name.EndsWith(".pdb", StringComparison.OrdinalIgnoreCase))
pdb_files.Add(file_name);
else
asm_files.Add(file_name);
}
if (file_name.EndsWith(".pdb", StringComparison.OrdinalIgnoreCase))
pdb_files.Add(file_name);
else
asm_files.Add(file_name);
}

foreach (string url in asm_files)
foreach (string url in asm_files)
{
try
{
try
{
string candidate_pdb = Path.ChangeExtension(url, "pdb");
string pdb = pdb_files.FirstOrDefault(n => n == candidate_pdb);
string candidate_pdb = Path.ChangeExtension(url, "pdb");
string pdb = pdb_files.FirstOrDefault(n => n == candidate_pdb);

steps.Add(
new DebugItem
{
Url = url,
Data = Task.WhenAll(MonoProxy.HttpClient.GetByteArrayAsync(url, token), pdb != null ? MonoProxy.HttpClient.GetByteArrayAsync(pdb, token) : Task.FromResult<byte[]>(null))
});
}
catch (Exception e)
{
logger.LogDebug($"Failed to read {url} ({e.Message})");
}
steps.Add(
new DebugItem
{
Url = url,
Data = Task.WhenAll(MonoProxy.HttpClient.GetByteArrayAsync(url, token), pdb != null ? MonoProxy.HttpClient.GetByteArrayAsync(pdb, token) : Task.FromResult<byte[]>(null))
});
}
}
else
{
foreach (string file_name in loaded_files)
catch (Exception e)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we check for more specific exception type(s)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, the retry should be if either of the two tasks fail, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should it logger.LogDebug if it goes down this new path?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont't think so, only if it fails in the retry process too, or if tryUseDebuggerProtocol is disabled.

{
if (file_name.EndsWith(".pdb", StringComparison.OrdinalIgnoreCase))
continue;
try
if (tryUseDebuggerProtocol)
{
string unescapedFileName = Uri.UnescapeDataString(file_name);
steps.Add(
try
{
string unescapedFileName = Uri.UnescapeDataString(url);
steps.Add(
new DebugItem
{
Url = file_name,
Url = url,
Data = context.SdbAgent.GetBytesFromAssemblyAndPdb(Path.GetFileName(unescapedFileName), token)
});
}
catch (Exception ex)
{
logger.LogDebug($"Failed to get bytes using debugger protocol {url} ({ex.Message})");
}
}
catch (Exception e)
else
{
logger.LogDebug($"Failed to read {file_name} ({e.Message})");
logger.LogDebug($"Failed to read {url} ({e.Message})");
}
}
}
Expand Down
Loading