Skip to content

Large parquet metadata swamps small workers #4410

Closed

Description

@mrocklin

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

cc @wesm @xhochy

Activity

  1. birdsarah commented on Jan 23, 2019

    @birdsarah
    Contributor

    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.

  2. martindurant commented on Jan 23, 2019

    @martindurant
    Member

    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.

  3. wesm commented on Jan 24, 2019

    @wesm
    Contributor

    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

  4. mrocklin commented on Jan 24, 2019

    @mrocklin
    MemberAuthor

    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 .metadata file 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.

  5. xhochy commented on Jan 25, 2019

    @xhochy
    Contributor

    @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-cpp but it will require some pointers.

  6. pearu commented on Apr 11, 2019

    @pearu

    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.

    @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.

  7. xhochy commented on Apr 18, 2019

    @xhochy
    Contributor

    @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.

  8. martindurant commented on Apr 30, 2019

    @martindurant
    Member

    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.

  9. wesm commented on May 1, 2019

    @wesm
    Contributor

    @jorisvandenbossche @nealrichardson to make you aware of this issue

  10. jcrist commented on May 13, 2022

    @jcrist
    Member

    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.

  11. self-assigned this
    on May 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions