linux 多线程查找文件

linux 多线程查找文件

我进行了搜索,但找不到类似的东西。

我有巨大的代码库( AOSP 或 Yocto )存储在 ext4 格式的 NVME 驱动器(例如 SAMSUNG 980Pro )中。这些代码库通常由数千个子目录中的数十万个文件组成。

当我使用 find 搜索文件时,我通常会这样做:

find . -iname "filename.txt"

我不想对文件进行操作,我只想找到该文件。

我觉得这不是多线程(如果我错了,请纠正我)。

请注意,我知道搜索文件通常受 IO 限制,但我的驱动器速度很快,并且我相信可以在多个线程中迭代子目录的工具可以显着加快查找结果的速度。

如果我错了,请纠正我。如果我是对的,如果有这样的工具,请告诉我。

答案1

我找到了我正在寻找的工具:https://github.com/sharkdp/fd

这是我在实际系统上的测试结果:

stulluk /media/WORK/RDK/521 $  time find . -iname "dsAudio.c"
./build/tmp/work/mesont5w_5.4_lib32_at301-rdkmllib32-linux-gnueabi/lib32-devicesettings-hal-amlogic-tv/gitAUTOINC+08aefcf7c0-r0/git/dsAudio.c
./build/tmp/work/mesont5w_5.4_lib32_at301-rdkmllib32-linux-gnueabi/lib32-devicesettings/rdkv-2023q2-dunfell+gitrAUTOINC+40fe1c3597-r0/git/rpc/srv/dsAudio.c
./build/tmp/work/mesont5w_5.4_lib32_at301-rdkmllib32-linux-gnueabi/lib32-devicesettings/rdkv-2023q2-dunfell+gitrAUTOINC+40fe1c3597-r0/git/rpc/cli/dsAudio.c
./build/tmp/work/mesont5w_5.4_lib32_at301-rdkmllib32-linux-gnueabi/lib32-devicesettings/rdkv-2023q2-dunfell+gitrAUTOINC+40fe1c3597-r0/git/.pc/AMLTVT5W-134-Volumelevel_setting_to_0.patch/rpc/srv/dsAudio.c
./build/tmp/work/mesont5w_5.4_lib32_at301-rdkmllib32-linux-gnueabi/lib32-devicesettings/rdkv-2023q2-dunfell+gitrAUTOINC+40fe1c3597-r0/git/.pc/0001-Add-audio-default-persistent-settings.patch/rpc/srv/dsAudio.c
./build/tmp/work/armv7at2hf-neon-rdkmllib32-linux-gnueabi/lib32-devicesettings-hal-headers/rdkv-2023q2-dunfell+gitrAUTOINC+40fe1c3597-r0/git/rpc/srv/dsAudio.c
./build/tmp/work/armv7at2hf-neon-rdkmllib32-linux-gnueabi/lib32-devicesettings-hal-headers/rdkv-2023q2-dunfell+gitrAUTOINC+40fe1c3597-r0/git/rpc/cli/dsAudio.c

real    0m11,925s
user    0m4,753s
sys 0m7,103s
stulluk /media/WORK/RDK/521 $  time find . -iname "dsAudio.c"
./build/tmp/work/mesont5w_5.4_lib32_at301-rdkmllib32-linux-gnueabi/lib32-devicesettings-hal-amlogic-tv/gitAUTOINC+08aefcf7c0-r0/git/dsAudio.c
./build/tmp/work/mesont5w_5.4_lib32_at301-rdkmllib32-linux-gnueabi/lib32-devicesettings/rdkv-2023q2-dunfell+gitrAUTOINC+40fe1c3597-r0/git/rpc/srv/dsAudio.c
./build/tmp/work/mesont5w_5.4_lib32_at301-rdkmllib32-linux-gnueabi/lib32-devicesettings/rdkv-2023q2-dunfell+gitrAUTOINC+40fe1c3597-r0/git/rpc/cli/dsAudio.c
./build/tmp/work/mesont5w_5.4_lib32_at301-rdkmllib32-linux-gnueabi/lib32-devicesettings/rdkv-2023q2-dunfell+gitrAUTOINC+40fe1c3597-r0/git/.pc/AMLTVT5W-134-Volumelevel_setting_to_0.patch/rpc/srv/dsAudio.c
./build/tmp/work/mesont5w_5.4_lib32_at301-rdkmllib32-linux-gnueabi/lib32-devicesettings/rdkv-2023q2-dunfell+gitrAUTOINC+40fe1c3597-r0/git/.pc/0001-Add-audio-default-persistent-settings.patch/rpc/srv/dsAudio.c
./build/tmp/work/armv7at2hf-neon-rdkmllib32-linux-gnueabi/lib32-devicesettings-hal-headers/rdkv-2023q2-dunfell+gitrAUTOINC+40fe1c3597-r0/git/rpc/srv/dsAudio.c
./build/tmp/work/armv7at2hf-neon-rdkmllib32-linux-gnueabi/lib32-devicesettings-hal-headers/rdkv-2023q2-dunfell+gitrAUTOINC+40fe1c3597-r0/git/rpc/cli/dsAudio.c

real    0m11,898s
user    0m4,618s
sys 0m7,211s
stulluk /media/WORK/RDK/521 $  time find . -iname "dsAudio.c"
./build/tmp/work/mesont5w_5.4_lib32_at301-rdkmllib32-linux-gnueabi/lib32-devicesettings-hal-amlogic-tv/gitAUTOINC+08aefcf7c0-r0/git/dsAudio.c
./build/tmp/work/mesont5w_5.4_lib32_at301-rdkmllib32-linux-gnueabi/lib32-devicesettings/rdkv-2023q2-dunfell+gitrAUTOINC+40fe1c3597-r0/git/rpc/srv/dsAudio.c
./build/tmp/work/mesont5w_5.4_lib32_at301-rdkmllib32-linux-gnueabi/lib32-devicesettings/rdkv-2023q2-dunfell+gitrAUTOINC+40fe1c3597-r0/git/rpc/cli/dsAudio.c
./build/tmp/work/mesont5w_5.4_lib32_at301-rdkmllib32-linux-gnueabi/lib32-devicesettings/rdkv-2023q2-dunfell+gitrAUTOINC+40fe1c3597-r0/git/.pc/AMLTVT5W-134-Volumelevel_setting_to_0.patch/rpc/srv/dsAudio.c
./build/tmp/work/mesont5w_5.4_lib32_at301-rdkmllib32-linux-gnueabi/lib32-devicesettings/rdkv-2023q2-dunfell+gitrAUTOINC+40fe1c3597-r0/git/.pc/0001-Add-audio-default-persistent-settings.patch/rpc/srv/dsAudio.c
./build/tmp/work/armv7at2hf-neon-rdkmllib32-linux-gnueabi/lib32-devicesettings-hal-headers/rdkv-2023q2-dunfell+gitrAUTOINC+40fe1c3597-r0/git/rpc/srv/dsAudio.c
./build/tmp/work/armv7at2hf-neon-rdkmllib32-linux-gnueabi/lib32-devicesettings-hal-headers/rdkv-2023q2-dunfell+gitrAUTOINC+40fe1c3597-r0/git/rpc/cli/dsAudio.c

real    0m11,880s
user    0m4,598s
sys 0m7,215s
stulluk /media/WORK/RDK/521 $  time fd dsAudio.c
build/tmp/work/armv7at2hf-neon-rdkmllib32-linux-gnueabi/lib32-devicesettings-hal-headers/rdkv-2023q2-dunfell+gitrAUTOINC+40fe1c3597-r0/git/rpc/cli/dsAudio.c
build/tmp/work/armv7at2hf-neon-rdkmllib32-linux-gnueabi/lib32-devicesettings-hal-headers/rdkv-2023q2-dunfell+gitrAUTOINC+40fe1c3597-r0/git/rpc/srv/dsAudio.c
build/tmp/work/mesont5w_5.4_lib32_at301-rdkmllib32-linux-gnueabi/lib32-devicesettings/rdkv-2023q2-dunfell+gitrAUTOINC+40fe1c3597-r0/git/rpc/srv/dsAudio.c
build/tmp/work/mesont5w_5.4_lib32_at301-rdkmllib32-linux-gnueabi/lib32-devicesettings/rdkv-2023q2-dunfell+gitrAUTOINC+40fe1c3597-r0/git/rpc/cli/dsAudio.c
build/tmp/work/mesont5w_5.4_lib32_at301-rdkmllib32-linux-gnueabi/lib32-devicesettings-hal-amlogic-tv/gitAUTOINC+08aefcf7c0-r0/git/dsAudio.c

real    0m4,495s
user    0m23,689s
sys 0m41,132s
stulluk /media/WORK/RDK/521 $  time fd dsAudio.c
build/tmp/work/armv7at2hf-neon-rdkmllib32-linux-gnueabi/lib32-devicesettings-hal-headers/rdkv-2023q2-dunfell+gitrAUTOINC+40fe1c3597-r0/git/rpc/cli/dsAudio.c
build/tmp/work/armv7at2hf-neon-rdkmllib32-linux-gnueabi/lib32-devicesettings-hal-headers/rdkv-2023q2-dunfell+gitrAUTOINC+40fe1c3597-r0/git/rpc/srv/dsAudio.c
build/tmp/work/mesont5w_5.4_lib32_at301-rdkmllib32-linux-gnueabi/lib32-devicesettings/rdkv-2023q2-dunfell+gitrAUTOINC+40fe1c3597-r0/git/rpc/srv/dsAudio.c
build/tmp/work/mesont5w_5.4_lib32_at301-rdkmllib32-linux-gnueabi/lib32-devicesettings/rdkv-2023q2-dunfell+gitrAUTOINC+40fe1c3597-r0/git/rpc/cli/dsAudio.c
build/tmp/work/mesont5w_5.4_lib32_at301-rdkmllib32-linux-gnueabi/lib32-devicesettings-hal-amlogic-tv/gitAUTOINC+08aefcf7c0-r0/git/dsAudio.c

real    0m4,491s
user    0m24,473s
sys 0m40,966s
stulluk /media/WORK/RDK/521 $  time fd -HI dsAudio.c
build/tmp/work/mesont5w_5.4_lib32_at301-rdkmllib32-linux-gnueabi/lib32-devicesettings/rdkv-2023q2-dunfell+gitrAUTOINC+40fe1c3597-r0/git/.pc/0001-Add-audio-default-persistent-settings.patch/rpc/srv/dsAudio.c
build/tmp/work/mesont5w_5.4_lib32_at301-rdkmllib32-linux-gnueabi/lib32-devicesettings/rdkv-2023q2-dunfell+gitrAUTOINC+40fe1c3597-r0/git/.pc/AMLTVT5W-134-Volumelevel_setting_to_0.patch/rpc/srv/dsAudio.c
build/tmp/work/mesont5w_5.4_lib32_at301-rdkmllib32-linux-gnueabi/lib32-devicesettings/rdkv-2023q2-dunfell+gitrAUTOINC+40fe1c3597-r0/git/rpc/srv/dsAudio.c
build/tmp/work/mesont5w_5.4_lib32_at301-rdkmllib32-linux-gnueabi/lib32-devicesettings/rdkv-2023q2-dunfell+gitrAUTOINC+40fe1c3597-r0/git/rpc/cli/dsAudio.c
build/tmp/work/mesont5w_5.4_lib32_at301-rdkmllib32-linux-gnueabi/lib32-devicesettings-hal-amlogic-tv/gitAUTOINC+08aefcf7c0-r0/git/dsAudio.c
build/tmp/work/armv7at2hf-neon-rdkmllib32-linux-gnueabi/lib32-devicesettings-hal-headers/rdkv-2023q2-dunfell+gitrAUTOINC+40fe1c3597-r0/git/rpc/cli/dsAudio.c
build/tmp/work/armv7at2hf-neon-rdkmllib32-linux-gnueabi/lib32-devicesettings-hal-headers/rdkv-2023q2-dunfell+gitrAUTOINC+40fe1c3597-r0/git/rpc/srv/dsAudio.c

real    0m5,446s
user    0m17,727s
sys 0m58,009s
stulluk /media/WORK/RDK/521 $  time fd -HI dsAudio.c
build/tmp/work/armv7at2hf-neon-rdkmllib32-linux-gnueabi/lib32-devicesettings-hal-headers/rdkv-2023q2-dunfell+gitrAUTOINC+40fe1c3597-r0/git/rpc/srv/dsAudio.c
build/tmp/work/armv7at2hf-neon-rdkmllib32-linux-gnueabi/lib32-devicesettings-hal-headers/rdkv-2023q2-dunfell+gitrAUTOINC+40fe1c3597-r0/git/rpc/cli/dsAudio.c
build/tmp/work/mesont5w_5.4_lib32_at301-rdkmllib32-linux-gnueabi/lib32-devicesettings/rdkv-2023q2-dunfell+gitrAUTOINC+40fe1c3597-r0/git/.pc/AMLTVT5W-134-Volumelevel_setting_to_0.patch/rpc/srv/dsAudio.c
build/tmp/work/mesont5w_5.4_lib32_at301-rdkmllib32-linux-gnueabi/lib32-devicesettings/rdkv-2023q2-dunfell+gitrAUTOINC+40fe1c3597-r0/git/.pc/0001-Add-audio-default-persistent-settings.patch/rpc/srv/dsAudio.c
build/tmp/work/mesont5w_5.4_lib32_at301-rdkmllib32-linux-gnueabi/lib32-devicesettings/rdkv-2023q2-dunfell+gitrAUTOINC+40fe1c3597-r0/git/rpc/cli/dsAudio.c
build/tmp/work/mesont5w_5.4_lib32_at301-rdkmllib32-linux-gnueabi/lib32-devicesettings/rdkv-2023q2-dunfell+gitrAUTOINC+40fe1c3597-r0/git/rpc/srv/dsAudio.c
build/tmp/work/mesont5w_5.4_lib32_at301-rdkmllib32-linux-gnueabi/lib32-devicesettings-hal-amlogic-tv/gitAUTOINC+08aefcf7c0-r0/git/dsAudio.c

real    0m5,431s
user    0m19,166s
sys 0m56,250s
stulluk /media/WORK/RDK/521 $  

另请参阅:https://github.com/sharkdp/fd#benchmark

相关内容