How to find out my Process Id is running on Which Physical CPU?

I have two Physical CPU in one of my Server. I see both of them have 8 Virtual processor associated with them. I have a few query.

  1. How do I find the job associated with my process Id is running on which CPU ?
  2. MY job is CPU extensive , so can it use both the CPUs and their Virtual processor or will it run on one of the CPU and virtual processor?
  3. If the job is allowed to run on both CPUs and their Virtual processor, Can lead to performance degradation as data will be exchanged between them.
  4. I tried to find CPU utilization related information by using mpstat where “wt” column gives the “Ideal time for CPU during Read/Write operation” but that always fetches me 0 value. Can you suggest any other command through which I can monitor CPU utilization for my process id? I have seen top, mpstat. For using and analysing statistic in readable form from procstat What can I do ?

Answer

How do i find the job associated with my process Id is running on which CPU ?

You can only do this with JNA or JNI.

MY job is CPU extensive , so can it use both the CPUs and their Virtual processor or It Will Run on one of the CPU and Virtual processor.

If you have only one thread, it will use only one logical thread. If you have more threads which are busy it can use more logical threads (possibly all your CPUs)

If the job is allowed to run on both CPUs and their Virtual processor, Can lead to performance degradation as Data will be excahnged between them.

Yes.

I tried to find CPU utilization related information by using mpstat where “wt” coloumn gives the “Ideal time for CPU during Read/Write operation” but that always fetches me 0 value.

The read/write delay is to IO devices, not between CPUs.

Can you suggest any other command through which i can monitor CPU utilization for my process id . I have seen top , mpstat.

They are the best you can get.

For using and analysing statistic in readable form from procstat What can i do ?

Assuming you have used a commercial profiler and it runs as efficiently as you can make it…

You need to create micro-benchmarks to see how using one thread or more runs on your system. This will give you an idea of how to scales and if it doesn’t scale, you have to do further analysis to determine why. You won’t be able to determine this using an analysis tool.

EDIT: If you want examples of how to use thread affinity, JNI or JNA you can try https://github.com/peter-lawrey/Java-Thread-Affinity

Note: it works for Linux.

Leave a Reply

Your email address will not be published. Required fields are marked *