Skip to content

Commit

Permalink
Adding LAT_RD_MEM profile
Browse files Browse the repository at this point in the history
  • Loading branch information
DEVAID-MSFT committed Jan 6, 2025
1 parent e55b25f commit c12a32c
Show file tree
Hide file tree
Showing 4 changed files with 161 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@ public void LMbenchMetricsParserCapturesTheExpectedMetrics_1()
IList<Metric> metrics = parser.Parse();

Assert.IsTrue(metrics.Count == 54);
Assert.IsNotNull(metrics.FirstOrDefault(m => m.Name == "LatencyArraySizeInMB_0.00098" && m.Value == 1.438));
Assert.IsNotNull(metrics.FirstOrDefault(m => m.Name == "LatencyArraySizeInMB_0.01172" && m.Value == 1.438));
Assert.IsNotNull(metrics.FirstOrDefault(m => m.Name == "LatencyArraySizeInMB_64.00000" && m.Value == 4.545));
Assert.IsNotNull(metrics.FirstOrDefault(m => m.Name == "LatencyArraySizeInMB_128.00000" && m.Value == 2.537));
Assert.IsNotNull(metrics.FirstOrDefault(m => m.Name == "LatencyArraySizeInMB_48.00000" && m.Value == 1.831));
Assert.IsNotNull(metrics.FirstOrDefault(m => m.Name == "Latency_StrideBytes_64_Array_512_B" && m.Value == 1.438));
Assert.IsNotNull(metrics.FirstOrDefault(m => m.Name == "Latency_StrideBytes_64_Array_1_KiB" && m.Value == 1.438));
Assert.IsNotNull(metrics.FirstOrDefault(m => m.Name == "Latency_StrideBytes_32_Array_768_KiB" && m.Value == 1.506));
Assert.IsNotNull(metrics.FirstOrDefault(m => m.Name == "Latency_StrideBytes_32_Array_32_MiB" && m.Value == 1.612));
}
}
}
34 changes: 28 additions & 6 deletions src/VirtualClient/VirtualClient.Actions/LMbench/LMbenchExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace VirtualClient.Actions
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.Razor;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.Extensions.DependencyInjection;
using VirtualClient.Common;
using VirtualClient.Common.Extensions;
Expand Down Expand Up @@ -146,15 +147,36 @@ protected override async Task ExecuteAsync(EventContext telemetryContext, Cancel
{
await this.ExecuteWorkloadAsync(telemetryContext, cancellationToken);
}
else
else if (this.BinaryName.Equals("lat_mem_rd", StringComparison.OrdinalIgnoreCase))
{
using (IProcessProxy executeBinary = await this.ExecuteCommandAsync($"{this.BinaryName}", this.BinaryCommandLine, this.LMbenchPackage.Path, telemetryContext, cancellationToken))
string binaryPath = string.Empty;
if (this.Platform == PlatformID.Unix && this.CpuArchitecture == Architecture.X64)
{
binaryPath = this.PlatformSpecifics.Combine(this.LMbenchPackage.Path, "bin", "x86_64-Linux");
}
else if (this.Platform == PlatformID.Unix && this.CpuArchitecture == Architecture.Arm64)
{
await this.LogProcessDetailsAsync(executeBinary, telemetryContext);
executeBinary.ThrowIfErrored<WorkloadException>(ProcessProxy.DefaultSuccessCodes, errorReason: ErrorReason.WorkloadFailed);
LatMemRdMetricsParser latMemRdMetricsParser = new LatMemRdMetricsParser(executeBinary.StandardOutput.ToString());
this.CaptureMetrics(executeBinary, latMemRdMetricsParser, telemetryContext);
binaryPath = this.PlatformSpecifics.Combine(this.LMbenchPackage.Path, "bin", "aarch64-Linux");
}
else
{
this.Logger.LogNotSupported(this.BinaryName, this.Platform, this.CpuArchitecture, EventContext.Persisted());
}

if (!string.IsNullOrEmpty(binaryPath))
{
using (IProcessProxy executeBinary = await this.ExecuteCommandAsync(this.PlatformSpecifics.Combine(binaryPath, this.BinaryName), this.BinaryCommandLine, binaryPath, telemetryContext, cancellationToken))
{
await this.LogProcessDetailsAsync(executeBinary, telemetryContext);
executeBinary.ThrowIfErrored<WorkloadException>(ProcessProxy.DefaultSuccessCodes, errorReason: ErrorReason.WorkloadFailed);
LatMemRdMetricsParser latMemRdMetricsParser = new LatMemRdMetricsParser($"{executeBinary.StandardOutput.ToString()}{executeBinary.StandardError.ToString()}");
this.CaptureMetrics(executeBinary, latMemRdMetricsParser, telemetryContext);
}
}
}
else
{
this.Logger.LogMessage($"Unsupported {nameof(this.BinaryName)}: {this.BinaryName}, supported binarienames are : null(for sumarry),lat_rd_mem", telemetryContext);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class LatMemRdMetricsParser : MetricsParser
/// <summary>
/// Sectionize by one or more empty lines.
/// </summary>
private static readonly Regex LatMemRdSectionDelimiter = new Regex(@"(\r)(\n)(\s)*(\r)(\n)", RegexOptions.ExplicitCapture);
private static readonly Regex LatMemRdSectionDelimiter = new Regex(@$"({Environment.NewLine})(\s)*({Environment.NewLine})", RegexOptions.ExplicitCapture);

/// <summary>
/// Initializes a new instance of the <see cref="LatMemRdMetricsParser"/> class.
Expand All @@ -36,7 +36,7 @@ public override IList<Metric> Parse()
this.Sections = TextParsingExtensions.Sectionize(this.PreprocessedText, LatMemRdSectionDelimiter);
foreach (var section in this.Sections)
{
var lines = section.Value.Split("\r\n");
var lines = section.Value.Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);
foreach (var line in lines)
{
var values = line.Split(' ');
Expand All @@ -56,14 +56,8 @@ public override IList<Metric> Parse()
/// <inheritdoc/>
protected override void Preprocess()
{
// Converting all CRLF(Windows EOL) to LF(Unix EOL).
this.PreprocessedText = Regex.Replace(this.RawText, "\r\n", "\n");

// Converting all LF to CRLF.
this.PreprocessedText = Regex.Replace(this.PreprocessedText, "\n", "\r\n");

// Removing unnecessary starting and ending space.
this.PreprocessedText = this.PreprocessedText.Trim();
this.PreprocessedText = this.RawText.Trim();
}

private long RoundOffToNearest512Multiple(double number)
Expand Down
126 changes: 126 additions & 0 deletions src/VirtualClient/VirtualClient.Main/profiles/PERF-MEM-LATRDMEM.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
{
"Description": "LMbench Performance Workload",
"MinimumExecutionInterval": "00:01:00",
"Metadata": {
"RecommendedMinimumExecutionTime": "(4-cores)=04:00:00,(16-cores)=10:00:00,(64-cores)=16:00:00",
"SupportedPlatforms": "linux-x64,linux-arm64",
"SupportedOperatingSystems": "CBL-Mariner,CentOS,Debian,RedHat,Suse,Ubuntu",
"Notes_Runtime": "The benchmark takes approximately 6 to 8 minutes per 1 GB of RAM targeted. The default profile uses 25% of the total RAM."
},
"Parameters": {
"CompilerName": "gcc",
"CompilerVersion": "10",
"CompilerFlags": "CPPFLAGS=\"-I /usr/include/tirpc\""
},
"Actions": [
{
"Type": "LMbenchExecutor",
"Parameters": {
"Scenario": "LatMemRd_Array_4096MB_Stride_8B",
"PackageName": "lmbench",
"CompilerFlags": "$.Parameters.CompilerFlags",
"BinaryName": "lat_mem_rd",
"BinaryCommandLine": "4096 8"
}
},
{
"Type": "LMbenchExecutor",
"Parameters": {
"Scenario": "LatMemRd_Array_4096MB_Stride_16B",
"PackageName": "lmbench",
"CompilerFlags": "$.Parameters.CompilerFlags",
"BinaryName": "lat_mem_rd",
"BinaryCommandLine": "4096 16"
}
},
{
"Type": "LMbenchExecutor",
"Parameters": {
"Scenario": "LatMemRd_Array_4096MB_Stride_32B",
"PackageName": "lmbench",
"CompilerFlags": "$.Parameters.CompilerFlags",
"BinaryName": "lat_mem_rd",
"BinaryCommandLine": "4096 32"
}
},
{
"Type": "LMbenchExecutor",
"Parameters": {
"Scenario": "LatMemRd_Array_4096MB_Stride_64B",
"PackageName": "lmbench",
"CompilerFlags": "$.Parameters.CompilerFlags",
"BinaryName": "lat_mem_rd",
"BinaryCommandLine": "4096 64"
}
},
{
"Type": "LMbenchExecutor",
"Parameters": {
"Scenario": "LatMemRd_Array_4096MB_Stride_128B",
"PackageName": "lmbench",
"CompilerFlags": "$.Parameters.CompilerFlags",
"BinaryName": "lat_mem_rd",
"BinaryCommandLine": "4096 128"
}
},
{
"Type": "LMbenchExecutor",
"Parameters": {
"Scenario": "LatMemRd_Array_4096MB_Stride_256B",
"PackageName": "lmbench",
"CompilerFlags": "$.Parameters.CompilerFlags",
"BinaryName": "lat_mem_rd",
"BinaryCommandLine": "4096 256"
}
},
{
"Type": "LMbenchExecutor",
"Parameters": {
"Scenario": "LatMemRd_Array_4096MB_Stride_512B",
"PackageName": "lmbench",
"CompilerFlags": "$.Parameters.CompilerFlags",
"BinaryName": "lat_mem_rd",
"BinaryCommandLine": "4096 512"
}
},
{
"Type": "LMbenchExecutor",
"Parameters": {
"Scenario": "LatMemRd_Array_4096MB_Stride_1024B",
"PackageName": "lmbench",
"CompilerFlags": "$.Parameters.CompilerFlags",
"BinaryName": "lat_mem_rd",
"BinaryCommandLine": "4096 1024"
}
}
],
"Dependencies": [
{
"Type": "LinuxPackageInstallation",
"Parameters": {
"Scenario": "InstallLinuxPackages",
"Packages-Apt": "libtirpc-dev",
"Packages-Yum": "libtirpc-devel",
"Packages-Dnf": "libtirpc-devel"
}
},
{
"Type": "CompilerInstallation",
"Parameters": {
"Scenario": "InstallCompiler",
"CompilerName": "$.Parameters.CompilerName",
"CompilerVersion": "$.Parameters.CompilerVersion"
}
},
{
"Type": "DependencyPackageInstallation",
"Parameters": {
"Scenario": "InstallLMbenchPackages",
"BlobContainer": "packages",
"BlobName": "lmbench.3.0-r1324.zip",
"PackageName": "lmbench",
"Extract": true
}
}
]
}

0 comments on commit c12a32c

Please sign in to comment.