Skip to content

Commit b27f0e4

Browse files
committed
Add background profiling feature to executors that are missing it.
1 parent e79cdb8 commit b27f0e4

File tree

14 files changed

+340
-309
lines changed

14 files changed

+340
-309
lines changed

.pipelines/azure-pipelines-linux.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ resources:
1616
options: --entrypoint=""
1717

1818
variables:
19-
VcVersion : 1.11.6
19+
VcVersion : 1.11.7
2020
ROOT: $(Build.SourcesDirectory)
2121
CDP_DEFINITION_BUILD_COUNT: $[counter('', 0)] # needed for onebranch.pipeline.version task https://aka.ms/obpipelines/versioning
2222
ENABLE_PRS_DELAYSIGN: 1
@@ -42,7 +42,7 @@ stages:
4242
displayName: 'Allow scripts to be executable on Linux'
4343

4444
# Ensure the artifact output/bin/obj directories are clean.
45-
# - script: $(Build.SourcesDirectory)/clean.cmd
45+
# - script: $(Build.SourcesDirectory)/clean.cmd
4646
# displayName: 'Clean Output Directories'
4747

4848
# Build the repo.

.pipelines/azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pool:
1818
vmImage: windows-latest
1919

2020
variables:
21-
VcVersion : 1.11.6
21+
VcVersion : 1.11.7
2222
ROOT: $(Build.SourcesDirectory)
2323
CDP_DEFINITION_BUILD_COUNT: $[counter('', 0)] # needed for onebranch.pipeline.version task https://aka.ms/obpipelines/versioning
2424
ENABLE_PRS_DELAYSIGN: 1

src/VirtualClient/VirtualClient.Actions/3DMark/ThreeDMarkExecutor.cs

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -244,65 +244,68 @@ private Task ExecuteWorkloadAsync(EventContext telemetryContext, CancellationTok
244244
}
245245
}
246246

247-
// Run Workload
248247
DateTime startTime = DateTime.UtcNow;
249-
foreach (string definition in this.Definitions)
248+
using (BackgroundOperations profiling = BackgroundOperations.BeginProfiling(this, cancellationToken))
250249
{
251-
this.OutFileName = $"{DateTimeOffset.Now.ToUnixTimeSeconds()}.out";
252-
253-
// Workload execution
254-
string arguments = this.GenerateCommandArguments(definition);
255-
string commandArguments = $"{baseArg} {this.ExecutablePath} {arguments}";
256-
257-
using (IProcessProxy process = this.systemManagement.ProcessManager.CreateProcess(psexec, commandArguments, this.psexecDir))
250+
// Run Workload
251+
foreach (string definition in this.Definitions)
258252
{
259-
this.CleanupTasks.Add(() => process.SafeKill());
253+
this.OutFileName = $"{DateTimeOffset.Now.ToUnixTimeSeconds()}.out";
254+
255+
// Workload execution
256+
string arguments = this.GenerateCommandArguments(definition);
257+
string commandArguments = $"{baseArg} {this.ExecutablePath} {arguments}";
260258

261-
try
259+
using (IProcessProxy process = this.systemManagement.ProcessManager.CreateProcess(psexec, commandArguments, this.psexecDir))
262260
{
263-
await process.StartAndWaitAsync(cancellationToken).ConfigureAwait(false);
261+
this.CleanupTasks.Add(() => process.SafeKill());
264262

265-
if (!cancellationToken.IsCancellationRequested)
263+
try
266264
{
267-
await this.LogProcessDetailsAsync(process, telemetryContext);
268-
process.ThrowIfErrored<WorkloadException>(ProcessProxy.DefaultSuccessCodes, errorReason: ErrorReason.WorkloadFailed);
265+
await process.StartAndWaitAsync(cancellationToken).ConfigureAwait(false);
266+
267+
if (!cancellationToken.IsCancellationRequested)
268+
{
269+
await this.LogProcessDetailsAsync(process, telemetryContext);
270+
process.ThrowIfErrored<WorkloadException>(ProcessProxy.DefaultSuccessCodes, errorReason: ErrorReason.WorkloadFailed);
269271

272+
}
270273
}
271-
}
272-
finally
273-
{
274-
if (!process.HasExited)
274+
finally
275275
{
276-
process.Kill();
276+
if (!process.HasExited)
277+
{
278+
process.Kill();
279+
}
277280
}
278281
}
279-
}
280282

281-
// Result Preparation
282-
string commandArguments2 = $"{baseArg} {this.ExecutablePath} --in={this.OutFileName} --export=result.xml";
283-
using (IProcessProxy process = this.systemManagement.ProcessManager.CreateProcess(psexec, commandArguments2, this.psexecDir))
284-
{
285-
this.CleanupTasks.Add(() => process.SafeKill());
286-
287-
try
283+
// Result Preparation
284+
string commandArguments2 = $"{baseArg} {this.ExecutablePath} --in={this.OutFileName} --export=result.xml";
285+
using (IProcessProxy process = this.systemManagement.ProcessManager.CreateProcess(psexec, commandArguments2, this.psexecDir))
288286
{
289-
await process.StartAndWaitAsync(cancellationToken).ConfigureAwait(false);
287+
this.CleanupTasks.Add(() => process.SafeKill());
290288

291-
if (!cancellationToken.IsCancellationRequested)
289+
try
292290
{
293-
await this.LogProcessDetailsAsync(process, telemetryContext);
294-
process.ThrowIfErrored<WorkloadException>(ProcessProxy.DefaultSuccessCodes, errorReason: ErrorReason.WorkloadFailed);
295-
foreach (Metric metric in this.CaptureResults(process, commandArguments, definition, telemetryContext))
291+
await process.StartAndWaitAsync(cancellationToken).ConfigureAwait(false);
292+
293+
if (!cancellationToken.IsCancellationRequested)
296294
{
297-
metrics.Add(metric);
295+
await this.LogProcessDetailsAsync(process, telemetryContext);
296+
process.ThrowIfErrored<WorkloadException>(ProcessProxy.DefaultSuccessCodes, errorReason: ErrorReason.WorkloadFailed);
297+
foreach (Metric metric in this.CaptureResults(process, commandArguments, definition, telemetryContext))
298+
{
299+
metrics.Add(metric);
300+
}
298301
}
299302
}
300-
}
301-
finally
302-
{
303-
if (!process.HasExited)
303+
finally
304304
{
305-
process.Kill();
305+
if (!process.HasExited)
306+
{
307+
process.Kill();
308+
}
306309
}
307310
}
308311
}

src/VirtualClient/VirtualClient.Actions/CoreMark/CoreMarkProExecutor.cs

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -100,46 +100,49 @@ protected override async Task ExecuteAsync(EventContext telemetryContext, Cancel
100100
DateTime startTime = DateTime.UtcNow;
101101
string output = string.Empty;
102102

103-
switch (this.Platform)
103+
using (BackgroundOperations profiling = BackgroundOperations.BeginProfiling(this, cancellationToken))
104104
{
105-
case PlatformID.Unix:
106-
using (IProcessProxy process = await this.ExecuteCommandAsync("make", commandArguments, this.CoreMarkProDirectory, telemetryContext, cancellationToken))
107-
{
108-
if (!cancellationToken.IsCancellationRequested)
105+
switch (this.Platform)
106+
{
107+
case PlatformID.Unix:
108+
using (IProcessProxy process = await this.ExecuteCommandAsync("make", commandArguments, this.CoreMarkProDirectory, telemetryContext, cancellationToken))
109109
{
110-
if (process.IsErrored())
110+
if (!cancellationToken.IsCancellationRequested)
111111
{
112+
if (process.IsErrored())
113+
{
114+
await this.LogProcessDetailsAsync(process, telemetryContext, "CoreMark Pro", logToFile: true);
115+
process.ThrowIfWorkloadFailed();
116+
}
117+
112118
await this.LogProcessDetailsAsync(process, telemetryContext, "CoreMark Pro", logToFile: true);
113-
process.ThrowIfWorkloadFailed();
119+
output = process.StandardOutput.ToString();
114120
}
115-
116-
await this.LogProcessDetailsAsync(process, telemetryContext, "CoreMark Pro", logToFile: true);
117-
output = process.StandardOutput.ToString();
118121
}
119-
}
120122

121-
break;
123+
break;
122124

123-
case PlatformID.Win32NT:
124-
DependencyPath cygwinPackage = await this.packageManager.GetPackageAsync("cygwin", CancellationToken.None)
125-
.ConfigureAwait(false);
125+
case PlatformID.Win32NT:
126+
DependencyPath cygwinPackage = await this.packageManager.GetPackageAsync("cygwin", CancellationToken.None)
127+
.ConfigureAwait(false);
126128

127-
using (IProcessProxy process = await this.ExecuteCygwinBashAsync($"make {commandArguments}", this.CoreMarkProDirectory, cygwinPackage.Path, telemetryContext, cancellationToken))
128-
{
129-
if (!cancellationToken.IsCancellationRequested)
129+
using (IProcessProxy process = await this.ExecuteCygwinBashAsync($"make {commandArguments}", this.CoreMarkProDirectory, cygwinPackage.Path, telemetryContext, cancellationToken))
130130
{
131-
if (process.IsErrored())
131+
if (!cancellationToken.IsCancellationRequested)
132132
{
133+
if (process.IsErrored())
134+
{
135+
await this.LogProcessDetailsAsync(process, telemetryContext, "CoreMark Pro", logToFile: true);
136+
process.ThrowIfWorkloadFailed();
137+
}
138+
133139
await this.LogProcessDetailsAsync(process, telemetryContext, "CoreMark Pro", logToFile: true);
134-
process.ThrowIfWorkloadFailed();
140+
output = process.StandardOutput.ToString();
135141
}
136-
137-
await this.LogProcessDetailsAsync(process, telemetryContext, "CoreMark Pro", logToFile: true);
138-
output = process.StandardOutput.ToString();
139142
}
140-
}
141143

142-
break;
144+
break;
145+
}
143146
}
144147

145148
this.MetadataContract.AddForScenario(

0 commit comments

Comments
 (0)