From 9e048585ecdd6e1e085445b62904afbf1dc23ba3 Mon Sep 17 00:00:00 2001 From: Keshava Munegowda Date: Fri, 16 Aug 2024 19:55:02 +0530 Subject: [PATCH 1/5] Implement PerformanceRecorderIdleWait. Signed-off-by: Keshava Munegowda --- .../java/io/perl/api/PerformanceRecorder.java | 46 +++++++++++++++++++ .../java/io/perl/api/impl/CQueuePerl.java | 4 +- ....java => PerformanceRecorderIdleWait.java} | 20 +++----- 3 files changed, 55 insertions(+), 15 deletions(-) create mode 100644 perl/src/main/java/io/perl/api/PerformanceRecorder.java rename perl/src/main/java/io/perl/api/impl/{PerformanceRecorder.java => PerformanceRecorderIdleWait.java} (85%) diff --git a/perl/src/main/java/io/perl/api/PerformanceRecorder.java b/perl/src/main/java/io/perl/api/PerformanceRecorder.java new file mode 100644 index 000000000..a51021110 --- /dev/null +++ b/perl/src/main/java/io/perl/api/PerformanceRecorder.java @@ -0,0 +1,46 @@ +/** + * Copyright (c) KMG. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + */ + +package io.perl.api; +import io.time.Time; + +import javax.annotation.Nonnull; + +abstract public class PerformanceRecorder { + final protected int windowIntervalMS; + final protected Time time; + final protected PeriodicRecorder periodicRecorder; + final protected Channel[] channels; + + /** + * Constructor to initialize values. + * + * @param periodicRecorder PeriodicRecorder + * @param channels Channel[] + * @param time Time + * @param reportingIntervalMS int + */ + public PerformanceRecorder(PeriodicRecorder periodicRecorder, @Nonnull Channel[] channels, Time time, + int reportingIntervalMS) { + this.periodicRecorder = periodicRecorder; + this.channels = channels.clone(); + this.time = time; + this.windowIntervalMS = reportingIntervalMS; + } + + /** + * Method run. + * + * @param secondsToRun final long. + * @param totalRecords final long. + */ + abstract public void run(final long secondsToRun, final long totalRecords); + +} diff --git a/perl/src/main/java/io/perl/api/impl/CQueuePerl.java b/perl/src/main/java/io/perl/api/impl/CQueuePerl.java index 57323234a..a861e3223 100644 --- a/perl/src/main/java/io/perl/api/impl/CQueuePerl.java +++ b/perl/src/main/java/io/perl/api/impl/CQueuePerl.java @@ -32,7 +32,7 @@ * Class for Concurrent Queue based PerL. */ final public class CQueuePerl implements Perl { - final private PerformanceRecorder perlReceiver; + final private PerformanceRecorderIdleWait perlReceiver; final private Channel[] channels; final private Time time; final private ExecutorService executor; @@ -75,7 +75,7 @@ public CQueuePerl(@NotNull PerlConfig perlConfig, PeriodicRecorder periodicRecor for (int i = 0; i < channels.length; i++) { channels[i] = new CQueueChannel(maxQs, new OnError()); } - this.perlReceiver = new PerformanceRecorder(periodicRecorder, channels, time, reportingIntervalMS, + this.perlReceiver = new PerformanceRecorderIdleWait(periodicRecorder, channels, time, reportingIntervalMS, Math.max(PerlConfig.MIN_IDLE_NS, perlConfig.idleNS)); } diff --git a/perl/src/main/java/io/perl/api/impl/PerformanceRecorder.java b/perl/src/main/java/io/perl/api/impl/PerformanceRecorderIdleWait.java similarity index 85% rename from perl/src/main/java/io/perl/api/impl/PerformanceRecorder.java rename to perl/src/main/java/io/perl/api/impl/PerformanceRecorderIdleWait.java index 3a8e8f19c..031e0d3f5 100644 --- a/perl/src/main/java/io/perl/api/impl/PerformanceRecorder.java +++ b/perl/src/main/java/io/perl/api/impl/PerformanceRecorderIdleWait.java @@ -10,6 +10,7 @@ package io.perl.api.impl; import io.perl.api.Channel; +import io.perl.api.PerformanceRecorder; import io.perl.api.PeriodicRecorder; import io.perl.config.PerlConfig; import io.perl.system.PerlPrinter; @@ -23,12 +24,8 @@ * Class for Performance Recording. */ @NotThreadSafe -public final class PerformanceRecorder { - final private int windowIntervalMS; +public final class PerformanceRecorderIdleWait extends PerformanceRecorder { final private int idleNS; - final private Time time; - final private PeriodicRecorder periodicRecorder; - final private Channel[] channels; /** * Constructor to initialize values. @@ -39,12 +36,9 @@ public final class PerformanceRecorder { * @param reportingIntervalMS int * @param idleNS int */ - public PerformanceRecorder(PeriodicRecorder periodicRecorder, @Nonnull Channel[] channels, Time time, - int reportingIntervalMS, int idleNS) { - this.periodicRecorder = periodicRecorder; - this.channels = channels.clone(); - this.time = time; - this.windowIntervalMS = reportingIntervalMS; + public PerformanceRecorderIdleWait(PeriodicRecorder periodicRecorder, @Nonnull Channel[] channels, Time time, + int reportingIntervalMS, int idleNS) { + super(periodicRecorder, channels, time, reportingIntervalMS); this.idleNS = idleNS; } @@ -64,7 +58,7 @@ public void run(final long secondsToRun, final long totalRecords) { long recordsCnt = 0; boolean notFound; TimeStamp t; - PerlPrinter.log.info("Performance Recorder Started"); + PerlPrinter.log.info("PerformanceRecorderIdleWait Started"); periodicRecorder.start(startTime); periodicRecorder.startWindow(startTime); while (doWork) { @@ -115,7 +109,7 @@ public void run(final long secondsToRun, final long totalRecords) { } } periodicRecorder.stop(ctime); - PerlPrinter.log.info("Performance Recorder Exited"); + PerlPrinter.log.info("PerformanceRecorderIdleWait Exited"); } } From 60dcee6e524f92e579510d4fb89fba7be036b68a Mon Sep 17 00:00:00 2001 From: Keshava Munegowda Date: Fri, 16 Aug 2024 20:11:19 +0530 Subject: [PATCH 2/5] Implement PerformanceRecorderIdleSleep and PerformanceRecorderIdleBusyWait Signed-off-by: Keshava Munegowda --- .../java/io/perl/api/impl/CQueuePerl.java | 5 +- ...a => PerformanceRecorderIdleBusyWait.java} | 6 +- .../impl/PerformanceRecorderIdleSleep.java | 104 ++++++++++++++++++ 3 files changed, 110 insertions(+), 5 deletions(-) rename perl/src/main/java/io/perl/api/impl/{PerformanceRecorderIdleWait.java => PerformanceRecorderIdleBusyWait.java} (93%) create mode 100644 perl/src/main/java/io/perl/api/impl/PerformanceRecorderIdleSleep.java diff --git a/perl/src/main/java/io/perl/api/impl/CQueuePerl.java b/perl/src/main/java/io/perl/api/impl/CQueuePerl.java index a861e3223..6c0ebcc5a 100644 --- a/perl/src/main/java/io/perl/api/impl/CQueuePerl.java +++ b/perl/src/main/java/io/perl/api/impl/CQueuePerl.java @@ -10,6 +10,7 @@ package io.perl.api.impl; import io.perl.api.Channel; +import io.perl.api.PerformanceRecorder; import io.perl.api.PeriodicRecorder; import io.perl.api.Perl; import io.perl.api.PerlChannel; @@ -32,7 +33,7 @@ * Class for Concurrent Queue based PerL. */ final public class CQueuePerl implements Perl { - final private PerformanceRecorderIdleWait perlReceiver; + final private PerformanceRecorder perlReceiver; final private Channel[] channels; final private Time time; final private ExecutorService executor; @@ -75,7 +76,7 @@ public CQueuePerl(@NotNull PerlConfig perlConfig, PeriodicRecorder periodicRecor for (int i = 0; i < channels.length; i++) { channels[i] = new CQueueChannel(maxQs, new OnError()); } - this.perlReceiver = new PerformanceRecorderIdleWait(periodicRecorder, channels, time, reportingIntervalMS, + this.perlReceiver = new PerformanceRecorderIdleBusyWait(periodicRecorder, channels, time, reportingIntervalMS, Math.max(PerlConfig.MIN_IDLE_NS, perlConfig.idleNS)); } diff --git a/perl/src/main/java/io/perl/api/impl/PerformanceRecorderIdleWait.java b/perl/src/main/java/io/perl/api/impl/PerformanceRecorderIdleBusyWait.java similarity index 93% rename from perl/src/main/java/io/perl/api/impl/PerformanceRecorderIdleWait.java rename to perl/src/main/java/io/perl/api/impl/PerformanceRecorderIdleBusyWait.java index 031e0d3f5..5f72e6d89 100644 --- a/perl/src/main/java/io/perl/api/impl/PerformanceRecorderIdleWait.java +++ b/perl/src/main/java/io/perl/api/impl/PerformanceRecorderIdleBusyWait.java @@ -24,7 +24,7 @@ * Class for Performance Recording. */ @NotThreadSafe -public final class PerformanceRecorderIdleWait extends PerformanceRecorder { +public final class PerformanceRecorderIdleBusyWait extends PerformanceRecorder { final private int idleNS; /** @@ -36,8 +36,8 @@ public final class PerformanceRecorderIdleWait extends PerformanceRecorder { * @param reportingIntervalMS int * @param idleNS int */ - public PerformanceRecorderIdleWait(PeriodicRecorder periodicRecorder, @Nonnull Channel[] channels, Time time, - int reportingIntervalMS, int idleNS) { + public PerformanceRecorderIdleBusyWait(PeriodicRecorder periodicRecorder, @Nonnull Channel[] channels, Time time, + int reportingIntervalMS, int idleNS) { super(periodicRecorder, channels, time, reportingIntervalMS); this.idleNS = idleNS; } diff --git a/perl/src/main/java/io/perl/api/impl/PerformanceRecorderIdleSleep.java b/perl/src/main/java/io/perl/api/impl/PerformanceRecorderIdleSleep.java new file mode 100644 index 000000000..909372b9f --- /dev/null +++ b/perl/src/main/java/io/perl/api/impl/PerformanceRecorderIdleSleep.java @@ -0,0 +1,104 @@ +/** + * Copyright (c) KMG. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + */ +package io.perl.api.impl; + +import io.perl.api.Channel; +import io.perl.api.PerformanceRecorder; +import io.perl.api.PeriodicRecorder; +import io.perl.api.TimeStamp; +import io.perl.system.PerlPrinter; +import io.time.Time; + +import javax.annotation.Nonnull; + +public class PerformanceRecorderIdleSleep extends PerformanceRecorder { + final private int sleepMS; + + /** + * Constructor to initialize values. + * + * @param periodicRecorder PeriodicRecorder + * @param channels Channel[] + * @param time Time + * @param reportingIntervalMS int + * @param sleepMS int + */ + public PerformanceRecorderIdleSleep(PeriodicRecorder periodicRecorder, @Nonnull Channel[] channels, Time time, + int reportingIntervalMS, int sleepMS) { + super(periodicRecorder, channels, time, reportingIntervalMS); + this.sleepMS = sleepMS; + } + + /** + * Method run. + * + * @param secondsToRun final long. + * @param totalRecords final long. + */ + public void run(final long secondsToRun, final long totalRecords) { + final long msToRun = secondsToRun * Time.MS_PER_SEC; + final long startTime = time.getCurrentTime(); + boolean doWork = true; + long ctime = startTime; + long recordsCnt = 0; + boolean notFound; + TimeStamp t; + PerlPrinter.log.info("PerformanceRecorderIdleSleep Started"); + periodicRecorder.start(startTime); + periodicRecorder.startWindow(startTime); + while (doWork) { + notFound = true; + for (int i = 0; doWork && (i < channels.length); i++) { + t = channels[i].receive(windowIntervalMS); + if (t != null) { + notFound = false; + ctime = t.endTime; + if (t.isEnd()) { + doWork = false; + } else { + recordsCnt += t.records; + periodicRecorder.record(t.startTime, t.endTime, t.records, t.bytes); + if (msToRun > 0) { + if (time.elapsedMilliSeconds(ctime, startTime) >= msToRun) { + doWork = false; + } + } else if (totalRecords > 0 && recordsCnt >= totalRecords) { + doWork = false; + } + } + if (periodicRecorder.elapsedMilliSecondsWindow(ctime) > windowIntervalMS) { + periodicRecorder.stopWindow(ctime); + periodicRecorder.startWindow(ctime); + } + } + } + if (doWork) { + if (notFound) { + try { + Thread.sleep(this.sleepMS); + } catch (InterruptedException e) { + PerlPrinter.log.warn("PerformanceRecorderIdleSleep : {}", e.getMessage()); + } + ctime = time.getCurrentTime(); + final long diffTime = periodicRecorder.elapsedMilliSecondsWindow(ctime); + if (diffTime > windowIntervalMS) { + periodicRecorder.stopWindow(ctime); + periodicRecorder.startWindow(ctime); + } + } + if (msToRun > 0 && time.elapsedMilliSeconds(ctime, startTime) >= msToRun) { + doWork = false; + } + } + periodicRecorder.stop(ctime); + PerlPrinter.log.info("PerformanceRecorderIdleSleep Exited"); + } + } +} From e8425e8bab0b0de600b03cb43a73180fdf61d4a1 Mon Sep 17 00:00:00 2001 From: Keshava Munegowda Date: Fri, 16 Aug 2024 20:19:21 +0530 Subject: [PATCH 3/5] Add sleepMS to PerlConfig Signed-off-by: Keshava Munegowda --- .../java/io/perl/api/impl/CQueuePerl.java | 24 +++++++++++-------- .../main/java/io/perl/config/PerlConfig.java | 5 ++++ perl/src/main/resources/perl.properties | 4 ++++ 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/perl/src/main/java/io/perl/api/impl/CQueuePerl.java b/perl/src/main/java/io/perl/api/impl/CQueuePerl.java index 6c0ebcc5a..2f2ccc5d3 100644 --- a/perl/src/main/java/io/perl/api/impl/CQueuePerl.java +++ b/perl/src/main/java/io/perl/api/impl/CQueuePerl.java @@ -52,11 +52,11 @@ final public class CQueuePerl implements Perl { /** * Constructor CQueuePerl initialize all values. * - * @param perlConfig NotNull PerlConfig - * @param periodicRecorder PeriodicRecorder - * @param reportingIntervalMS int - * @param time Time - * @param executor ExecutorService + * @param perlConfig NotNull PerlConfig + * @param periodicRecorder PeriodicRecorder + * @param reportingIntervalMS int + * @param time Time + * @param executor ExecutorService */ public CQueuePerl(@NotNull PerlConfig perlConfig, PeriodicRecorder periodicRecorder, int reportingIntervalMS, Time time, ExecutorService executor) { @@ -76,8 +76,13 @@ public CQueuePerl(@NotNull PerlConfig perlConfig, PeriodicRecorder periodicRecor for (int i = 0; i < channels.length; i++) { channels[i] = new CQueueChannel(maxQs, new OnError()); } - this.perlReceiver = new PerformanceRecorderIdleBusyWait(periodicRecorder, channels, time, reportingIntervalMS, - Math.max(PerlConfig.MIN_IDLE_NS, perlConfig.idleNS)); + if (perlConfig.sleepMS > 0) { + this.perlReceiver = new PerformanceRecorderIdleSleep(periodicRecorder, channels, time, reportingIntervalMS, + Math.min(perlConfig.sleepMS, reportingIntervalMS)); + } else { + this.perlReceiver = new PerformanceRecorderIdleBusyWait(periodicRecorder, channels, time, reportingIntervalMS, + Math.max(PerlConfig.MIN_IDLE_NS, perlConfig.idleNS)); + } } @@ -154,8 +159,7 @@ public CompletableFuture run(long secondsToRun, long recordsCount) { } /** - * Stop the CQ Perl. - * + * Stop the CQ Perl. */ @Override public void stop() { @@ -169,7 +173,7 @@ interface Throw { @NotThreadSafe static final class CQueueChannel extends ConcurrentLinkedQueueArray implements Channel { - final private int maxQs; + final private int maxQs; final private Throw eThrow; private int rIndex; diff --git a/perl/src/main/java/io/perl/config/PerlConfig.java b/perl/src/main/java/io/perl/config/PerlConfig.java index 2a57fd116..9c80dc337 100644 --- a/perl/src/main/java/io/perl/config/PerlConfig.java +++ b/perl/src/main/java/io/perl/config/PerlConfig.java @@ -81,6 +81,11 @@ final public class PerlConfig extends LatencyConfig { */ public int idleNS; + /** + * int sleepMS. + */ + public int sleepMS; + /** * int maxQs. */ diff --git a/perl/src/main/resources/perl.properties b/perl/src/main/resources/perl.properties index c90ec46de..98156e7d1 100644 --- a/perl/src/main/resources/perl.properties +++ b/perl/src/main/resources/perl.properties @@ -18,6 +18,10 @@ maxQs=0 # Maximum Idle delay in Nano seconds to read the benchmark Data. Minimum value is 1000 Nano seconds (1 Micro second). idleNS=1000000 +# Maximum sleep time in Milli seconds to read the benchmark data. Initial default value is 0. +# if this value is more than 1 then idleNS will be discarded. +sleepMS=0 + #Max Latency Array Size maxArraySizeMB=64 From aa5ccb9cd4034ec971b5be8bdeff401fc152e9e5 Mon Sep 17 00:00:00 2001 From: Keshava Munegowda Date: Fri, 16 Aug 2024 21:18:56 +0530 Subject: [PATCH 4/5] Add the test case testPerlRecordsSleepMS and fix the bug in PerformanceRecorderIdleSleep. Signed-off-by: Keshava Munegowda --- .../impl/PerformanceRecorderIdleSleep.java | 4 +- perl/src/test/java/io/perl/test/PerlTest.java | 39 ++++++++++++++----- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/perl/src/main/java/io/perl/api/impl/PerformanceRecorderIdleSleep.java b/perl/src/main/java/io/perl/api/impl/PerformanceRecorderIdleSleep.java index 909372b9f..be7d6b984 100644 --- a/perl/src/main/java/io/perl/api/impl/PerformanceRecorderIdleSleep.java +++ b/perl/src/main/java/io/perl/api/impl/PerformanceRecorderIdleSleep.java @@ -97,8 +97,8 @@ public void run(final long secondsToRun, final long totalRecords) { doWork = false; } } - periodicRecorder.stop(ctime); - PerlPrinter.log.info("PerformanceRecorderIdleSleep Exited"); } + periodicRecorder.stop(ctime); + PerlPrinter.log.info("PerformanceRecorderIdleSleep Exited"); } } diff --git a/perl/src/test/java/io/perl/test/PerlTest.java b/perl/src/test/java/io/perl/test/PerlTest.java index 2aba5df13..3c81c2d4f 100644 --- a/perl/src/test/java/io/perl/test/PerlTest.java +++ b/perl/src/test/java/io/perl/test/PerlTest.java @@ -13,6 +13,7 @@ import io.perl.api.Perl; import io.perl.api.PerlChannel; import io.perl.api.impl.PerlBuilder; +import io.perl.config.PerlConfig; import io.perl.logger.impl.DefaultLogger; import io.perl.system.PerlPrinter; import org.junit.Assert; @@ -28,12 +29,13 @@ /** * Class for PerL validation. */ -public class PerlTest { +public class PerlTest { public final static int PERL_THREADS = 2; public final static int PERL_TOTAL_RECORDS = 100; public final static int PERL_RECORDS_PER_THREAD = PERL_TOTAL_RECORDS / PERL_THREADS; public final static int PERL_RECORD_SIZE = 10; public final static int PERL_TIMEOUT_SECONDS = 5; + public final static int PERL_SLEEP_MS = 100; public static class TestLogger extends DefaultLogger { public final AtomicLong latencyReporterCnt; @@ -75,15 +77,14 @@ public void recordLatency(long startTime, int events, int bytes, long latency) { } } - @Test - public void testPerlRecords() throws IOException, ExecutionException, InterruptedException, TimeoutException { - TestLogger logger = new TestLogger(); - Perl perl = PerlBuilder.build( logger, logger, null, null, null); + + private void runPerlRecords(final TestLogger logger, final Perl perl) throws IOException, ExecutionException, + InterruptedException, TimeoutException { PerlChannel[] channels = new PerlChannel[PERL_THREADS]; for (int i = 0; i < PERL_THREADS; i++) { channels[i] = perl.getPerlChannel(); } - CompletableFuture ret = perl.run(0, PERL_TOTAL_RECORDS); + CompletableFuture ret = perl.run(0, PERL_TOTAL_RECORDS); int records = PERL_TOTAL_RECORDS; int ch = 0; @@ -99,16 +100,34 @@ public void testPerlRecords() throws IOException, ExecutionException, Interrupte } ret.get(PERL_TIMEOUT_SECONDS, TimeUnit.SECONDS); if (logger.latencyReporterCnt.get() != PERL_TOTAL_RECORDS) { - Assert.fail("Latency Reporter Count Failed! Latency Reporter Count : "+ logger.latencyReporterCnt.get() + - " , Expected : " + PERL_TOTAL_RECORDS); + Assert.fail("Latency Reporter Count Failed! Latency Reporter Count : " + logger.latencyReporterCnt.get() + + " , Expected : " + PERL_TOTAL_RECORDS); } if (logger.printCnt.get() != PERL_TOTAL_RECORDS) { - Assert.fail("Print Count Failed! Latency Reporter Count : "+ logger.latencyReporterCnt.get() + + Assert.fail("Print Count Failed! Latency Reporter Count : " + logger.printCnt.get() + " , Expected : " + PERL_TOTAL_RECORDS); } if (logger.totalPrintCnt.get() != PERL_TOTAL_RECORDS) { - Assert.fail("Total Print Count Failed! Latency Reporter Count : " + logger.latencyReporterCnt.get() + + Assert.fail("Total Print Count Failed! Latency Reporter Count : " + logger.totalPrintCnt.get() + " , Expected : " + PERL_TOTAL_RECORDS); } } + + @Test + public void testPerlRecordsIdleNS() throws IOException, ExecutionException, InterruptedException, TimeoutException { + TestLogger logger = new TestLogger(); + Perl perl = PerlBuilder.build(logger, logger, null, null, null); + runPerlRecords(logger, perl); + } + + @Test + public void testPerlRecordsSleepMS() throws IOException, ExecutionException, + InterruptedException, TimeoutException { + TestLogger logger = new TestLogger(); + PerlConfig config = PerlConfig.build(); + config.sleepMS = PERL_SLEEP_MS; + Perl perl = PerlBuilder.build(logger, logger, null, config, null); + runPerlRecords(logger, perl); + } + } From e631399128b5c1e063686d6f254f083bcb7f8455 Mon Sep 17 00:00:00 2001 From: Keshava Munegowda Date: Fri, 16 Aug 2024 21:47:58 +0530 Subject: [PATCH 5/5] Add the new option 'millisecsleep'. Signed-off-by: Keshava Munegowda --- .../io/perl/api/impl/PerformanceRecorderIdleBusyWait.java | 4 ++-- sbk-api/src/main/java/io/sbk/api/impl/SbkBenchmark.java | 2 ++ sbk-api/src/main/java/io/sbk/params/Parameters.java | 7 +++++++ .../src/main/java/io/sbk/params/impl/SbkParameters.java | 5 +++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/perl/src/main/java/io/perl/api/impl/PerformanceRecorderIdleBusyWait.java b/perl/src/main/java/io/perl/api/impl/PerformanceRecorderIdleBusyWait.java index 5f72e6d89..77402bddb 100644 --- a/perl/src/main/java/io/perl/api/impl/PerformanceRecorderIdleBusyWait.java +++ b/perl/src/main/java/io/perl/api/impl/PerformanceRecorderIdleBusyWait.java @@ -58,7 +58,7 @@ public void run(final long secondsToRun, final long totalRecords) { long recordsCnt = 0; boolean notFound; TimeStamp t; - PerlPrinter.log.info("PerformanceRecorderIdleWait Started"); + PerlPrinter.log.info("PerformanceRecorderIdleBusyWait Started"); periodicRecorder.start(startTime); periodicRecorder.startWindow(startTime); while (doWork) { @@ -109,7 +109,7 @@ public void run(final long secondsToRun, final long totalRecords) { } } periodicRecorder.stop(ctime); - PerlPrinter.log.info("PerformanceRecorderIdleWait Exited"); + PerlPrinter.log.info("PerformanceRecorderIdleBusyWait Exited"); } } diff --git a/sbk-api/src/main/java/io/sbk/api/impl/SbkBenchmark.java b/sbk-api/src/main/java/io/sbk/api/impl/SbkBenchmark.java index b180cb7aa..cbdb2e824 100644 --- a/sbk-api/src/main/java/io/sbk/api/impl/SbkBenchmark.java +++ b/sbk-api/src/main/java/io/sbk/api/impl/SbkBenchmark.java @@ -91,6 +91,7 @@ public SbkBenchmark(ParameterOptions params, Storage storage, if (params.getWritersCount() > 0 && params.getAction() == Action.Writing) { PerlConfig wConfig = PerlConfig.build(SbkBenchmark.class.getClassLoader().getResourceAsStream(CONFIGFILE)); wConfig.workers = params.getWritersCount(); + wConfig.sleepMS = params.getIdleSleepMilliSeconds(); wConfig.csv = false; writePerl = PerlBuilder.build(rwLogger, rwLogger, this.time, wConfig, executor); } else { @@ -100,6 +101,7 @@ public SbkBenchmark(ParameterOptions params, Storage storage, if (params.getReadersCount() > 0) { PerlConfig rConfig = PerlConfig.build(SbkBenchmark.class.getClassLoader().getResourceAsStream(CONFIGFILE)); rConfig.workers = params.getReadersCount(); + rConfig.sleepMS = params.getIdleSleepMilliSeconds(); rConfig.csv = false; readPerl = PerlBuilder.build(rwLogger, rwLogger, this.time, rConfig, executor); } else { diff --git a/sbk-api/src/main/java/io/sbk/params/Parameters.java b/sbk-api/src/main/java/io/sbk/params/Parameters.java index 2832717d9..ef41c08b2 100644 --- a/sbk-api/src/main/java/io/sbk/params/Parameters.java +++ b/sbk-api/src/main/java/io/sbk/params/Parameters.java @@ -103,4 +103,11 @@ public interface Parameters extends ActionParameter { */ int getReadersStepSeconds(); + + /** + * get duration idle sleep in Milliseconds. + * + * @return get idle sleep in milliseconds . + */ + int getIdleSleepMilliSeconds(); } diff --git a/sbk-api/src/main/java/io/sbk/params/impl/SbkParameters.java b/sbk-api/src/main/java/io/sbk/params/impl/SbkParameters.java index 2d2b344f8..ee07b28c3 100644 --- a/sbk-api/src/main/java/io/sbk/params/impl/SbkParameters.java +++ b/sbk-api/src/main/java/io/sbk/params/impl/SbkParameters.java @@ -64,6 +64,9 @@ public sealed class SbkParameters extends SbkInputOptions implements InputParame @Getter private Action action; + @Getter + private int idleSleepMilliSeconds; + public SbkParameters(String name, String desc) { super(name, desc); @@ -103,6 +106,7 @@ public SbkParameters(String name, String desc) { """ Readonly Benchmarking, Applicable only if both writers and readers are set; default: false"""); + addOption("millisecsleep", true, "Idle sleep in milliseconds; default: 0 ms"); } public SbkParameters(String name) { @@ -149,6 +153,7 @@ public void parseArgs(String[] args) throws ParseException, IllegalArgumentExcep writersStepSeconds = Integer.parseInt(getOptionValue("wsec", "0")); readersStep = Integer.parseInt(getOptionValue("rstep", "1")); readersStepSeconds = Integer.parseInt(getOptionValue("rsec", "0")); + idleSleepMilliSeconds = Integer.parseInt(getOptionValue("millisecsleep", "0")); int workersCnt = writersCount; if (workersCnt == 0) {