Bug 58183 - Rampup may not be respected if thread take time to start leading to threads continuing to start post ramp up time
Summary: Rampup may not be respected if thread take time to start leading to threads c...
Status: RESOLVED FIXED
Alias: None
Product: JMeter
Classification: Unclassified
Component: Main (show other bugs)
Version: 2.13
Hardware: All All
: P2 normal (vote)
Target Milestone: JMETER_5.1.1
Assignee: JMeter issues mailing list
URL:
Keywords: FixedInTrunk
Depends on:
Blocks: 58182
  Show dependency tree
 
Reported: 2015-07-28 09:48 UTC by indravardhan
Modified: 2019-03-04 10:47 UTC (History)
2 users (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description indravardhan 2015-07-28 09:48:56 UTC
We have noticed a persistent problem with JMeter. Threads continue to build past the ramp-up period.

Below are the logs for one group.
$ grep "Starting thread group number 1" *.log
2015/07/21 12:21:10 INFO  - jmeter.threads.ThreadGroup: Starting thread group number 1 threads 39 ramp-up 300 perThread 7692.3076 delayedStart=false 

$ grep "Thread started: Group1" *.log
2015/07/21 12:21:13 INFO  - jmeter.threads.JMeterThread: Thread started: Group1 1-1 
2015/07/21 12:21:23 INFO  - jmeter.threads.JMeterThread: Thread started: Group1 1-2 
2015/07/21 12:21:33 INFO  - jmeter.threads.JMeterThread: Thread started: Group1 1-3 
2015/07/21 12:21:43 INFO  - jmeter.threads.JMeterThread: Thread started: Group1 1-4 
2015/07/21 12:21:53 INFO  - jmeter.threads.JMeterThread: Thread started: Group1 1-5 
2015/07/21 12:22:03 INFO  - jmeter.threads.JMeterThread: Thread started: Group1 1-6 
2015/07/21 12:22:13 INFO  - jmeter.threads.JMeterThread: Thread started: Group1 1-7 
2015/07/21 12:22:23 INFO  - jmeter.threads.JMeterThread: Thread started: Group1 1-8 
2015/07/21 12:22:32 INFO  - jmeter.threads.JMeterThread: Thread started: Group1 1-9 
2015/07/21 12:22:42 INFO  - jmeter.threads.JMeterThread: Thread started: Group1 1-10 
2015/07/21 12:22:52 INFO  - jmeter.threads.JMeterThread: Thread started: Group1 1-11 
2015/07/21 12:23:02 INFO  - jmeter.threads.JMeterThread: Thread started: Group1 1-12 
2015/07/21 12:23:12 INFO  - jmeter.threads.JMeterThread: Thread started: Group1 1-13 
2015/07/21 12:23:22 INFO  - jmeter.threads.JMeterThread: Thread started: Group1 1-14 
2015/07/21 12:23:31 INFO  - jmeter.threads.JMeterThread: Thread started: Group1 1-15 
2015/07/21 12:23:41 INFO  - jmeter.threads.JMeterThread: Thread started: Group1 1-16 
2015/07/21 12:23:51 INFO  - jmeter.threads.JMeterThread: Thread started: Group1 1-17 
2015/07/21 12:24:01 INFO  - jmeter.threads.JMeterThread: Thread started: Group1 1-18 
2015/07/21 12:24:11 INFO  - jmeter.threads.JMeterThread: Thread started: Group1 1-19 
2015/07/21 12:24:21 INFO  - jmeter.threads.JMeterThread: Thread started: Group1 1-20 
2015/07/21 12:24:30 INFO  - jmeter.threads.JMeterThread: Thread started: Group1 1-21 
2015/07/21 12:24:40 INFO  - jmeter.threads.JMeterThread: Thread started: Group1 1-22 
2015/07/21 12:24:50 INFO  - jmeter.threads.JMeterThread: Thread started: Group1 1-23 
2015/07/21 12:25:04 INFO  - jmeter.threads.JMeterThread: Thread started: Group1 1-24 
2015/07/21 12:25:10 INFO  - jmeter.threads.JMeterThread: Thread started: Group1 1-25 
2015/07/21 12:25:20 INFO  - jmeter.threads.JMeterThread: Thread started: Group1 1-26 
2015/07/21 12:25:30 INFO  - jmeter.threads.JMeterThread: Thread started: Group1 1-27 
2015/07/21 12:25:40 INFO  - jmeter.threads.JMeterThread: Thread started: Group1 1-28 
2015/07/21 12:25:50 INFO  - jmeter.threads.JMeterThread: Thread started: Group1 1-29 
2015/07/21 12:26:00 INFO  - jmeter.threads.JMeterThread: Thread started: Group1 1-30 
2015/07/21 12:26:10 INFO  - jmeter.threads.JMeterThread: Thread started: Group1 1-31 
2015/07/21 12:26:19 INFO  - jmeter.threads.JMeterThread: Thread started: Group1 1-32 
2015/07/21 12:26:29 INFO  - jmeter.threads.JMeterThread: Thread started: Group1 1-33 
2015/07/21 12:26:39 INFO  - jmeter.threads.JMeterThread: Thread started: Group1 1-34 
2015/07/21 12:26:49 INFO  - jmeter.threads.JMeterThread: Thread started: Group1 1-35 
2015/07/21 12:26:59 INFO  - jmeter.threads.JMeterThread: Thread started: Group1 1-36 
2015/07/21 12:27:09 INFO  - jmeter.threads.JMeterThread: Thread started: Group1 1-37 
2015/07/21 12:27:19 INFO  - jmeter.threads.JMeterThread: Thread started: Group1 1-38 
2015/07/21 12:27:29 INFO  - jmeter.threads.JMeterThread: Thread started: Group1 1-39 

1) Here time between two threads is 10 seconds instead of 7692.3076(8 seconds if we use ceil).
2) These threads are stared in loop. So total time taken to launch all threads will be Ramp time + loop time(time to makeThread). Please check blow source.

org.apache.jmeter.threads.ThreadGroup#start()
final int numThreads = getNumThreads();
            final int perTthreadDelay = Math.round(((float) (getRampUp() * 1000) / (float) numThreads));
            for (int i = 0; running && i < numThreads; i++) {
                if (i > 0) {
                    pause(perTthreadDelay); // ramp-up delay (except first)
                }
                if (usingScheduler && System.currentTimeMillis() > endtime) {
                    break; // no point continuing beyond the end time
                }
                .
                .
                newThread.start();
            }
        }
        
We can modify perThreadDelay for each iteration instead of fixed value.
            final float rampUpOrg = (float) (getRampUp() * 1000);
            final long currentTime = System.currentTimeMillis();
            for (int i = 0; running && i < numThreads; i++) {
                if (i > 0) {
                	final float elapsed = System.currentTimeMillis() - currentTime; 
                	final int perThreadDelay = Math.round(((float) (rampUpOrg - elapsed) / (float) (numThreads - i)));
                    pause(perThreadDelay); // ramp-up delay (except first)
                }
                .
                .
                newThread.start();
            }
        }
Comment 1 Philippe Mouawad 2015-08-21 12:35:55 UTC
Bug validated.
Comment 2 Stuart Kenworthy 2017-02-13 13:51:20 UTC
Do we have any movement on this bug? My test rig is currently suffering heavily from this bug and https://bz.apache.org/bugzilla/show_bug.cgi?id=58182 which is impacting my ability to run multiple thread groups in a planned amount of time.
Comment 3 Philippe Mouawad 2019-03-03 20:23:52 UTC
Author: pmouawad
Date: Sun Mar  3 20:23:18 2019
New Revision: 1854738

URL: http://svn.apache.org/viewvc?rev=1854738&view=rev
Log:
Bug 58183 - Rampup may not be respected if thread take time to start leading to threads continuing to start post ramp up time
Bugzilla Id: 58183

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/threads/ThreadGroup.java
    jmeter/trunk/xdocs/changes.xml
Comment 4 Philippe Mouawad 2019-03-03 20:40:22 UTC
To reproduce this bug, add an artificial delay after newThread.start() and see that rampup is not correct anymore.