Details
-
Improvement
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
3.0.0
Description
When using DataFrameReader#csv to read many S3 files (in my case 300k), I've noticed that it took about an hour for the files to be loaded on the driver.
You can see the timestamp difference when the log from InMemoryFileIndex occurs from 7:45 to 8:54:
19/09/06 07:44:42 INFO SparkContext: Running Spark version 2.4.4
19/09/06 07:44:42 INFO SparkContext: Submitted application: LoglineParquetGenerator
...
19/09/06 07:45:40 INFO StateStoreCoordinatorRef: Registered StateStoreCoordinator endpoint
19/09/06 08:54:57 INFO InMemoryFileIndex: Listing leaf files and directories in parallel under: [300K files...]
A major source of the bottleneck comes from DataSource#checkAndGlobPathIfNecessary, which will (possibly) glob and do a FileSystem#exists on all the paths in a single thread. On S3, these are slow network calls.
After a discussion on the mailing list [0], it was suggested that an improvement could be to:
- have SparkHadoopUtils differentiate between files returned by globStatus(), and which therefore exist, and those which it didn't glob for -it will only need to check those.
- add parallel execution to the glob and existence checks
I am currently working on a patch that implements this improvement
Attachments
Issue Links
- links to