ManManson commented on code in PR #13796:
URL: https://github.com/apache/arrow/pull/13796#discussion_r939511196


##########
cpp/src/arrow/filesystem/localfs.cc:
##########
@@ -309,6 +313,202 @@ Result<std::vector<FileInfo>> 
LocalFileSystem::GetFileInfo(const FileSelector& s
   return results;
 }
 
+namespace {
+
+/// Workhorse for streaming async implementation of `GetFileInfo`
+/// (`GetFileInfoGenerator`).
+///
+/// There are two variants of async discovery functions suported:
+/// 1. `DiscoverPartitionFiles`, which parallelizes traversal of individual 
directories
+///    so that each directory results are yielded as a separate 
`FileInfoGenerator` via
+///    an underlying `DiscoveryImplIterator`, which delivers items in chunks 
(default size
+///    is `kBatchSize == 1K` items).

Review Comment:
   Getting just directory entries (`linux_dirent`) from linux kernel is 
extremely fast, even though we use regular `readdir`, which fetches the items 
one-by-one, and don't use `getdents` syscall directly, which is capable of 
yielding multiple entries at once and should be even faster.
   
   For example, on my machine, fetching contents of a directory with 10M files 
completes in less than 2 seconds, which is acceptable, I think.
   
   The most time-consuming part is `stat`-ing individual files, which should be 
done sequentially by arrow code and there isn't really a _get 100000 items from 
the kernel_ option, so the batching resides on our part, too.
   
   So, the "chunk" is a vector of `FileInfo`:s, which is the result of 
`stat`-ing these files. The directory iterator caches dirents on the first call 
upon its initialization, there's no additional overhead after that.  



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to