Thanks to visit codestin.com
Credit goes to github.com

Skip to content

lsfd: *early* file path filter #3328

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

masatake
Copy link
Member

@masatake masatake commented Dec 13, 2024

Partial solves #2567.

$  ./lsfd /dev/null | head -3
COMMAND             PID   USER ASSOC  XMODE TYPE SOURCE MNTID INODE NAME
pipewire          12620 yamato     0 r-----  CHR  mem:3    34     4 /dev/null
wireplumber       12621 yamato     0 r-----  CHR  mem:3    34     4 /dev/null
$  ./lsfd -- /dev/null | head -3
COMMAND             PID   USER ASSOC  XMODE TYPE SOURCE MNTID INODE NAME
pipewire          12620 yamato     0 r-----  CHR  mem:3    34     4 /dev/null
wireplumber       12621 yamato     0 r-----  CHR  mem:3    34     4 /dev/null
$  ./lsfd -- /dev/zero | head -3
COMMAND     PID   USER ASSOC  XMODE TYPE SOURCE MNTID INODE NAME
dd      2434997 yamato     0 r-----  CHR  mem:5    34     6 /dev/zero

This feature is not implemented as a syntax-sugar for -Q.
The early filter works in the "collecting"-information stage.
I expected the early filter to work much faster than -Q 'NAME == "/dev/zero", a filter working in the "post-collecting" information stage.

# time ./lsfd | wc -l
216088

real	0m4.811s
user	0m3.638s
sys	0m1.196s
# time ./lsfd -Q 'NAME == "/dev/zero"' | wc -l
5

real	0m1.605s
user	0m0.702s
sys	0m0.893s
# time ./lsfd -- /dev/zero | wc -l
5

real	0m0.977s
user	0m0.439s
sys	0m0.539s

However, the difference between -Q and -- was much smaller than I expected.

Is the early filter mechanism a way to go?

TODO:

  • test cases
  • update lsfd(1)

@masatake masatake force-pushed the lsfd--early-path-filter branch from 1923f01 to 2f9aa6d Compare December 26, 2024 20:44
@masatake masatake force-pushed the lsfd--early-path-filter branch from 2f9aa6d to 494b8d8 Compare January 8, 2025 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant