bugfindutils - Bugs: bug #58197, "find" fails to optimize...

 
 

bug #58197: "find" fails to optimize "-path /usr/foo -o -path /usr/bar" to "-regex '/usr/\(foo\|bar\)'"

Submitted by:  None
Submitted on:  Fri 17 Apr 2020 04:26:34 PM UTC  
 
Category:  find Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Originator Name:  Askar Safin Originator Email:  -email is unavailable-
Open/Closed:  Open Release:  4.7.0
Fixed Release:  None

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Fri 17 Apr 2020 04:26:34 PM UTC, original submission:  

I often search my home directory using command similar to this:

find -O3 -L /home/user '(' -path ... -o -path ... -o -name ... -o -name ... -o lots-of-other-paths-i-want-to-skip.......... ')' -prune -o -print | xargs grep ...

So performance of this command is very important for me. Today I discovered this: if I replace pattern "-path ... -o -path ..." with single "-regex" option, that "find" command starts to work faster. Here is minimal reproducer on my system:

user@comp:~$ time -p find -O3 -L /usr '(' -path /usr/foo -o -path /usr/bar ')' -prune -o -print > /dev/null
find: File system loop detected; ‘/usr/bin/X11’ is part of the same file system loop as ‘/usr/bin’.
find: File system loop detected; ‘/usr/lib/llvm-11/build/Debug+Asserts’ is part of the same file system loop as ‘/usr/lib/llvm-11’.
find: File system loop detected; ‘/usr/lib/llvm-11/build/Release’ is part of the same file system loop as ‘/usr/lib/llvm-11’.
find: ‘/usr/lib/ssl/private’: Permission denied
find: ‘/usr/lib/chromium/extensions’: Permission denied
real 1,47
user 0,64
sys 0,82
user@comp:~$ time -p find -O3 -L /usr -regextype grep '(' -regex '/usr/\(bar\|foo\)' ')' -prune -o -print > /dev/null
find: File system loop detected; ‘/usr/bin/X11’ is part of the same file system loop as ‘/usr/bin’.
find: File system loop detected; ‘/usr/lib/llvm-11/build/Debug+Asserts’ is part of the same file system loop as ‘/usr/lib/llvm-11’.
find: File system loop detected; ‘/usr/lib/llvm-11/build/Release’ is part of the same file system loop as ‘/usr/lib/llvm-11’.
find: ‘/usr/lib/ssl/private’: Permission denied
find: ‘/usr/lib/chromium/extensions’: Permission denied
real 1,36
user 0,51
sys 0,84

I don't have dirs /usr/bar and /usr/foo on my system, but still I see substantial speed improvement.

I run both commands on already warm caches, i. e. I already run full find command just before time measurement. I have SSD disks with ext4.

So, "find -O3" is unable to optimize multiple -path options to single -regex option. And this is bad. I don't want to manually replace -path options in my commands, I want "find" to optimize everything.

Steps to reproduce: above
What I see: "1,47" is more than "1,36"
What I expected to see: first command should be as fast as second one

I use Debian Stretch. find --version:

find (GNU findutils) 4.7.0-git
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Eric B. Decker, James Youngman, and Kevin Dalley.
Features enabled: D_TYPE O_NOFOLLOW(enabled) LEAF_OPTIMISATION FTS(FTS_CWDFD) CBO(level=2)

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by None (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

     

     

    No changes have been made to this item

    Back to the top


    Powered by Savane 3.7