日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux rsync删文件速度,为什么用rsync删除大量文件的时候比用rm快

發布時間:2023/12/1 linux 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux rsync删文件速度,为什么用rsync删除大量文件的时候比用rm快 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

為什么用rsync刪除大量文件的時候比用rm快

今天研究怎么在Linux下快速刪除大量文件,

搜到很多人都說可以用rsync來刪除大量文件,

速度比rm要快很多,但是沒有人說為什么,

仔細研究了一下原因,總結起來大概就是,一個是列出文件的時候,

在文件非常多的時候會導致慢, 另外就是刪除導致B樹rebanlance導致開銷

rsync減少了這種開銷,所以速度比rm要快

==轉===========

rm on a directory with millions of files

When a directory needs to be listed readdir() is called on the

directory which yields a list of files. readdir is a posix call,

but the real linux system call being used here is called

'getdents'. Getdents list directory entries by filling a buffer is

entries.

The problem is mainly down to the fact that that readdir()

uses a fixed buffer size of 32Kb to fetch files. As a directory

gets larger and larger (the size increases as files are added) ext3

gets slower and slower to fetch entries and additional readdir's

32Kb buffer size is only sufficient to include a fraction of the

entries in the directory. This causes readdir to loop over and over

and invoke the expensive system call over and over.

。。。。

I revisited this today, because most filesystems store their

directory structures in a btree format, the order of which you

delete files is also important. One needs to avoid rebalancing the

btree when you perform the unlink.

As such I added a sort before deletes occur. The program will

now (on my system) delete 1000000 files in 43 seconds. The closest

program to this was rsync -a --delete which took 60 seconds (which

also does deletions in-order, too but does not perform an efficient

directory lookup).

Efficiently delete large directory containing thousands of

files

linux-快速刪除五十萬+文件的方法

linux下面快速刪除大量文件及快速復制大量小文件

總結

以上是生活随笔為你收集整理的linux rsync删文件速度,为什么用rsync删除大量文件的时候比用rm快的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。