You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was working with @birdsarah on a problem she was having with parquet where saving to parquet caused her workers to die. The issue seemed to be that the metadata results of each write_parquet task were decently large (she had 2500 columns) and she had many partitions (10k) and so accumulating these in memory was causing issues (her workers only had a couple gigs of memory). We eventually found two short-term solutions to this:
Use pyarrow because it doesn't currently handle writing metadata
Use Xarray because the metadata is shared and handled in only one spot
I'd like to record this issue though. I think that as we add metadata support to PyArrow we should be cognizant of these costs. In the future I'd like to see ...
metadata that was smallish in memory
the option to intermediately store only the data that changes between partitions (I'm not sure if there is a substantial difference here though)
maintain the ability to not handle metadata writes
I was imagining a world where a user could request that the metadata be written to disk at the same time as the partition (presumably in the same location) and then at the end of all writes these are all read back and combined for final metadata.
Agreed, it should totally be possible to read the metadata from the output files and stream to a metadata file, rather than aggregate in memory. It would not take too much effort in fastparquet to achieve this, I think, but it would change a bit the model of what is passed around in the dask graph. Note also that this approach is wasteful for the simpler case, since files will need to be re-read, and the footers of each re-parsed for every data file.
I do not know yet what steps we need to take on this but I added this to our work queue so we can work with you to define development work in Apache Arrow to support Dask on this issue
This issue raises an additional concern that that metadata can eventually grow to be prohibitively large in the case where have many partitions, many columns, and small-memory workers. So some modest care should be taken to control size on the Arrow side (though I suspect that this is typical for arrow development) and that Dask should make sure that this behavior is optional. I'll link to the JIRA shortly.
@xhochy Do you mean the Builder classes such as ColumnChunkMetaDataBuilder, RowGroupMetaDataBuilder, FileMetaDataBuilder need to be exposed to Python? I'd be happy to take any pointers on what is needed for resolving ARROW-1983.
@pearu Yes. In the end to create the _metadata we would need to collect the RowGroupMetaData instances from all files, pickle them, send them to a single worker and then create out of all of them a single FileMetaData that is stored as part of an empty Parquet file named _metadata.
Consider, though, that it may well still be useful to have an option not to make column statistics, partly to speed up writing and partly to decrease the metadata size. Fastparquet has this option in dask/fastparquet#259 (which is py3 only, and so not merged), but it is not surfaced.
With #8901, we no longer write _metadata files by default, which should remove this problem. There may be some upstream fixes in pyarrow that could improve the scalability limit of producing the _metadata file, but at some point the full dataset metadata will always become too large for a single worker to process. Other tools like spark have come to the same conclusion and made the same change. Closing.
Activity
birdsarah commentedon Jan 23, 2019
I was imagining a world where a user could request that the metadata be written to disk at the same time as the partition (presumably in the same location) and then at the end of all writes these are all read back and combined for final metadata.
martindurant commentedon Jan 23, 2019
Agreed, it should totally be possible to read the metadata from the output files and stream to a metadata file, rather than aggregate in memory. It would not take too much effort in fastparquet to achieve this, I think, but it would change a bit the model of what is passed around in the dask graph. Note also that this approach is wasteful for the simpler case, since files will need to be re-read, and the footers of each re-parsed for every data file.
wesm commentedon Jan 24, 2019
I do not know yet what steps we need to take on this but I added this to our work queue so we can work with you to define development work in Apache Arrow to support Dask on this issue
mrocklin commentedon Jan 24, 2019
The bigger ask from Arrow generally is to provide per-row-group metadata when writing chunks that we can then collect together to write a full
.metadatafile later when we're finished writing everything down. See https://issues.apache.org/jira/browse/ARROW-1983 .This issue raises an additional concern that that metadata can eventually grow to be prohibitively large in the case where have many partitions, many columns, and small-memory workers. So some modest care should be taken to control size on the Arrow side (though I suspect that this is typical for arrow development) and that Dask should make sure that this behavior is optional. I'll link to the JIRA shortly.
xhochy commentedon Jan 25, 2019
@wesm The main steps to be taken here is to better expose the C++ classes in https://github.com/apache/arrow/blob/master/cpp/src/parquet/metadata.h in Python and adding the ability to write a Parquet file just from this classes without any data again. Both are things people can do that don't have expertise with the inner workings of
parquet-cppbut it will require some pointers.pearu commentedon Apr 11, 2019
@xhochy Do you mean the Builder classes such as ColumnChunkMetaDataBuilder, RowGroupMetaDataBuilder, FileMetaDataBuilder need to be exposed to Python? I'd be happy to take any pointers on what is needed for resolving ARROW-1983.
xhochy commentedon Apr 18, 2019
@pearu Yes. In the end to create the
_metadatawe would need to collect theRowGroupMetaDatainstances from all files, pickle them, send them to a single worker and then create out of all of them a singleFileMetaDatathat is stored as part of an empty Parquet file named_metadata.martindurant commentedon Apr 30, 2019
This issue is still relevant, but partly covered by the conversation in https://issues.apache.org/jira/browse/ARROW-1983
Consider, though, that it may well still be useful to have an option not to make column statistics, partly to speed up writing and partly to decrease the metadata size. Fastparquet has this option in dask/fastparquet#259 (which is py3 only, and so not merged), but it is not surfaced.
wesm commentedon May 1, 2019
@jorisvandenbossche @nealrichardson to make you aware of this issue
jcrist commentedon May 13, 2022
With #8901, we no longer write _metadata files by default, which should remove this problem. There may be some upstream fixes in pyarrow that could improve the scalability limit of producing the _metadata file, but at some point the full dataset metadata will always become too large for a single worker to process. Other tools like spark have come to the same conclusion and made the same change. Closing.