Skip to content

Commit 0c8476a

Browse files
authored
Consolidate Sysbench command arguments string (#570)
* Equalize Sysbench parameters distribution in command arguments string to optimize and speed benchmark Kusto queries. * unit tests review * sysbench profile tests review * conflict resolution * unit tests review --------- Signed-off-by: v-safilho <v-safilho@microsoft.com>
1 parent 8ac1445 commit 0c8476a

6 files changed

Lines changed: 88 additions & 66 deletions

File tree

src/VirtualClient/VirtualClient.Actions.FunctionalTests/SysbenchProfileTests.cs

Lines changed: 36 additions & 36 deletions
Large diffs are not rendered by default.

src/VirtualClient/VirtualClient.Actions.UnitTests/Sysbench/SysbenchClientExecutorTests.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public async Task SysbenchClientExecutorRunsTheExpectedWorkloadCommand()
9090
{
9191
SetupDefaultBehavior();
9292

93-
string expectedCommand = @$"python3 {this.mockPackagePath}/run-workload.py --dbName sbtest --databaseSystem MySQL --benchmark OLTP --workload oltp_read_write --threadCount 8 --tableCount 10 --recordCount 1000 --hostIpAddress 1.2.3.5 --durationSecs 10 --password [A-Za-z0-9+/=]+";
93+
string expectedCommand = @$"python3 {this.mockPackagePath}/run-workload.py --dbName sbtest --databaseSystem MySQL --benchmark OLTP --tableCount 10 --recordCount 1000 --threadCount 8 --workload oltp_read_write --hostIpAddress 1.2.3.5 --durationSecs 10 --password [A-Za-z0-9+/=]+";
9494
bool commandExecuted = false;
9595

9696
this.fixture.ProcessManager.OnCreateProcess = (exe, arguments, workingDir) =>
@@ -136,7 +136,7 @@ public async Task SysbenchClientExecutorUsesDefinedParametersWhenRunningTheWorkl
136136
this.fixture.Parameters[nameof(SysbenchClientExecutor.TableCount)] = "40";
137137
this.fixture.Parameters[nameof(SysbenchClientExecutor.DatabaseScenario)] = "Configure";
138138

139-
string expectedCommand = @$"python3 {this.mockPackagePath}/run-workload.py --dbName sbtest --databaseSystem MySQL --benchmark OLTP --workload oltp_read_write --threadCount 64 --tableCount 40 --recordCount 1000 --hostIpAddress 1.2.3.5 --durationSecs 10 --password [A-Za-z0-9+/=]+";
139+
string expectedCommand = @$"python3 {this.mockPackagePath}/run-workload.py --dbName sbtest --databaseSystem MySQL --benchmark OLTP --tableCount 40 --recordCount 1000 --threadCount 64 --workload oltp_read_write --hostIpAddress 1.2.3.5 --durationSecs 10 --password [A-Za-z0-9+/=]+";
140140
bool commandExecuted = false;
141141

142142
this.fixture.ProcessManager.OnCreateProcess = (exe, arguments, workingDir) =>
@@ -179,7 +179,7 @@ public async Task SysbenchClientExecutorRunsTheExpectedBalancedScenario()
179179

180180
this.fixture.Parameters[nameof(SysbenchClientExecutor.DatabaseScenario)] = "Balanced";
181181

182-
string expectedCommand = $"python3 {this.mockPackagePath}/run-workload.py --dbName sbtest --databaseSystem MySQL --benchmark OLTP --workload oltp_read_write --threadCount 8 --tableCount 10 --recordCount 1000 --hostIpAddress 1.2.3.5 --durationSecs 10 --password [A-Za-z0-9+/=]+";
182+
string expectedCommand = $"python3 {this.mockPackagePath}/run-workload.py --dbName sbtest --databaseSystem MySQL --benchmark OLTP --tableCount 10 --recordCount 1000 --threadCount 8 --workload oltp_read_write --hostIpAddress 1.2.3.5 --durationSecs 10 --password [A-Za-z0-9+/=]+";
183183
bool commandExecuted = false;
184184

185185
this.fixture.ProcessManager.OnCreateProcess = (exe, arguments, workingDir) =>
@@ -222,7 +222,7 @@ public async Task SysbenchClientExecutorRunsInMemoryScenario()
222222

223223
this.fixture.Parameters[nameof(SysbenchClientExecutor.DatabaseScenario)] = "InMemory";
224224

225-
string expectedCommand = $"python3 {this.mockPackagePath}/run-workload.py --dbName sbtest --databaseSystem MySQL --benchmark OLTP --workload oltp_read_write --threadCount 8 --tableCount 10 --recordCount 100000 --hostIpAddress 1.2.3.5 --durationSecs 10 --password [A-Za-z0-9+/=]+";
225+
string expectedCommand = $"python3 {this.mockPackagePath}/run-workload.py --dbName sbtest --databaseSystem MySQL --benchmark OLTP --tableCount 10 --recordCount 100000 --threadCount 8 --workload oltp_read_write --hostIpAddress 1.2.3.5 --durationSecs 10 --password [A-Za-z0-9+/=]+";
226226
bool commandExecuted = false;
227227

228228
this.fixture.ProcessManager.OnCreateProcess = (exe, arguments, workingDir) =>
@@ -265,7 +265,7 @@ public async Task SysbenchClientExecutorRunsTheExpectedTPCCWorkloadCommand()
265265

266266
this.fixture.Parameters[nameof(SysbenchClientExecutor.Benchmark)] = "TPCC";
267267

268-
string expectedCommand = $"python3 {this.mockPackagePath}/run-workload.py --dbName sbtest --databaseSystem MySQL --benchmark TPCC --workload tpcc --threadCount 8 --tableCount 10 --warehouses 100 --hostIpAddress 1.2.3.5 --durationSecs 10 --password [A-Za-z0-9+/=]+";
268+
string expectedCommand = $"python3 {this.mockPackagePath}/run-workload.py --dbName sbtest --databaseSystem MySQL --benchmark TPCC --tableCount 10 --warehouses 100 --threadCount 8 --workload tpcc --hostIpAddress 1.2.3.5 --durationSecs 10 --password [A-Za-z0-9+/=]+";
269269
bool commandExecuted = false;
270270

271271
this.fixture.ProcessManager.OnCreateProcess = (exe, arguments, workingDir) =>
@@ -308,7 +308,7 @@ public async Task SysbenchClientExecutorRunsTheExpectedPostgreSQLOLTPWorkloadCom
308308

309309
this.fixture.Parameters[nameof(SysbenchClientExecutor.DatabaseSystem)] = "PostgreSQL";
310310

311-
string expectedCommand = $"python3 {this.mockPackagePath}/run-workload.py --dbName sbtest --databaseSystem PostgreSQL --benchmark OLTP --workload oltp_read_write --threadCount 8 --tableCount 10 --recordCount 1000 --hostIpAddress 1.2.3.5 --durationSecs 10 --password [A-Za-z0-9+/=]+";
311+
string expectedCommand = $"python3 {this.mockPackagePath}/run-workload.py --dbName sbtest --databaseSystem PostgreSQL --benchmark OLTP --tableCount 10 --recordCount 1000 --threadCount 8 --workload oltp_read_write --hostIpAddress 1.2.3.5 --durationSecs 10 --password [A-Za-z0-9+/=]+";
312312
bool commandExecuted = false;
313313

314314
this.fixture.ProcessManager.OnCreateProcess = (exe, arguments, workingDir) =>
@@ -352,7 +352,7 @@ public async Task SysbenchClientExecutorRunsTheExpectedPostgreSQLTPCCWorkloadCom
352352
this.fixture.Parameters[nameof(SysbenchClientExecutor.DatabaseSystem)] = "PostgreSQL";
353353
this.fixture.Parameters[nameof(SysbenchClientExecutor.Benchmark)] = "TPCC";
354354

355-
string expectedCommand = $"python3 {this.mockPackagePath}/run-workload.py --dbName sbtest --databaseSystem PostgreSQL --benchmark TPCC --workload tpcc --threadCount 8 --tableCount 10 --warehouses 100 --hostIpAddress 1.2.3.5 --durationSecs 10 --password [A-Za-z0-9+/=]+";
355+
string expectedCommand = $"python3 {this.mockPackagePath}/run-workload.py --dbName sbtest --databaseSystem PostgreSQL --benchmark TPCC --tableCount 10 --warehouses 100 --threadCount 8 --workload tpcc --hostIpAddress 1.2.3.5 --durationSecs 10 --password [A-Za-z0-9+/=]+";
356356
bool commandExecuted = false;
357357

358358
this.fixture.ProcessManager.OnCreateProcess = (exe, arguments, workingDir) =>

src/VirtualClient/VirtualClient.Actions.UnitTests/Sysbench/SysbenchConfigurationTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public async Task SysbenchConfigurationSkipsSysbenchInitialization()
7777

7878
string[] expectedCommands =
7979
{
80-
$"python3 {this.mockPackagePath}/populate-database.py --dbName sbtest --databaseSystem MySQL --benchmark OLTP --threadCount 8 --tableCount 10 --recordCount 1000 --password [A-Za-z0-9+/=]+",
80+
$"python3 {this.mockPackagePath}/populate-database.py --dbName sbtest --databaseSystem MySQL --benchmark OLTP --tableCount 10 --recordCount 1000 --threadCount 8 --password [A-Za-z0-9+/=]+",
8181
};
8282

8383
int commandNumber = 0;
@@ -122,7 +122,7 @@ public async Task SysbenchConfigurationPreparesDatabase()
122122
string[] expectedCommands =
123123
{
124124
$"python3 {this.mockPackagePath}/configure-workload-generator.py --distro Ubuntu --databaseSystem MySQL --packagePath {this.mockPackagePath}",
125-
$"python3 {this.mockPackagePath}/populate-database.py --dbName sbtest --databaseSystem MySQL --benchmark OLTP --threadCount 8 --tableCount 10 --recordCount 1000 --password [A-Za-z0-9+/=]+",
125+
$"python3 {this.mockPackagePath}/populate-database.py --dbName sbtest --databaseSystem MySQL --benchmark OLTP --tableCount 10 --recordCount 1000 --threadCount 8 --password [A-Za-z0-9+/=]+",
126126
};
127127

128128
int commandNumber = 0;
@@ -173,7 +173,7 @@ public async Task SysbenchConfigurationUsesDefinedParametersWhenRunningTheWorklo
173173
string[] expectedCommands =
174174
{
175175
$"python3 {this.mockPackagePath}/configure-workload-generator.py --distro Ubuntu --databaseSystem MySQL --packagePath {this.mockPackagePath}",
176-
$"python3 {this.mockPackagePath}/populate-database.py --dbName sbtest --databaseSystem MySQL --benchmark OLTP --threadCount 16 --tableCount 40 --recordCount 1000 --password [A-Za-z0-9+/=]+",
176+
$"python3 {this.mockPackagePath}/populate-database.py --dbName sbtest --databaseSystem MySQL --benchmark OLTP --tableCount 40 --recordCount 1000 --threadCount 16 --password [A-Za-z0-9+/=]+",
177177
};
178178

179179
int commandNumber = 0;
@@ -386,7 +386,7 @@ public async Task SysbenchConfigurationProperlyExecutesPostgreSQLOLTPConfigurabl
386386

387387
string[] expectedCommands =
388388
{
389-
$"python3 {this.mockPackagePath}/populate-database.py --dbName sbtest --databaseSystem PostgreSQL --benchmark OLTP --threadCount 16 --tableCount 40 --recordCount 1000 --password [A-Za-z0-9+/=]+"
389+
$"python3 {this.mockPackagePath}/populate-database.py --dbName sbtest --databaseSystem PostgreSQL --benchmark OLTP --tableCount 40 --recordCount 1000 --threadCount 16 --password [A-Za-z0-9+/=]+"
390390
};
391391

392392
int commandNumber = 0;

src/VirtualClient/VirtualClient.Actions/Sysbench/SysbenchClientExecutor.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,7 @@ private Task ExecuteWorkloadAsync(EventContext telemetryContext, CancellationTok
230230

231231
private async Task RunOLTPWorkloadAsync(EventContext telemetryContext, CancellationToken cancellationToken)
232232
{
233-
int tableCount = GetTableCount(this.DatabaseScenario, this.TableCount, this.Workload);
234-
int threadCount = GetThreadCount(this.SystemManager, this.DatabaseScenario, this.Threads);
235-
int recordCount = GetRecordCount(this.SystemManager, this.DatabaseScenario, this.RecordCount);
236-
237-
this.sysbenchLoggingArguments = $"--dbName {this.DatabaseName} --databaseSystem {this.DatabaseSystem} --benchmark {this.Benchmark} --workload {this.Workload} --threadCount {threadCount} --tableCount {tableCount} --recordCount {recordCount} ";
233+
this.sysbenchLoggingArguments = $"{this.BuildSysbenchLoggingOLTPBasicArguments()} --workload {this.Workload} ";
238234
this.sysbenchExecutionArguments = this.sysbenchLoggingArguments + $"--hostIpAddress {this.ServerIpAddress} --durationSecs {this.Duration.TotalSeconds} --password {this.SuperUserPassword}";
239235

240236
string script = $"{this.SysbenchPackagePath}/run-workload.py ";
@@ -289,7 +285,7 @@ private async Task RunTPCCWorkloadAsync(EventContext telemetryContext, Cancellat
289285
int threadCount = GetThreadCount(this.SystemManager, this.DatabaseScenario, this.Threads);
290286
int warehouseCount = GetWarehouseCount(this.DatabaseScenario, this.WarehouseCount);
291287

292-
this.sysbenchLoggingArguments = $"--dbName {this.DatabaseName} --databaseSystem {this.DatabaseSystem} --benchmark {this.Benchmark} --workload tpcc --threadCount {threadCount} --tableCount {tableCount} --warehouses {warehouseCount} ";
288+
this.sysbenchLoggingArguments = $"{this.BuildSysbenchLoggingTPCCBasicArguments()} --workload tpcc ";
293289
this.sysbenchExecutionArguments = this.sysbenchLoggingArguments + $"--hostIpAddress {this.ServerIpAddress} --durationSecs {this.Duration.TotalSeconds} --password {this.SuperUserPassword}";
294290

295291
string script = $"{this.SysbenchPackagePath}/run-workload.py ";
@@ -338,11 +334,8 @@ private async Task TruncateMySQLDatabaseAsync(EventContext telemetryContext, Can
338334

339335
private async Task PrepareOLTPMySQLDatabase(EventContext telemetryContext, CancellationToken cancellationToken)
340336
{
341-
int tableCount = GetTableCount(this.DatabaseScenario, this.TableCount, this.Workload);
342-
int threadCount = GetThreadCount(this.SystemManager, this.DatabaseScenario, this.Threads);
343-
int recordCount = GetRecordCount(this.SystemManager, this.DatabaseScenario, this.RecordCount);
337+
this.sysbenchLoggingArguments = this.BuildSysbenchLoggingOLTPBasicArguments();
344338

345-
this.sysbenchLoggingArguments = $"--dbName {this.DatabaseName} --databaseSystem {this.DatabaseSystem} --benchmark {this.Benchmark} --threadCount {threadCount} --tableCount {tableCount} --recordCount {recordCount}";
346339
this.sysbenchPrepareArguments = $"{this.sysbenchLoggingArguments} --password {this.SuperUserPassword}";
347340

348341
string serverIp = (this.GetLayoutClientInstances(ClientRole.Server, false) ?? Enumerable.Empty<ClientInstance>())

src/VirtualClient/VirtualClient.Actions/Sysbench/SysbenchConfiguration.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,8 @@ await this.Logger.LogMessageAsync($"{this.TypeName}.PopulateDatabase", telemetry
7575

7676
private async Task PrepareOLTPMySQLDatabase(EventContext telemetryContext, CancellationToken cancellationToken)
7777
{
78-
int tableCount = GetTableCount(this.DatabaseScenario, this.TableCount, this.Workload);
79-
int threadCount = GetThreadCount(this.SystemManager, this.DatabaseScenario, this.Threads);
80-
int recordCount = GetRecordCount(this.SystemManager, this.DatabaseScenario, this.RecordCount);
78+
string sysbenchLoggingArguments = this.BuildSysbenchLoggingOLTPBasicArguments();
8179

82-
string sysbenchLoggingArguments = $"--dbName {this.DatabaseName} --databaseSystem {this.DatabaseSystem} --benchmark {this.Benchmark} --threadCount {threadCount} --tableCount {tableCount} --recordCount {recordCount}";
8380
this.sysbenchPrepareArguments = $"{sysbenchLoggingArguments} --password {this.SuperUserPassword}";
8481

8582
string serverIp = "localhost";
@@ -107,11 +104,7 @@ private async Task PrepareOLTPMySQLDatabase(EventContext telemetryContext, Cance
107104

108105
private async Task PrepareTPCCMySQLDatabase(EventContext telemetryContext, CancellationToken cancellationToken)
109106
{
110-
int tableCount = GetTableCount(this.DatabaseScenario, this.TableCount, this.Workload);
111-
int threadCount = GetThreadCount(this.SystemManager, this.DatabaseScenario, this.Threads);
112-
int warehouseCount = GetWarehouseCount(this.DatabaseScenario, this.WarehouseCount);
113-
114-
string sysbenchLoggingArguments = $"--dbName {this.DatabaseName} --databaseSystem {this.DatabaseSystem} --benchmark {this.Benchmark} --tableCount {tableCount} --warehouses {warehouseCount} --threadCount {threadCount}";
107+
string sysbenchLoggingArguments = this.BuildSysbenchLoggingTPCCBasicArguments();
115108
this.sysbenchPrepareArguments = $"{sysbenchLoggingArguments} --password {this.SuperUserPassword}";
116109

117110
string arguments = $"{this.SysbenchPackagePath}/populate-database.py ";

src/VirtualClient/VirtualClient.Actions/Sysbench/SysbenchExecutor.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,42 @@ protected void AddMetric(string arguments, IProcessProxy process, EventContext t
426426
}
427427
}
428428

429+
/// <summary>
430+
/// Build the Sysbench Logging Basic Arguments, having the common parameters
431+
/// dbName, databaseSystem, benchmark and tableCount.
432+
/// </summary>
433+
/// <returns></returns>
434+
protected string BuildSysbenchLoggingBasicArguments()
435+
{
436+
int tableCount = GetTableCount(this.DatabaseScenario, this.TableCount, this.Workload);
437+
438+
return $"--dbName {this.DatabaseName} --databaseSystem {this.DatabaseSystem} --benchmark {this.Benchmark} --tableCount {tableCount}";
439+
}
440+
441+
/// <summary>
442+
/// Build the Sysbench Logging OLTP Basic Arguments, having the common parameters
443+
/// dbName, databaseSystem, benchmark, tableCount, recordCount and threadCount.
444+
/// </summary>
445+
/// <returns></returns>
446+
protected string BuildSysbenchLoggingOLTPBasicArguments()
447+
{
448+
int recordCount = GetRecordCount(this.SystemManager, this.DatabaseScenario, this.RecordCount);
449+
int threadCount = GetThreadCount(this.SystemManager, this.DatabaseScenario, this.Threads);
450+
return $"{this.BuildSysbenchLoggingBasicArguments()} --recordCount {recordCount} --threadCount {threadCount}";
451+
}
452+
453+
/// <summary>
454+
/// Build the Sysbench Logging TPCC Basic Arguments, having the common parameters
455+
/// dbName, databaseSystem, benchmark, tableCount, warehouses and threadCount.
456+
/// </summary>
457+
/// <returns></returns>
458+
protected string BuildSysbenchLoggingTPCCBasicArguments()
459+
{
460+
int warehouseCount = GetWarehouseCount(this.DatabaseScenario, this.WarehouseCount);
461+
int threadCount = GetThreadCount(this.SystemManager, this.DatabaseScenario, this.Threads);
462+
return $"{this.BuildSysbenchLoggingBasicArguments()} --warehouses {warehouseCount} --threadCount {threadCount}";
463+
}
464+
429465
private async Task CheckDistroSupportAsync(EventContext telemetryContext, CancellationToken cancellationToken)
430466
{
431467
if (this.Platform == PlatformID.Unix)

0 commit comments

Comments
 (0)