Hacker News new | ask | show | jobs
by osswid 1768 days ago
ls -f
1 comments

       -f      do not sort, enable -aU, disable -ls --color
       
       -a      do not ignore entries starting with .
       -U      do not sort; list entries in directory order
       -l      use a long listing format
       -s      print the allocated size of each file, in blocks
       --color colorize the output
I assume you mean to imply that by turning off sorting/filtering/formatting ls will run in a more optimized mode where it can avoid buffering and just dump the dentries as described in the article?
Yeah, exactly. OP is changing 3 variables and concluding that getdirent buffer size was the significant one, but actually the problem was likely (1) stat calls, for --color, and (2) buffer and sort, which adds O(N log N) sorting time to the total run+print time. (Both of which are avoided by using getdirent directly.)