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

perf: If there are many small chunks in write_parquet(), convert to a single chunk (#14484) #14487

Merged

Conversation

itamarst
Copy link
Contributor

@itamarst itamarst commented Feb 14, 2024

Fixes #14484

Before:

COLLECT+WRITE 0.9387576580047607
STREAMING COLLECT+WRITE 5.633932828903198

After:

COLLECT+WRITE 0.9567661285400391
STREAMING COLLECT+WRITE 0.9884464740753174
COLLECT+WRITE 0.9158937931060791
STREAMING COLLECT+WRITE 1.0007367134094238

@github-actions github-actions bot added performance Performance issues or improvements python Related to Python Polars rust Related to Rust Polars labels Feb 14, 2024
@itamarst itamarst changed the title perf: If there are many small chunks, convert to a single chunk (#14484) perf: If there are many small chunks in write_parquet(), convert to a single chunk (#14484) Feb 14, 2024
@itamarst itamarst marked this pull request as draft February 14, 2024 17:19
@itamarst itamarst marked this pull request as ready for review February 14, 2024 17:28
Copy link

codecov bot commented Feb 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ No coverage uploaded for pull request base (main@d80cebf). Click here to learn what that means.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #14487   +/-   ##
=======================================
  Coverage        ?   80.35%           
=======================================
  Files           ?     1352           
  Lines           ?   174669           
  Branches        ?     2436           
=======================================
  Hits            ?   140353           
  Misses          ?    33844           
  Partials        ?      472           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -133,7 +133,11 @@ pub fn split_series(s: &Series, n: usize) -> PolarsResult<Vec<Series>> {
split_array!(s, n, i64)
}

pub fn split_df_as_ref(df: &DataFrame, n: usize) -> PolarsResult<Vec<DataFrame>> {
pub fn split_df_as_ref(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is technically a public API, though nothing uses it at least in Polars, just split_df(), so if backwards compat is an issue then this could be a new function and split_df_as_ref could be a wrapper. (Shame Rust has no default keyword args, makes this sort of change easier to be backwards compat.)

Copy link
Member

@ritchie46 ritchie46 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @itamarst. Looks good to me. 👍

@ritchie46 ritchie46 merged commit 3b065f3 into pola-rs:main Feb 22, 2024
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Performance issues or improvements python Related to Python Polars rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

collect(streaming=True).write_parquet() is slow when there are many small chunks
3 participants