Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jmeter threads use overloaded run method but not CachedThreadPool #4785

Closed
asfimport opened this issue May 20, 2018 · 7 comments
Closed

jmeter threads use overloaded run method but not CachedThreadPool #4785

asfimport opened this issue May 20, 2018 · 7 comments

Comments

@asfimport
Copy link
Collaborator

Srijon (Bug 62390):
jmeter threads use overloaded run method to implement multithreading. This makes it impossible to pause/restart the threads. Implementing threads by using CachedThreadPool will make it possible to pause/restart the threads.

OS: Mac OS X 10.1

Duplicated by:

@asfimport
Copy link
Collaborator Author

Srijon (migrated from Bugzilla):
/* This is the original way multithreading was implemented in jMeter by implementing the Runnable interface

public void runTest() throws JMeterEngineException {
    if (host != null){
        long now=System.currentTimeMillis();
        System.out.println("Starting the test on host " + host + " @ "+new Date(now)+" ("+now+")"); // NOSONAR Intentional
    }
    try {
        Thread runningThread = new Thread(this, "StandardJMeterEngine");
        runningThread.start();
    } catch (Exception err) {
        stopTest();
        throw new JMeterEngineException(err);
    }
}

*/

/This is the proposed way to implentation using executors, this will allow jmeter threads to be paused during execution/

  @Override
public void runTest() throws JMeterEngineException {
    if (host != null){
        long now=System.currentTimeMillis();
        System.out.println("Starting the test on host " + host + " @ "+new Date(now)+" ("+now+")"); // NOSONAR Intentional
    }
    
    ExecutorService execService = Executors.newCachedThreadPool(); //using newCachedThreadPool to implement multi-threading in jMeter
    execService.execute(this);
    
}

@asfimport
Copy link
Collaborator Author

@vlsi (migrated from Bugzilla):
@srijon, would you please clarify what do you mean by "pause/restart the threads"?

@asfimport
Copy link
Collaborator Author

Srijon (migrated from Bugzilla):
In the commercial tools that I have used, after starting a test with 100 threads(virtual users), if I see too much load on the server then I am able to pause 50 threads. On pausing the threads, the threads stop generating load. Then once I feel that the server is performing better I can restart the 50 paused threads.

This gives a lot of flexibility to the performance test engineer, to tune the load when he/she does not know what is a good load. Or if the server is not functioning properly then he/she is able to reduce the load instantly without having to stop the test entirely.

@asfimport
Copy link
Collaborator Author

@vlsi (migrated from Bugzilla):

if I see too much load on the server then I am able to pause 50 threads

That is interesting.

However I do not see how the proposed changes correlate with the "pausing/resuming threads on the fly" feature.

@asfimport
Copy link
Collaborator Author

Srijon (migrated from Bugzilla):
Pausing/restarting is not fully implemented. I could not find a way to implement pausing/restarting with the way threads is currently implemented in jmeter. Current way jmeter threads are running in fire and forget mode, this will execute load test fine, but cannot be paused.

But because there is lot of code written around this fire and forget mode of multithreading, I want to just introduce CachedThreadPool in the first iteration. If there are any complains from users it can be rolled back. There are other ways to implement multithreading also which will support pausing/restarting. This is my thinking, so I just tried to make one change.

But somehow build is failing, I am still not used to jmeter build process and trying to understand the code and test cases around it. If you can help please do.

@asfimport
Copy link
Collaborator Author

@FSchumacher (migrated from Bugzilla):
JMeter depends on the current threading model in a lot of places. It basically treats one thread as one user and has done this for a long time. Plugins might depend on this feature by using ThreadLocals (JMeter internally does this in a few places).

So this is not an easy task.

If you want to pause threads you could implement this by using a PreProcessor with some sort of pausing functionality based upon the thread id or the current running threads.

@asfimport
Copy link
Collaborator Author

@pmouawad (migrated from Bugzilla):
Hello,
Marking as duplicate of #2400.

If you want help on implementing feature, you should start a discussion on dev mailing list with your ideas, and proposals, we'll be happy to help.

If you're new to JMeter code base, starting with the Threading Model is not the good way to start IMO as it is complex and critical.

I'll add comments on other bugs.
Regards

This bug has been marked as a duplicate of #2400

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant