当前位置:网站首页>Multithread decompression of tar
Multithread decompression of tar
2022-06-12 07:39:00 【Nine in the morning and twelve in the evening】
Hello everyone , I am nine in the morning and twelve in the evening , At present, I am doing operation and maintenance related work . Blogging is to accumulate , I hope you can make progress together !
My home page : Nine in the morning and twelve in the evening
List of articles
About tar
We usually operate on the server , Often used to tar command , This is a Unix And the class Unix Compression packaging tools on the system , You can combine multiple files into one file , The file suffix after packing is also “tar”. It can be used by any user .
meanwhile , It has multiple versions with different compression rates , Such as tar.xz and tar.gz, The former has a higher compression ratio , But there may be compatibility issues .
If you've used tar, Must have this feeling : When you are decompressing or compressing a very large file , It's going to be slow ! This is because tar Decompression is performed by a single thread , If you are decompressing , Use top command , I often see a certain cpu Soar to 100%.

Today we will introduce ,tar Multithreading operation of .
Multithreaded installation
yum -y install pigz
pigz Commands come from English phrases ”parallel implementation of gzip“ Abbreviation , Its function is to extract files for multithreading . Unlike other decompression commands pigz The command supports multi-threaded parallel processing , Year on year gzip It can be fast 60% above , Of course CPU The consumption will also be higher .
# Compressed files
tar --use-compress-program=pigz -cvpf app.tar.gz app
# Unzip the file
tar --use-compress-program=pigz -xvpf app.tar.gz
--use-compress-program=pigz That is to say, it represents pigz Tools , What is the effect , Let's look forward to
Results test
We can write a script , Calculation and use pigz And unused time .
#!/bin/bash
echo "starttime: `date +"%Y-%m-%d %H:%M:%S"`" > tar.txt
sleep 5 # Fill in our compression command here
echo "endtime: `date +"%Y-%m-%d %H:%M:%S"`" >> tar.txt
start=`awk '{print $2,$3}' tar.txt | sed -n '1p'`
end=`awk '{print $2,$3}' tar.txt | sed -n '2p' `
echo $start
echo $end
starttime=$(date -d "$start" +%s) # Convert to system time
endtime=$(date -d "$end" +%s)
runtime=$(($endtime-$starttime)) # Calculate program run time
echo $runtime
Single threaded compression
take sleep 5 Replace with tar -cvpf app.tar.gz app/ After execution , The output is 26s
Multithreaded compression
take sleep 5 Replace with tar --use-compress-program=pigz -cvpf app.tar.gz app After execution , The output is 15s

According to the above test results , You can see that the time is shortened 11s. Decompress , My friends can test it by themselves .
It's not easy to code words , I hope you can support one wave for three times . If there is any problem, you can point out , Thank you. !
边栏推荐
- 20220607. 人脸识别
- tar之多线程解压缩
- Test manager defines and implements test metrics
- In depth learning - overview of image classification related models
- 鸿蒙os-第一次培训
- 移动端、安卓、IOS兼容性面试题
- VS2019 MFC IP Address Control 控件繼承CIPAddressCtrl類重繪
- How to stop MySQL service under Linux
- 20220524 backbone深度学习网络骨架
- Paddepaddl 28 supports the implementation of GHM loss, a gradient balancing mechanism for arbitrary dimensional data (supports ignore\u index, class\u weight, back propagation training, and multi clas
猜你喜欢

Decryption game of private protocol: from secret text to plaintext

Generalized semantic recognition based on semantic similarity

BI技巧丨当月期初

Federated meta learning with fast convergence and effective communication

20220526 yolov1-v5

2022 G3 boiler water treatment recurrent training question bank and answers

2022r2 mobile pressure vessel filling test question simulation test platform operation

2022R2移动式压力容器充装试题模拟考试平台操作

Adaptive personalized federated learning paper interpretation + code analysis

Set up a remote Jupiter notebook
随机推荐
2022 electrician (elementary) examination question bank and simulation examination
[college entrance examination] prospective college students look at it, choose the direction and future, and grasp it by themselves
Summary of machine learning + pattern recognition learning (I) -- k-nearest neighbor method
2022R2移动式压力容器充装试题模拟考试平台操作
MySQL index (easy to handle in one article)
Utilize user behavior data
LeetCode笔记:Biweekly Contest 79
Voice assistant -- Qu -- query error correction and rewriting
Thyristor, it is a very important AC control device
謀新局、促發展,桂林綠色數字經濟的頭雁效應
Vs2019 MFC IP address Control Control inherit cipaddressctrl class redessine
Source code learning - [FreeRTOS] privileged_ Understanding of function meaning
Leetcode notes: biweekly contest 79
The first demand in my life - batch uploading of Excel data to the database
Exposure compensation, white increase and black decrease theory
晶闸管,它是很重要的,交流控制器件
Modelants II
Connect to the database but cannot modify the data
2022起重机械指挥考试题模拟考试平台操作
Use case design of software testing interview questions




