Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polars parquet writer much slower than pyarrow parquet writer #15455

Open
2 tasks done
ion-elgreco opened this issue Apr 3, 2024 · 2 comments
Open
2 tasks done

Polars parquet writer much slower than pyarrow parquet writer #15455

ion-elgreco opened this issue Apr 3, 2024 · 2 comments
Labels
A-io Area: reading and writing data A-io-parquet Area: reading/writing Parquet files bug Something isn't working P-low Priority: low python Related to Python Polars

Comments

@ion-elgreco
Copy link
Contributor

Checks

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of Polars.

Reproducible example

import numpy as np
import polars as pl

df = pl.DataFrame({
    "foo":np.random.randn(1, 100000000).reshape((100000000,)),
    "foo1":np.random.randn(1, 100000000).reshape((100000000,)),
    "foo2":np.random.randn(1, 100000000).reshape((100000000,)),
    "foo3":np.random.randn(1, 100000000).reshape((100000000,))
})
df = df.with_columns(pl.col('foo').cast(pl.Utf8).alias('foo_str'), pl.col('foo').cast(pl.Utf8).alias('foo_str2'))

df.write_parquet("test.parquet", compression='snappy') takes 92 seconds

df.write_parquet("test2.parquet", compression='snappy', use_pyarrow=True) takes 55 seconds.

Log output

No response

Issue description

At work we saw one of our pipelines taking around 50 minutes to write a parquet file. The difference was huge compared to pyarrow which took only one minute, see the logs below:

With polars (50minutes):
image

With pyarrow (1.5 minute):
image

Expected behavior

Write fast, like pyarrow does.

Installed versions

0.20.10
@ion-elgreco ion-elgreco added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels Apr 3, 2024
@deanm0000
Copy link
Collaborator

I tried to reproduce with the 100m but after 2 min of generating df, I tapped out and did it again with just 10m. With just 10m rows, I got 2.9s to save with polars and 3.0s with pyarrow.

@Chuck321123
Copy link

Chuck321123 commented Apr 4, 2024

By using "zstd" as compression method i got this (with 10m rows)
4.85 s ± 303 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
8.6 s ± 1.41 s per loop (mean ± std. dev. of 7 runs, 1 loop each)
Where i set use_pyarrow=True for the first part

@deanm0000 deanm0000 added P-low Priority: low A-io Area: reading and writing data A-io-parquet Area: reading/writing Parquet files and removed needs triage Awaiting prioritization by a maintainer labels Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-io Area: reading and writing data A-io-parquet Area: reading/writing Parquet files bug Something isn't working P-low Priority: low python Related to Python Polars
Projects
Status: Ready
Development

No branches or pull requests

3 participants