lsd: LSD is very slow compared to ls when listing large directories
Listing the Void Linux repo srcpkgs directory (about 12055 directories) takes far longer with lsd than it does with GNU ls.
lsd --color never 1.39s user 0.12s system 99% cpu 1.521 total
lsd 1.42s user 0.12s system 98% cpu 1.559 total
ls 0.01s user 0.02s system 91% cpu 0.034 total
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 20
- Comments: 17 (2 by maintainers)
This is how I looked into the issue of lsd’s bad performance.
I created a directory in /tmp with 10,000 empty files. On my Linux system, /tmp is a tmpfs, and bash was the shell I used.
Then I compared the execution time of
exa,lsd,ls, anduu-lson that directory.The options used were intended to disable features that differ between programs (such as icons and colors) but still display “long” output.
Next I logged the system calls made by each program.
You can see that lsd had many more system calls than the others. It’s strace output was about 176M, so keep that in mind if you test on a directory with more files.
Here’s a count of how many times each system call was made for each program.
I used a spreadsheet to put the strace results in a table for easier comparison.
Here are some of the calls that stood out to me.
grep -F 'readlink(' strace.lsd.txtgrep -E '^(socket|connect)\(' strace.lsd.txt | sort | uniq -c | sort -n | tailgrep -F '/etc/nsswitch.conf' strace.lsd.txt | sort | uniq -c | sort -n | tailgrep -E '^openat\(.+"/' strace.lsd.txt | sort | uniq -c | sort -n | tailtl;dr: WTH?!
+1 to this. I’ve just did the other test: compared lsd and exa when listing long output and tree view:
exa -l -T 2.54s user 6.14s system 47% cpu 18.298 totallsd -l --tree 332.53s user 96.61s system 50% cpu 14:13.04 total(obviously no info from vanilla ls, as it doesn’t have tree functionality).I did it on my 13GB home directory (macOS, so many small files in ~/Library).
No. In my example there were two calls of
lsd: one that uses the config file, and one that ignores it. The intent was to show that neither method has acceptable performance.I added
total-size: falseto my config.yaml, but I didn’t see a difference in performance.Commands:
Output:
as a workaround for now i turned off
total-sizewhich resulted in a 3632x speedup.Here is how
lsdcompares toexaandlsat the moment. Test cases is a directory with 10,376 files (a fuzzing corpus).So plain-old
lsis 400 times faster thanlsd.Since #441 was closed, is there any indication whether this issue will be fixed?
Same here. The time of listing 287188 files:
Whyt
lsdis much slower thanls? Is there anything we can do?Use
stracewithls,exa, andlsdin a large directory, and notice thatlsdis making many more system calls that the other 2.strace ls --color=never -l --sort=none 2> ~/strace.ls.txtstrace exa --color=never --no-icons --long --sort=none 2> ~/strace.exa.txtstrace lsd --color=never --icon=never --long --sort=none 2> ~/strace.lsd.txtwc --lines --total=never strace.*.txt