Skip to content

Commit 9b910bf

Browse files
authored
Bug: Fix "logical processors per core" calculation to be correct. (#236)
* Bug: Fix "logical processors per core" calculation to be correct. * Support well-known placeholders for total system memory/RAM. * Modify OpenSSL workload profile to use metric scenario defined in profile with metrics output.
1 parent 0df5be0 commit 9b910bf

File tree

20 files changed

+449
-58
lines changed

20 files changed

+449
-58
lines changed

src/VirtualClient/VirtualClient.Actions.UnitTests/OpenSSL/OpenSslExecutorTests.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ await executor.ExecuteAsync(CancellationToken.None)
185185
Assert.IsNotEmpty(messages);
186186
Assert.True(messages.Count() == 6);
187187
Assert.IsTrue(messages.All(msg => msg.Item3 as EventContext != null));
188-
Assert.IsTrue(messages.All(msg => (msg.Item3 as EventContext).Properties["ScenarioName"].ToString() == "OpenSSL Speed"));
188+
Assert.IsTrue(messages.All(msg => (msg.Item3 as EventContext).Properties["ToolName"].ToString() == "OpenSSL"));
189+
Assert.IsTrue(messages.All(msg => (msg.Item3 as EventContext).Properties["ScenarioName"].ToString() == "aes-256-cbc"));
189190
}
190191
}
191192

@@ -235,6 +236,8 @@ private void SetupDefaultBehaviors(PlatformID platform = PlatformID.Unix, Archit
235236
// Profile parameters.
236237
this.fixture.Parameters = new Dictionary<string, IConvertible>
237238
{
239+
{ "Scenario", "AES-256-CBC" },
240+
{ "MetricScenario", "aes-256-cbc" },
238241
{ "CommandArguments", "speed -elapsed -seconds 100 aes-256-cbc" },
239242
{ "PackageName", "OpenSSL" },
240243
{ "Tags", "CPU,OpenSSL,Cryptography" }

src/VirtualClient/VirtualClient.Actions/CoreMark/CoreMarkExecutor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public int ThreadCount
7575
{
7676
// Default to system logical core count, but overwritable with parameters.
7777
CpuInfo cpuInfo = this.systemManagement.GetCpuInfoAsync(CancellationToken.None).GetAwaiter().GetResult();
78-
int threadCount = cpuInfo.LogicalCoreCount;
78+
int threadCount = cpuInfo.LogicalProcessorCount;
7979

8080
if (this.Parameters.TryGetValue(nameof(this.ThreadCount), out IConvertible value) && value != null)
8181
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public int ThreadCount
6969
{
7070
// Default to system logical core count, but overwritable with parameters.
7171
CpuInfo cpuInfo = this.systemManagement.GetCpuInfoAsync(CancellationToken.None).GetAwaiter().GetResult();
72-
int threadCount = cpuInfo.LogicalCoreCount;
72+
int threadCount = cpuInfo.LogicalProcessorCount;
7373

7474
if (this.Parameters.TryGetValue(nameof(this.ThreadCount), out IConvertible value) && value != null)
7575
{

src/VirtualClient/VirtualClient.Actions/HPLinpack/HPLinpackExecutor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public int NumberOfProcesses
9595
{
9696
get
9797
{
98-
return this.Parameters.GetValue<int>(nameof(this.NumberOfProcesses), this.cpuInfo.LogicalCoreCount);
98+
return this.Parameters.GetValue<int>(nameof(this.NumberOfProcesses), this.cpuInfo.LogicalProcessorCount);
9999
}
100100
}
101101

@@ -168,7 +168,7 @@ protected override async Task InitializeAsync(EventContext telemetryContext, Can
168168
await this.EvaluateParametersAsync(cancellationToken);
169169
this.ThrowIfPlatformIsNotSupported();
170170
await this.CheckDistroSupportAsync(telemetryContext, cancellationToken);
171-
this.coreCount = this.cpuInfo.LogicalCoreCount;
171+
this.coreCount = this.cpuInfo.LogicalProcessorCount;
172172

173173
MemoryInfo memoryInfo = await this.systemManagement.GetMemoryInfoAsync(CancellationToken.None);
174174
this.totalMemoryKiloBytes = memoryInfo.TotalMemory;

src/VirtualClient/VirtualClient.Actions/OpenSSL/OpenSslExecutor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ private void CaptureMetrics(IProcessProxy workloadProcess, string commandArgumen
130130

131131
this.Logger.LogMetrics(
132132
"OpenSSL",
133-
"OpenSSL Speed",
133+
this.MetricScenario ?? this.Scenario,
134134
workloadProcess.StartTime,
135135
workloadProcess.ExitTime,
136136
metrics,

src/VirtualClient/VirtualClient.Actions/Redis/RedisServerExecutor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ protected override void Validate()
254254
base.Validate();
255255
CpuInfo cpuInfo = this.SystemManagement.GetCpuInfoAsync(CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult();
256256

257-
if (this.BindToCores && this.ServerInstances > cpuInfo.LogicalCoreCount)
257+
if (this.BindToCores && this.ServerInstances > cpuInfo.LogicalProcessorCount)
258258
{
259259
throw new WorkloadException(
260260
$"Invalid '{nameof(this.ServerInstances)}' parameter value. The number of server instances cannot exceed the number of logical cores/vCPUs on the system.",

src/VirtualClient/VirtualClient.Actions/SysbenchOLTP/SysbenchOLTPClientExecutor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public int RecordCount
122122
// records & threads depend on the core count
123123

124124
CpuInfo cpuInfo = this.SystemManager.GetCpuInfoAsync(CancellationToken.None).GetAwaiter().GetResult();
125-
int coreCount = cpuInfo.LogicalCoreCount;
125+
int coreCount = cpuInfo.LogicalProcessorCount;
126126

127127
int recordCountExponent = this.DatabaseScenario == SysbenchOLTPScenario.Balanced ?
128128
(int)Math.Log2(coreCount) : (int)Math.Log2(coreCount) + 2;
@@ -151,7 +151,7 @@ public int Threads
151151
CpuInfo cpuInfo = this.SystemManager.GetCpuInfoAsync(CancellationToken.None).GetAwaiter().GetResult();
152152

153153
int numThreads = this.DatabaseScenario == SysbenchOLTPScenario.Balanced ?
154-
1 : cpuInfo.LogicalCoreCount * 8;
154+
1 : cpuInfo.LogicalProcessorCount * 8;
155155

156156
if (this.Parameters.TryGetValue(nameof(SysbenchOLTPClientExecutor.Threads), out IConvertible threads) && threads != null)
157157
{
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Architecture: aarch64
2+
CPU op-mode(s): 32-bit, 64-bit
3+
Byte Order: Little Endian
4+
CPU(s): 64
5+
On-line CPU(s) list: 0-63
6+
Thread(s) per core: 1
7+
Core(s) per socket: 64
8+
Socket(s): 1
9+
NUMA node(s): 1
10+
Vendor ID: ARM
11+
Model: 1
12+
Model name: Neoverse-N1
13+
Stepping: r3p1
14+
BogoMIPS: 50.00
15+
L1d cache: 4 MiB
16+
L1i cache: 4 MiB
17+
L2 cache: 64 MiB
18+
L3 cache: 32 MiB
19+
NUMA node0 CPU(s): 0-63
20+
Vulnerability Gather data sampling: Not affected
21+
Vulnerability Itlb multihit: Not affected
22+
Vulnerability L1tf: Not affected
23+
Vulnerability Mds: Not affected
24+
Vulnerability Meltdown: Mitigation; PTI
25+
Vulnerability Mmio stale data: Not affected
26+
Vulnerability Retbleed: Not affected
27+
Vulnerability Spec rstack overflow: Not affected
28+
Vulnerability Spec store bypass: Not affected
29+
Vulnerability Spectre v1: Mitigation; __user pointer sanitization
30+
Vulnerability Spectre v2: Mitigation; CSV2, BHB
31+
Vulnerability Srbds: Not affected
32+
Vulnerability Tsx async abort: Not affected
33+
Flags: fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp

src/VirtualClient/VirtualClient.Contracts.UnitTests/Parser/CoreInfoParserTests.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ public void CoreInfoParserParsesTheExpectedResultsFromIntelSystems_Scenario1()
2424
Assert.IsNotNull(info);
2525
Assert.AreEqual("Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz", info.Name);
2626
Assert.AreEqual("Intel64 Family 6 Model 106 Stepping 6, GenuineIntel", info.Description);
27-
Assert.AreEqual(4, info.LogicalCoreCount);
27+
Assert.AreEqual(4, info.LogicalProcessorCount);
28+
Assert.AreEqual(2, info.LogicalProcessorsPerCoreCount);
2829
Assert.AreEqual(2, info.PhysicalCoreCount);
2930
Assert.AreEqual(1, info.SocketCount);
3031
Assert.AreEqual(0, info.NumaNodeCount);
@@ -51,7 +52,8 @@ public void CoreInfoParserParsesTheExpectedResultsFromIntelSystems_Scenario2()
5152
Assert.IsNotNull(info);
5253
Assert.AreEqual("Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz", info.Name);
5354
Assert.AreEqual("Intel64 Family 6 Model 106 Stepping 6, GenuineIntel", info.Description);
54-
Assert.AreEqual(2, info.LogicalCoreCount);
55+
Assert.AreEqual(2, info.LogicalProcessorCount);
56+
Assert.AreEqual(1, info.LogicalProcessorsPerCoreCount);
5557
Assert.AreEqual(2, info.PhysicalCoreCount);
5658
Assert.AreEqual(1, info.SocketCount);
5759
Assert.AreEqual(0, info.NumaNodeCount);
@@ -78,7 +80,8 @@ public void CoreInfoParserParsesTheExpectedResultsFromIntelSystems_Scenario3()
7880
Assert.IsNotNull(info);
7981
Assert.AreEqual("Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz", info.Name);
8082
Assert.AreEqual("Intel64 Family 6 Model 106 Stepping 6, GenuineIntel", info.Description);
81-
Assert.AreEqual(8, info.LogicalCoreCount);
83+
Assert.AreEqual(8, info.LogicalProcessorCount);
84+
Assert.AreEqual(2, info.LogicalProcessorsPerCoreCount);
8285
Assert.AreEqual(4, info.PhysicalCoreCount);
8386
Assert.AreEqual(2, info.SocketCount);
8487
Assert.AreEqual(2, info.NumaNodeCount);
@@ -105,7 +108,8 @@ public void CoreInfoParserParsesTheExpectedResultsFromAMDSystems_Scenario1()
105108
Assert.IsNotNull(info);
106109
Assert.AreEqual("AMD EPYC 7452 32-Core Processor", info.Name);
107110
Assert.AreEqual("AMD64 Family 23 Model 49 Stepping 0, AuthenticAMD", info.Description);
108-
Assert.AreEqual(2, info.LogicalCoreCount);
111+
Assert.AreEqual(2, info.LogicalProcessorCount);
112+
Assert.AreEqual(2, info.LogicalProcessorsPerCoreCount);
109113
Assert.AreEqual(1, info.PhysicalCoreCount);
110114
Assert.AreEqual(1, info.SocketCount);
111115
Assert.AreEqual(0, info.NumaNodeCount);
@@ -132,7 +136,8 @@ public void CoreInfoParserParsesTheExpectedResultsFromAmpereSystems_Scenario1()
132136
Assert.IsNotNull(info);
133137
Assert.AreEqual("Ampere(R) Altra(R) Processor", info.Name);
134138
Assert.AreEqual("ARMv8 (64-bit) Family 8 Model D0C Revision 301, Ampere(R)", info.Description);
135-
Assert.AreEqual(4, info.LogicalCoreCount);
139+
Assert.AreEqual(4, info.LogicalProcessorCount);
140+
Assert.AreEqual(1, info.LogicalProcessorsPerCoreCount);
136141
Assert.AreEqual(4, info.PhysicalCoreCount);
137142
Assert.AreEqual(1, info.SocketCount);
138143
Assert.AreEqual(1, info.NumaNodeCount);
@@ -158,7 +163,8 @@ public void CoreInfoParserParsesTheExpectedResultsFromAmpereSystems_Scenario2()
158163
Assert.IsNotNull(info);
159164
Assert.AreEqual("Ampere(R) Altra(R) Processor", info.Name);
160165
Assert.AreEqual("ARMv8 (64-bit) Family 8 Model D0C Revision 301, Ampere(R)", info.Description);
161-
Assert.AreEqual(16, info.LogicalCoreCount);
166+
Assert.AreEqual(16, info.LogicalProcessorCount);
167+
Assert.AreEqual(1, info.LogicalProcessorsPerCoreCount);
162168
Assert.AreEqual(16, info.PhysicalCoreCount);
163169
Assert.AreEqual(1, info.SocketCount);
164170
Assert.AreEqual(0, info.NumaNodeCount);

src/VirtualClient/VirtualClient.Contracts.UnitTests/Parser/LscpuParserTests.cs

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ public void LscpuParserParsesTheExpectedResultsFromIntelSystems_Scenario1()
2323
Assert.IsNotNull(info);
2424
Assert.AreEqual("Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz", info.Name);
2525
Assert.AreEqual("Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz Family 6 Model 106 Stepping 6, GenuineIntel", info.Description);
26-
Assert.AreEqual(4, info.LogicalCoreCount);
26+
Assert.AreEqual(4, info.LogicalProcessorCount);
27+
Assert.AreEqual(2, info.LogicalProcessorsPerCoreCount);
2728
Assert.AreEqual(2, info.PhysicalCoreCount);
2829
Assert.AreEqual(1, info.SocketCount);
2930
Assert.AreEqual(1, info.NumaNodeCount);
@@ -62,7 +63,8 @@ public void LscpuParserParsesTheExpectedResultsFromIntelSystems_Scenario2()
6263
Assert.IsNotNull(info);
6364
Assert.AreEqual("Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz", info.Name);
6465
Assert.AreEqual("Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz Family 6 Model 106 Stepping 6, GenuineIntel", info.Description);
65-
Assert.AreEqual(2, info.LogicalCoreCount);
66+
Assert.AreEqual(2, info.LogicalProcessorCount);
67+
Assert.AreEqual(1, info.LogicalProcessorsPerCoreCount);
6668
Assert.AreEqual(2, info.PhysicalCoreCount);
6769
Assert.AreEqual(1, info.SocketCount);
6870
Assert.AreEqual(1, info.NumaNodeCount);
@@ -101,7 +103,8 @@ public void LscpuParserParsesTheExpectedResultsFromAmpereSystems_Scenario1()
101103
Assert.IsNotNull(info);
102104
Assert.AreEqual("Neoverse-N1", info.Name);
103105
Assert.AreEqual("Neoverse-N1 Model 1 Stepping r3p1, ARM", info.Description);
104-
Assert.AreEqual(2, info.LogicalCoreCount);
106+
Assert.AreEqual(2, info.LogicalProcessorCount);
107+
Assert.AreEqual(1, info.LogicalProcessorsPerCoreCount);
105108
Assert.AreEqual(2, info.PhysicalCoreCount);
106109
Assert.AreEqual(1, info.SocketCount);
107110
Assert.AreEqual(1, info.NumaNodeCount);
@@ -129,6 +132,45 @@ public void LscpuParserParsesTheExpectedResultsFromAmpereSystems_Scenario1()
129132
Assert.IsTrue(info.Caches.Any(cache => cache.Name == "L3" && cache.SizeInBytes == 33554432));
130133
}
131134

135+
[Test]
136+
public void LscpuParserParsesTheExpectedResultsFromAmpereSystems_Scenario2()
137+
{
138+
string results = File.ReadAllText(Path.Combine(MockFixture.ExamplesDirectory, "lscpu", "lscpu_results_ampere_2.txt"));
139+
LscpuParser parser = new LscpuParser(results);
140+
CpuInfo info = parser.Parse();
141+
142+
Assert.IsNotNull(info);
143+
Assert.AreEqual("Neoverse-N1", info.Name);
144+
Assert.AreEqual("Neoverse-N1 Model 1 Stepping r3p1, ARM", info.Description);
145+
Assert.AreEqual(64, info.LogicalProcessorCount);
146+
Assert.AreEqual(1, info.LogicalProcessorsPerCoreCount);
147+
Assert.AreEqual(64, info.PhysicalCoreCount);
148+
Assert.AreEqual(1, info.SocketCount);
149+
Assert.AreEqual(1, info.NumaNodeCount);
150+
Assert.IsFalse(info.IsHyperthreadingEnabled);
151+
Assert.AreEqual(double.NaN, info.MaxFrequencyMHz);
152+
Assert.AreEqual(double.NaN, info.MinFrequencyMHz);
153+
Assert.AreEqual(double.NaN, info.FrequencyMHz);
154+
155+
Assert.AreEqual(6, info.Flags.Count);
156+
Assert.AreEqual("aarch64", info.Flags["Architecture"]);
157+
Assert.AreEqual("32-bit, 64-bit", info.Flags["CPU op-mode(s)"]);
158+
Assert.AreEqual("Little Endian", info.Flags["Byte Order"]);
159+
Assert.AreEqual("0-63", info.Flags["NUMA node0 CPU(s)"]);
160+
Assert.AreEqual("0-63", info.Flags["On-line CPU(s) list"]);
161+
Assert.AreEqual("50", info.Flags["BogoMIPS"]);
162+
163+
IConvertible cacheMemory = 0;
164+
Assert.IsNotEmpty(info.Caches);
165+
166+
Assert.IsTrue(info.Caches.Count() == 5);
167+
Assert.IsTrue(info.Caches.Any(cache => cache.Name == "L1" && cache.SizeInBytes == 8388608));
168+
Assert.IsTrue(info.Caches.Any(cache => cache.Name == "L1d" && cache.SizeInBytes == 4194304));
169+
Assert.IsTrue(info.Caches.Any(cache => cache.Name == "L1i" && cache.SizeInBytes == 4194304));
170+
Assert.IsTrue(info.Caches.Any(cache => cache.Name == "L2" && cache.SizeInBytes == 67108864));
171+
Assert.IsTrue(info.Caches.Any(cache => cache.Name == "L3" && cache.SizeInBytes == 33554432));
172+
}
173+
132174
[Test]
133175
public void LscpuParserParsesTheExpectedResultsFromAWSSystems_Scenario3()
134176
{
@@ -139,7 +181,8 @@ public void LscpuParserParsesTheExpectedResultsFromAWSSystems_Scenario3()
139181
Assert.IsNotNull(info);
140182
Assert.AreEqual("Model 1 Stepping r1p1, ARM", info.Name);
141183
Assert.AreEqual("Model 1 Stepping r1p1, ARM", info.Description);
142-
Assert.AreEqual(2, info.LogicalCoreCount);
184+
Assert.AreEqual(2, info.LogicalProcessorCount);
185+
Assert.AreEqual(1, info.LogicalProcessorsPerCoreCount);
143186
Assert.AreEqual(2, info.PhysicalCoreCount);
144187
Assert.AreEqual(1, info.SocketCount);
145188
Assert.AreEqual(1, info.NumaNodeCount);
@@ -177,7 +220,8 @@ public void LscpuParserParsesTheExpectedResultsIntelLabSystems_Scenario4()
177220
Assert.IsNotNull(info);
178221
Assert.AreEqual("Intel(R) Xeon(R) Platinum 8480C", info.Name);
179222
Assert.AreEqual("Intel(R) Xeon(R) Platinum 8480C Family 6 Model 143 Stepping 8, GenuineIntel", info.Description);
180-
Assert.AreEqual(28, info.LogicalCoreCount);
223+
Assert.AreEqual(28, info.LogicalProcessorCount);
224+
Assert.AreEqual(2, info.LogicalProcessorsPerCoreCount);
181225
Assert.AreEqual(14, info.PhysicalCoreCount);
182226
Assert.AreEqual(2, info.SocketCount);
183227
Assert.AreEqual(2, info.NumaNodeCount);

0 commit comments

Comments
 (0)