4

I have a java system doing lot of i/o operations. I do understand that non CPU bound tasks can benefit from # of threads more than #CPUs.

As I/O operations time is non deterministic(I don't know how many threads I should initialize in pool). I want to measure the context switching happening due to number of threads I initialized in my java program.

Finally as result of that context switching overhead I want to tune the size of thread pool.

1
  • You can add System.currentTimeMillis() to logs to measure how much time you need to complete tasks and simply experiment with thread pool size. Beggining conditions (inputs) should be the same. Commented Jul 31, 2017 at 7:54

2 Answers 2

1

There are two options here:

  • you engage in "real" profiling. Meaning: you learn about tools that help you monitoring such aspects of your application. See here for starters; or there for a broader variety of tools.
  • you simply experiment. Setup your pool size to 100, 500, 1000. And see what happens. You see, when you have good insight on the clients using your system, it might sufficient to just tune that parameter and see how/if it affects your users.

Obviously, option 1 results in better understanding - but it also requires more work.

Sign up to request clarification or add additional context in comments.

Comments

0

You can use good profiling tools like appdynamics to measure how much time of your program is spending in the IO and CPU wait and get lots of interesting insights about your program and accordingly optimize your code. Once you get insights about your code, then you can gradually test with different size of thread pool and see the effect in Appdynamics and choose the best size, which gives you best performance.

Note:- Appdynamics provides free trial version and comes as a SAAS. I've used it multiple times and likes it a lot.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.