当前位置:网站首页>Network IO, disk IO
Network IO, disk IO
2022-06-26 07:01:00 【Zuohaifeng blog】
The Internet Io, Sending a network request is common 1 Milliseconds to hundreds of milliseconds . disk io, commonly 5 Milliseconds to hundreds of milliseconds . Two kinds of io Every time the time is not fixed , Even if you take the same data . The Internet Io There may be network fluctuations leading to .
io intensive .cpu Keep making requests , It takes tens or hundreds of milliseconds to wait each time . After getting the data, the processing speed is 1 The subtlety is solved . So most of the time cpu All idling .
One revolution of the local disk is about 5 millisecond , If the data taken is large , Just turn around a lot . There is a lot of time .
before cpu Fetching data from memory is 20 nanosecond , Now it has been raised to the millisecond level . A million fold increase in time .
How to improve cpu Utilization ratio , For example, the network requests a large amount of data ,1 copies . Then create 100 Threads , When the first thread makes a request , Switching thread . Other threads start sending requests in turn . Don't open too many threads . Thread switching required 1 Haos second , It also takes time , And when switching cpu Not working , Threads also increase memory overhead . Creating a thread generally considers cpu The number of nuclear ,cpu Task execution time vs. wasted time . The bigger the number is , The fewer threads you need to open . And because of the thread switching time , So the final result should be tested .
10 Ten thousand data , open 100 Threads , Every thread 1000 A mission . Some threads are fast , Some threads are slow . The fast thread is destroyed after it completes the task . There are many final tasks , Fewer threads . amount to cpu Performance is reduced again . So this allocation of threads is flawed .
What we want is that threads always exist , Then the efficiency will not be low . You can do this , Just don't divide the tasks equally , Each thread handles one task at a time , When it's done , Just go here 10 Take tasks from ten thousand data . Until the task is processed . This is the judgment condition of each thread 10 Whether 10000 data are empty , When it is empty, the thread is destroyed . The thread pool is just used . Thread pools help us manage these threads .
Thread pools generally use bounded queues , This can trigger thread resizing . Then the number of threads in the thread pool when there is no task is 0, When dealing with a task , The number becomes the number of core threads , When the task is finished , Nor will it fall to 0, It also reduces the number of core threads . Then there is the thread pool .
Unbounded queues can be used if there is no time requirement . Like web crawlers , Data processing
边栏推荐
- Promise API for getting started with the web
- unity之EasyAR使用
- Market survey of China's coal to liquid industry and analysis report on investment competitiveness during the "14th five year plan" 2022-2027
- If you meet a female driver who drives didi as an amateur, you can earn 500 yuan a day!
- Past events of Xinhua III
- Dpdk - tcp/udp protocol stack server implementation (I)
- 【特征提取】基于稀疏PCA实现目标识别信息特征选择附matlab源码
- 屏幕共享推荐
- Simple use of enum type in TS
- Rust中的过程宏
猜你喜欢

How to publish function computing (FC) through cloud effect

【yolov4】基于yolov4深度学习网络目标检测MATLAB仿真

DS18B20 details

ZRaQnHYDAe

Analyze 5 indicators of NFT project

Shell programming - user information management

Installation and login of MySQL database

LabVIEW Arduino TCP/IP遠程智能家居系統(項目篇—5)

【图像检测】基于Itti模型实现图像显著性检测附matlab代码

Kotlin compose state recovery remembersaveable and remember
随机推荐
OCA安全联盟(CyberSecurity Mesh)
China imported wine circulation and investment market survey and Future Development Trend Outlook report 2022-2027
~94 zoom
Research Report on market supply and demand and strategy of Chinese amyl cinnamaldehyde (ACA) industry
MySQL basic usage 01
How to publish function computing (FC) through cloud effect
MySQL
LabVIEW Arduino TCP/IP远程智能家居系统(项目篇—5)
面试官:测试计划和测试方案有什么区别?
Research Report on pallet handling equipment industry - market status analysis and development prospect forecast
Rust中的过程宏
解决新版谷歌Chrome浏览器Cookie跨域失效问题
Analysis report on market demand and investment competitiveness of China's cyclohexanone industry (2022 Edition)
Solve the problem of cross domain invalidation of cookies in the new version of Google Chrome browser
Guide to "avoid dismissal during probation period"
【路径规划】基于改进人工势场实现机器人路径规划附matlab代码
Pytorch builds CNN LSTM hybrid model to realize multivariable and multi step time series forecasting (load forecasting)
Deep exploration image theme color extraction
NumPy学习挑战第四关-NumPy数组属性
Numpy learning challenge level 5 - create array