Parallelize file metadata inspection in 2-stage reader - #75
Parallelize file metadata inspection in 2-stage reader#75Baptiste-Arnould wants to merge 2 commits into
Conversation
|
Your changes are definitely an improvement and the implementation looks reasonable. There is just a minor thing I would like you to reconsider. You used a cyclic distribution to parallelize. That is OK in general, it is very convenient. But when order is important, it forces you to keep track of indices to reconstruct the original ordering, leading to slightly more convoluted code.. Look at local_infos = []
# Distribute files across reader ranks
count, start = utils_par.blockdist(len(data_list), comm.size, comm.rank)
for i in range(start, start + count):
file_name = data_list[i]
file_shape, file_dtype, file_size = _inspect_file_metadata(file_name, variables[0])
local_infos.append((file_name, file_shape, str(file_dtype), file_size))
# Gather metadata on rank 0
all_infos = comm.gather(local_infos, root=0)and then you need to keep updating a few things to remove the sort call, etc. Would you be willing to explore this approach and update the PR accordingly? |
|
Thanks for the suggestion. I updated the PR to use a block distribution for metadata inspection and made blockdist public. This removes the explicit file indices and sorting step and simplifies the reconstruction on rank 0. |
|
LGTM. @mengaldo Once tests pass (modulo the MPI failures that no one had taken care to fix 🤦 ) I think this one is good to go. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #75 +/- ##
==========================================
+ Coverage 76.84% 76.95% +0.11%
==========================================
Files 16 16
Lines 3532 3549 +17
Branches 465 467 +2
==========================================
+ Hits 2714 2731 +17
Misses 660 660
Partials 158 158 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
This PR parallelizes file metadata inspection during the initialization of the 2-stage reader.
Previously, metadata for all input files were inspected sequentially by rank 0. For datasets containing a large number of files, this can result in significant initialization time.
The metadata inspection is now distributed across the available reader ranks. The resulting metadata are gathered on rank 0 and reordered according to the original file order before constructing
_file_time,_shape,_is_real, and_files_size.The data-reading algorithm itself is unchanged.
Changes
Testing
Tested with MPI on a dataset composed of 11800 files (~250TB in total).
Closes #74