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

Make scheduler dumps best-effort #10642

Merged
merged 1 commit into from
Sep 11, 2024
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
44 changes: 34 additions & 10 deletions src/Build/BackEnd/Components/Scheduler/Scheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2565,13 +2565,19 @@ private void TraceScheduler(string format, params object[] stuff)
{
if (_debugDumpState)
{
FileUtilities.EnsureDirectoryExists(_debugDumpPath);
try
{
FileUtilities.EnsureDirectoryExists(_debugDumpPath);

StreamWriter file = FileUtilities.OpenWrite(String.Format(CultureInfo.CurrentCulture, Path.Combine(_debugDumpPath, "SchedulerTrace_{0}.txt"), Process.GetCurrentProcess().Id), append: true);
file.Write("{0}({1})-{2}: ", Thread.CurrentThread.Name, Thread.CurrentThread.ManagedThreadId, _schedulingData.EventTime.Ticks);
file.WriteLine(format, stuff);
file.Flush();
file.Dispose();
using StreamWriter file = FileUtilities.OpenWrite(String.Format(CultureInfo.CurrentCulture, Path.Combine(_debugDumpPath, "SchedulerTrace_{0}.txt"), Process.GetCurrentProcess().Id), append: true);
file.Write("{0}({1})-{2}: ", Thread.CurrentThread.Name, Thread.CurrentThread.ManagedThreadId, _schedulingData.EventTime.Ticks);
file.WriteLine(format, stuff);
file.Flush();
}
catch (Exception e) when (!ExceptionHandling.IsCriticalException(e))
{
// Ignore exceptions
}
}
}

Expand All @@ -2584,9 +2590,11 @@ private void DumpSchedulerState()
{
if (_schedulingData != null)
{
FileUtilities.EnsureDirectoryExists(_debugDumpPath);
using (StreamWriter file = FileUtilities.OpenWrite(String.Format(CultureInfo.CurrentCulture, Path.Combine(_debugDumpPath, "SchedulerState_{0}.txt"), Process.GetCurrentProcess().Id), append: true))
try
{
FileUtilities.EnsureDirectoryExists(_debugDumpPath);
using StreamWriter file = FileUtilities.OpenWrite(String.Format(CultureInfo.CurrentCulture, Path.Combine(_debugDumpPath, "SchedulerState_{0}.txt"), Process.GetCurrentProcess().Id), append: true);

file.WriteLine("Scheduler state at timestamp {0}:", _schedulingData.EventTime.Ticks);
file.WriteLine("------------------------------------------------");

Expand Down Expand Up @@ -2680,6 +2688,10 @@ private void DumpSchedulerState()

file.WriteLine();
}
catch (Exception e) when (!ExceptionHandling.IsCriticalException(e))
{
// Ignore exceptions
}
}
}
}
Expand All @@ -2693,8 +2705,10 @@ private void DumpConfigurations()
{
if (_schedulingData != null)
{
using (StreamWriter file = FileUtilities.OpenWrite(String.Format(CultureInfo.CurrentCulture, Path.Combine(_debugDumpPath, "SchedulerState_{0}.txt"), Process.GetCurrentProcess().Id), append: true))
try
{
using StreamWriter file = FileUtilities.OpenWrite(String.Format(CultureInfo.CurrentCulture, Path.Combine(_debugDumpPath, "SchedulerState_{0}.txt"), Process.GetCurrentProcess().Id), append: true);

file.WriteLine("Configurations used during this build");
file.WriteLine("-------------------------------------");

Expand All @@ -2714,6 +2728,10 @@ private void DumpConfigurations()

file.Flush();
}
catch (Exception e) when (!ExceptionHandling.IsCriticalException(e))
{
// Ignore exceptions
}
}
}
}
Expand All @@ -2727,14 +2745,20 @@ private void DumpRequests()
{
if (_schedulingData != null)
{
using (StreamWriter file = FileUtilities.OpenWrite(String.Format(CultureInfo.CurrentCulture, Path.Combine(_debugDumpPath, "SchedulerState_{0}.txt"), Process.GetCurrentProcess().Id), append: true))
try
{
using StreamWriter file = FileUtilities.OpenWrite(String.Format(CultureInfo.CurrentCulture, Path.Combine(_debugDumpPath, "SchedulerState_{0}.txt"), Process.GetCurrentProcess().Id), append: true);

file.WriteLine("Requests used during the build:");
file.WriteLine("-------------------------------");
file.WriteLine("Format: GlobalRequestId: [NodeId] FinalState (ConfigId) Path (Targets)");
DumpRequestHierarchy(file, null, 0);
file.Flush();
}
catch (Exception e) when (!ExceptionHandling.IsCriticalException(e))
{
// Ignore exceptions
}
}
}
}
Expand Down