3 ms·
There isn't actually an arbitrary limit, it's just that glibc's readdir() implementation is really really slow with millions of files according to the article.
by cmeacham98 5y ago
There isn't actually an arbitrary limit, it's just that glibc's readdir() implementation is really really slow with millions of files according to the article. Presumably if you waited awhile `ls` would eventually get the whole list.
- matheusmoreira 5y agoThe glibc functions are just bad wrappers for the real system calls which no doubt work much more efficiently. I fully expected to find the system call solution in the article and was not disappointed.
- p_l 5y agoit's not readdir() that is slow - it's the way ls needs to load the whole directory into memory then do a bunch of things on it (sorting, calculating column sizes, etc), and depending on what you have in your defaults or passed options it might also try to stat() every of those files first.