The directory traversal performs a .metadata() on each entry to check whether it is a directory, which results in a syscall. This is extremely wasteful since DirEntry::file_type can grab the file type directly from the readdir results which are obtained in batches via getdents syscall, i.e. only 1 syscall every N directory entries.
An additional problem is that there are multiple metadata() calls. They are not cached on the file descriptor, so each call results in an additional syscall.