From 930029e85985eb973c0509f01c7683b340677983 Mon Sep 17 00:00:00 2001 From: pbaykalov <54845956+pbaykalov@users.noreply.github.com> Date: Fri, 16 Dec 2022 00:01:59 +0300 Subject: [PATCH 1/2] add requested comment --- .../kg/apc/jmeter/timers/VariableThroughputTimer.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/tst/src/main/java/kg/apc/jmeter/timers/VariableThroughputTimer.java b/plugins/tst/src/main/java/kg/apc/jmeter/timers/VariableThroughputTimer.java index a833ada33..e64d1b2ce 100644 --- a/plugins/tst/src/main/java/kg/apc/jmeter/timers/VariableThroughputTimer.java +++ b/plugins/tst/src/main/java/kg/apc/jmeter/timers/VariableThroughputTimer.java @@ -167,8 +167,14 @@ private int getDelay(long millisSinceLastSecond) { if (log.isDebugEnabled()) { log.debug("Calculating {} {} {}", millisSinceLastSecond, cntSent * msecPerReq, cntSent); } + + if (millisSinceLastSecond < (cntSent * msecPerReq)) { - // TODO : Explain this for other maintainers + //this code allows for very big number of threads to be fired each second (at most 1 divided by how much time "delay" runs because it's synchronized) + //each second has number of requests to fire + //this condition evaluates to true if threads have been firing (executing "sample" and then executing "delay") quickly enough since the second started + //otherwise next thread should be fired instantly + // cntDelayed + 1 : Current threads waiting + this thread return (int) (1 + 1000.0 * (cntDelayed + 1) / rps); } From c4580a8bd7dfe5f274fbf2a79cc1ba3cca723e5f Mon Sep 17 00:00:00 2001 From: pbaykalov <54845956+pbaykalov@users.noreply.github.com> Date: Fri, 16 Dec 2022 00:16:08 +0300 Subject: [PATCH 2/2] correct handling or RPS<1 if rps is less than 1 and if delay() is executed inside new second this condition will evaluate to false and cause double-release potentially this can cause very long series of 1 RPS release if resonance is hit: if ((total time for each sample to execute with all other thread actions) + msecPerReq ) % 1000 is close to 0 or 1000 then 1 RPS will fire for very long time for arbitrarily small RPS this commit fixes this multiple release for small RPS but there are still problems if the requests are long enough I will suggest better and simplier code in future commits --- .../main/java/kg/apc/jmeter/timers/VariableThroughputTimer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/tst/src/main/java/kg/apc/jmeter/timers/VariableThroughputTimer.java b/plugins/tst/src/main/java/kg/apc/jmeter/timers/VariableThroughputTimer.java index e64d1b2ce..168f0d01b 100644 --- a/plugins/tst/src/main/java/kg/apc/jmeter/timers/VariableThroughputTimer.java +++ b/plugins/tst/src/main/java/kg/apc/jmeter/timers/VariableThroughputTimer.java @@ -169,7 +169,7 @@ private int getDelay(long millisSinceLastSecond) { } - if (millisSinceLastSecond < (cntSent * msecPerReq)) { + if (millisSinceLastSecond < (cntSent * msecPerReq) || msecPerReq > 1000) { //this code allows for very big number of threads to be fired each second (at most 1 divided by how much time "delay" runs because it's synchronized) //each second has number of requests to fire //this condition evaluates to true if threads have been firing (executing "sample" and then executing "delay") quickly enough since the second started