当前位置:网站首页>Reasonably set the number of threads 【 rpm 】
Reasonably set the number of threads 【 rpm 】
2022-06-21 14:32:00 【Internet Walker】
1. The speed-up relationship between multithreaded programs and single threaded programs
Amdahl's The laws of
Set the number of processors to N, The program must be serial ( That is, it cannot be parallelized ) The proportion of partial time-consuming to the total time-consuming of the program is p, Then change such a program into a multithreaded program , The theoretical maximum acceleration we can get Smax by
Smax = 1 / (p + (1 - p) / N);
set up T(1) The total time taken to run a single threaded version of the program ,T(N) The total time taken to run the multithreaded version of the program , So the speedup obtained by changing the program to a multithreaded program Smax by
Smax = T(1) / T(N)
N->∞ Smax = 1 / p
2. The principle of setting the number of threads
set up Ncpu Indicates the number of processors in a system , Ncpu The specific value of can be as follows Java Code acquisition :
int nCPU = Runtime.getRuntime().avaliableProcessors();
2.1 about CPU Intensive thread , You can set the number of threads to Ncpu + 1;
2.2 about I/O Intensive thread , Priority is given to setting the number of threads to 1, Only when one thread is not enough, count the threads to 2 * Ncpu near
2.3 Settings for software with processor utilization thresholds
Nthreads = Ncpu * Ucpu * (1 + WT / ST)
Nthreads A reasonable size for the number of threads , Ncpu by CPU number , Ucpu Target CPU The usage rate of (0 < Ucpu <= 1), WT(Wait Time) Waiting for program ( Wait for I/O Operating results ) Length of time on , ST(Service Time) The length of time that the program actually uses the processor to perform calculations . In practice , We can use jvisualvm Calculated from the monitoring data provided WT/ST Value .
边栏推荐
- CSDN is the only one: detailed tutorial teaching on how to connect multiple mobile phones by appium+pytest+allure+jenkins
- Three questions for learning new things
- HSV color model and color component range in opencv
- Configuring MySQL master-slave and implementing semi synchronous replication in docker environment
- Installation of MySQL 8.0.19 under alicloud lightweight application server linux-centos7
- T32 add toolbar button
- Dplayer development barrage background
- Add SSL security certificate to web site
- Qt-5-multi window programming
- Redisson distributed lock design from a bug
猜你喜欢
![[Goo Goo donkey takeout rebate system] customer service configuration tutorial of takeout CPS project - (attached with picture and text building tutorial)](/img/54/d30b9c08e46760dac8c3405716941f.jpg)
[Goo Goo donkey takeout rebate system] customer service configuration tutorial of takeout CPS project - (attached with picture and text building tutorial)
![Cool background shadow effect [second with layered feeling] [picture hover style]](/img/ca/d68f2cf9f9af7b9346032b2a6e120b.jpg)
Cool background shadow effect [second with layered feeling] [picture hover style]

CSDN is the only one: detailed tutorial teaching on how to connect multiple mobile phones by appium+pytest+allure+jenkins

Postman testing websocket interface

Compile time annotation automatically generates dataholder

Qt-5-multi window programming

Declare war on uncivilized code I

Redisson distributed lock design from a bug

Nmap scan port tool

Usage of SED (replacement, deletion of text content, etc.)
随机推荐
网上开户安全吗?新手可以开账户吗
How to write a rotation chart
Three questions for learning new things
T32 add toolbar button
. bash_ profile
ARP interaction process
Vscade, open a folder or workspace... (file - > open folder) solution
How to unit test non pure functions -- unittest
Chapter 4 - network layer
Cool background shadow effect [second with layered feeling] [picture hover style]
C#&. Net to implement a distributed event bus from 0 (1)
NPM package management configuration file [package.json and node\u modules configuration details and how to develop their own packages and publish them on NPM]
Judge password strength - Optimization
Never change
SSH based command operation
Chapter 2 - physical layer (I)
Taobao secsha plug-in
T32 custom menu bar
Simplified crud using code generation
Nmap scan port tool