当前位置:网站首页>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
边栏推荐
- Differences, advantages and disadvantages between synchronous communication and asynchronous communication
- 【图像分割】基于最大主曲率实现视网膜眼底图像中的血管提取附matlab代码
- STM 32 uses cube to generate Tim to trigger ADC and transmit through DMA
- China polyphenylene oxide Market Development Prospect and Investment Strategy Research Report 2022-2027
- Promise API for getting started with the web
- Six stones Management: exaggerating the achievements, whether the parties themselves know
- SQL基础
- Bugku练习题---MISC---富强民主
- DS18B20 details
- [feature extraction] feature selection of target recognition information based on sparse PCA with Matlab source code
猜你喜欢

Interviewer: what is the difference between a test plan and a test plan?

I use flask to write the website "II"

【图像增强】基于人工多重曝光融合AMEF实现图像去雾附matlab代码

What is data mining?

MySQL

Analyse d'un problème classique

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

How to publish function computing (FC) through cloud effect

LabVIEW Arduino tcp/ip remote smart home system (project part-5)

海量日志采集工具——Flume
随机推荐
China imported wine circulation and investment market survey and Future Development Trend Outlook report 2022-2027
JS download pictures
~94 zoom
Get the first and last days of the current month, and the first and last days of the previous month
Marketing skills: compared with the advantages of the product, it is more effective to show the use effect to customers
Hudi compilation of data Lake architecture
Web technology sharing | webrtc recording video stream
[image enhancement] image defogging based on artificial multiple exposure fusion amef with matlab code
【图像融合】基于梯度能量、局部能量、 PCA三种融合规则实现MRI-CT图像融合附matlab代码
OCA Security Alliance (cybersecurity mesh)
OCA安全联盟(CyberSecurity Mesh)
LabVIEW Arduino TCP/IP遠程智能家居系統(項目篇—5)
Massive log collection tool flume
How to make the main thread wait for the sub thread to execute before executing
[yolov4] matlab simulation of network target detection based on yolov4 deep learning
[image fusion] MRI-CT image fusion based on gradient energy, local energy and PCA fusion rules with matlab code
Research Report on pallet handling equipment industry - market status analysis and development prospect forecast
SQL Basics
[feature extraction] feature selection of target recognition information based on sparse PCA with Matlab source code
【图像融合】基于耦合特征学习的多模式医学图像融合附matlab代码