Skip to content
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

Change find to ls -r in 30[0]_create_extlinux.sh #1161

Closed
lrirwin opened this issue Jan 10, 2017 · 4 comments
Closed

Change find to ls -r in 30[0]_create_extlinux.sh #1161

lrirwin opened this issue Jan 10, 2017 · 4 comments

Comments

@lrirwin
Copy link

lrirwin commented Jan 10, 2017

  • rear version (/usr/sbin/rear -V): 1.18 forward

  • Brief description of the issue:
    When "backup" folders exist, using "find" takes a long time.
    Suggest this change at line 164 in output/USB/Linux-i386/30[0]_create_extlinux.sh:

- for file in $(cd $BUILD_DIR/outputfs; find rear/*/* -name syslinux.cfg); do
+ for file in $(cd $BUILD_DIR/outputfs; ls -r rear/*/*/syslinux.cfg); do

This is much quicker when the backup folders contain thousands of files.
It also accomplishes part of the TODO mentioned in the script.
Thanks for all you do!

@jsmeix
Copy link
Member

jsmeix commented Jan 11, 2017

In general regarding using 'ls' versus 'find'
when its argument contains a wildcard '*' see
https://raw.githubusercontent.com/rear/rear/master/usr/share/rear/prep/NETFS/default/070_set_backup_archive.sh
(excerpt)

# Here things like 'find /path/to/dir -name '*.tar.gz' | sort' are used because
# one cannot use bash globbing via commands like 'ls /path/to/dir/*.tar.gz'
# because /usr/sbin/rear sets the nullglob bash option which leads to plain 'ls'
# when '/path/to/dir/*.tar.gz' matches nothing (i.e. when no backup file exists)
# so that then plain 'ls' would result nonsense.

I.e. before calling

ls -r rear/*/*/syslinux.cfg

one would need to ensure that "rear/*/*/syslinux.cfg"
does never evaluate to nothing - i.e. an additional test
would be needed before calling "ls -r rear/*/*/syslinux.cfg".

Comparison how much time is actually saved
(on my test system):
with "find"

real    0m0.007s
user    0m0.006s
sys     0m0.001s

with "ls -r"

real    0m0.018s
user    0m0.015s
sys     0m0.002s

Surprise!
With "ls -r" ist is actually much slower.

But even if it was faster with "ls -r"
the whole stuff would be about saving
at most a few thousandths of a second
which is not worth any effort.

@jsmeix jsmeix closed this as completed Jan 11, 2017
@jsmeix
Copy link
Member

jsmeix commented Jan 11, 2017

@lrirwin
can you explain what you mean with
"backup folders contain thousands of files"?

@lrirwin
Copy link
Author

lrirwin commented Jan 11, 2017 via email

@jsmeix
Copy link
Member

jsmeix commented Jan 12, 2017

By guessing from your comments it seems
you use rysnc as backup method and that results
very many individual files while I use 'tar' so that
I get only a few tar archives so that for me the
whole difference is about a few millisecods.

I really helps to provide the information as requested in
https://github.com/rear/rear/blob/master/.github/ISSUE_TEMPLATE.md
to aviod wasting time with guesswork.

Furthermore preferably provide your proposed changes
as GitHub pull requests which also makes it easier for us
to see what you actually like to change.

Finally see
https://github.com/rear/rear/wiki/Coding-Style
so that over the time the ReaR code can get better step by step.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants