Skip to content

Commit

Permalink
Stream progress summary
Browse files Browse the repository at this point in the history
  • Loading branch information
MihaZupan committed Jun 20, 2024
1 parent 1269bae commit 1b1523e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
12 changes: 12 additions & 0 deletions Runner/BenchmarkLibrariesJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ await RunProcessAsync("dotnet",
artifactsDir = dir;
}
// ** Remained 420 (74.5 %) benchmark(s) to run. Estimated finish 2024-06-20 2:54 (0h 40m from now) **
if (line.Contains("benchmark(s) to run. Estimated finish", StringComparison.Ordinal) &&
BdnProgressSummaryRegex().Match(line) is { Success: true } match)
{
LastProgressSummary = $"{match.Groups[1].ValueSpan} ({match.Groups[2].ValueSpan} %) benchmarks remain. Estimated time: {match.Groups[3].ValueSpan}";
}
return line;
});

Expand Down Expand Up @@ -172,4 +179,9 @@ await RunProcessAsync("dotnet",

[GeneratedRegex(@"^benchmark ([^ ]+)", RegexOptions.IgnoreCase | RegexOptions.Singleline)]
private static partial Regex FilterNameRegex();

// ** Remained 420 (74.5 %) benchmark(s) to run. Estimated finish 2024-06-20 2:54 (0h 40m from now) **
// 420 74.5 0h 40m
[GeneratedRegex(@"Remained (\d+) \((.*?) %\).*?\(([\dhms ]+) from", RegexOptions.IgnoreCase | RegexOptions.Singleline)]
private static partial Regex BdnProgressSummaryRegex();
}
8 changes: 5 additions & 3 deletions Runner/JobBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public abstract class JobBase
public Dictionary<string, string> Metadata { get; }
public readonly string OriginalWorkingDirectory = Environment.CurrentDirectory;

public string LastProgressSummary { get; set; }

protected readonly ConcurrentQueue<Task> PendingTasks = new();

public string CustomArguments => Metadata["CustomArguments"];
Expand Down Expand Up @@ -383,14 +385,14 @@ protected async Task UploadArtifactAsync(string path, string? fileName = null)
JobTimeout);
}

private async Task PostAsJsonAsync(string path, object? value, int attemptsRemaining = 4)
private async Task PostAsJsonAsync(string path, object? value, string? queryArgs = null, int attemptsRemaining = 4)
{
int delayMs = 1_000;
while (true)
{
try
{
using var response = await _client.PostAsJsonAsync($"{path}/{_jobId}", value, JobTimeout);
using var response = await _client.PostAsJsonAsync($"{path}/{_jobId}{queryArgs}", value, JobTimeout);

if (response.Headers.Contains("X-Job-Completed"))
{
Expand Down Expand Up @@ -527,7 +529,7 @@ private async Task StreamSystemHardwareInfoAsync()
CpuCoresAvailable = coreCount,
MemoryUsageGB = usedGB,
MemoryAvailableGB = totalGB,
});
}, LastProgressSummary is { } summary ? $"?progressSummary={Uri.EscapeDataString(summary)}" : null);
}

if (failureMessages == 0 && usageHistory.Count > 0)
Expand Down

0 comments on commit 1b1523e

Please sign in to comment.