JVM Tutorials - Herong's Tutorial Examples - Version 4.23, by Dr. Herong Yang
Multi-Thread Process on 2-CPU-4-Thread Machine
This section provides a tutorial example on how a multi-threaded process behaves on a 2-CPU-4-Thread architecture. A Java process with more than 4 CPU intensive threads gets the same total productivity rate as 4 threads.
Okay, time to play with 3, 4 and more threads.
1. Close all applications on the system.
2. Launch MultithreadingCpuRunner.java with 3 threads.
C:\>"\Program Files\Java\jdk1.7.0_45\bin\java" MultithreadingCpuRunner 1000 3 Thread parameter: 1000 Number of threads: 3 Seconds | Productivity per thread | Total | Average ... 226 | 467 791 513 | 1773 | 1773 227 | 466 754 544 | 1772 | 1773 228 | 467 803 502 | 1775 | 1773 229 | 467 757 548 | 1772 | 1773 230 | 466 815 491 | 1773 | 1773 ...
These performance numbers are expected based on the single thread performance and how Windows allocates CPU-Threads. The expectation is that 3 CPU-Threads are allocated with a maximum of (100+100+11)% CPU execution power. That means a maximum of 885*211% = 1867 productivity.
3. Stop and start again MultithreadingCpuRunner.java with 4 threads.
C:\>"\Program Files\Java\jdk1.7.0_45\bin\java" MultithreadingCpuRunner 1000 4 Thread parameter: 1000 Number of threads: 4 Seconds | Productivity per thread | Total | Average ... 165 | 461 454 459 462 | 1838 | 1854 166 | 466 444 464 466 | 1842 | 1854 167 | 466 446 464 467 | 1844 | 1854 168 | 466 463 466 467 | 1863 | 1854 169 | 466 462 465 467 | 1862 | 1854 ...
These performance numbers are also expected based on the single thread performance and how Windows allocates CPU-Threads. The expectation is that 4 CPU-Threads are allocated with a maximum of (100+11+100+11)% CPU execution power. That means a maximum of 885*222% = 1965 productivity.
4. Stop and start again MultithreadingCpuRunner.java with 8 threads.
C:\>"\Program Files\Java\jdk1.7.0_45\bin\java" MultithreadingCpuRunner 1000 8 Thread parameter: 1000 Number of threads: 8 Seconds | Productivity per thread | Total | Average ... 136 | 465 167 173 148 142 467 150 140 | 1853 | 1853 137 | 463 143 142 145 142 466 174 176 | 1856 | 1853 138 | 464 136 146 154 172 466 151 156 | 1850 | 1853 139 | 464 161 144 178 158 466 139 140 | 1854 | 1853 140 | 464 163 169 149 145 466 151 143 | 1851 | 1853 ...
These performance numbers still match our expectation based on the single thread performance and how Windows allocates CPU-Threads. The expectation is that 4 CPU-Threads are allocated with a (100+11+100+11)% CPU execution power. The total productivity should stay at the same level as running it in 4 threads.
Conclusion: On a 2-CPU-4-Thread machine, HotSpot 1.7 JVM on Windows 7 supports the following default behavior for CPU intensive process threads:
Last update: 2014.
Table of Contents
Downloading and Installing JDK 1.8.0 on Windows
Downloading and Installing JDK 1.7.0 on Windows
java.lang.Runtime Class - The JVM Instance
java.lang.System Class - The Operating System
ClassLoader Class - Class Loaders
Class Class - Class Reflections
JRockit JVM 28.2.7 by Oracle Corporation
Memory Management and Garbage Collectors
JVM Stack, Frame and Stack Overflow
Thread Testing Program and Result
►CPU Impact of Multi-Thread Applications
PrimeCalculator.java - CPU Intensive Process
CPU Intensive Process - 1 Thread per CPU
Single Thread Process on 2-CPU-4-Thread Machine
Two-Thread Process on 2-CPU-4-Thread Machine
►Multi-Thread Process on 2-CPU-4-Thread Machine
Multi-Thread Process Slows Down System Response Time
Multi-Thread Process Running on JRockit JVM
I/O Impact of Multi-Thread Applications
Micro Benchmark Runner and JVM Options
Micro Benchmark Tests on "int" Operations
Micro Benchmark Tests on "long" Operations
Micro Benchmark Tests in JIT Compilation Mode