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

refactor: Traced await #21638

Closed
wants to merge 4 commits into from
Closed

Conversation

nameexhaustion
Copy link
Collaborator

@nameexhaustion nameexhaustion commented Mar 7, 2025

This is a branch with added tracing to await points in the new-streaming compute nodes, intended for finding which await points are blocking execution in the event of a deadlock.

Compile and run with POLARS_TRACED_AWAIT=1 set in the environment, which should print lines to stderr similar to the following:

image

The output should be saved to a file, the following script can then be used to extract the locations at which async tasks are currently blocked:

import polars as pl
from pathlib import Path

trace_file = ".env/trace"

df = (
    pl.Series("raw", [Path(trace_file).read_text()])
    .str.strip_chars_end("\n")
    .str.split("\n")
    .list.explode()
    .to_frame()
    .filter(
        pl.first().str.starts_with("begin_await")
        | pl.first().str.starts_with("finish_await")
    )
)

v = (
    df.with_columns(
        pl.col("raw")
        .str.splitn(" ", 3)
        .struct.rename_fields(["event", "id", "location"])
        .struct.unnest()
    )
    .filter(pl.len().over("id") < 2)
    .unique("location")
    .sort("location")
)


with pl.Config(
    tbl_formatting="ASCII_MARKDOWN",
    fmt_str_lengths=999,
    tbl_width_chars=999,
    tbl_hide_column_data_types=True,
    tbl_rows=999,
):
    print(v.select("location"))

@nameexhaustion nameexhaustion added the do not merge This pull requests should not be merged right now label Mar 7, 2025
@github-actions github-actions bot added internal An internal refactor or improvement python Related to Python Polars rust Related to Rust Polars labels Mar 7, 2025
Copy link

codecov bot commented Mar 7, 2025

Codecov Report

Attention: Patch coverage is 75.72115% with 101 lines in your changes missing coverage. Please review.

Project coverage is 80.59%. Comparing base (33ed4b7) to head (b53ca05).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
crates/polars-stream/src/nodes/merge_sorted.rs 41.17% 20 Missing ⚠️
...src/nodes/io_sources/ndjson/negative_slice_pass.rs 0.00% 13 Missing ⚠️
crates/polars-stream/src/prelude.rs 53.57% 13 Missing ⚠️
crates/polars-stream/src/nodes/with_row_index.rs 0.00% 9 Missing ⚠️
crates/polars-stream/src/nodes/joins/equi_join.rs 71.42% 6 Missing ⚠️
crates/polars-stream/src/nodes/zip.rs 0.00% 6 Missing ⚠️
crates/polars-stream/src/nodes/reduce.rs 0.00% 5 Missing ⚠️
...eam/src/nodes/io_sources/parquet/metadata_utils.rs 33.33% 4 Missing ⚠️
...c/nodes/io_sources/parquet/row_group_data_fetch.rs 50.00% 4 Missing ⚠️
crates/polars-stream/src/nodes/multiplexer.rs 0.00% 4 Missing ⚠️
... and 10 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #21638      +/-   ##
==========================================
- Coverage   80.59%   80.59%   -0.01%     
==========================================
  Files        1604     1605       +1     
  Lines      231526   231694     +168     
  Branches     2650     2650              
==========================================
+ Hits       186593   186726     +133     
- Misses      44316    44351      +35     
  Partials      617      617              

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

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nameexhaustion nameexhaustion changed the title refactor: Debug await refactor: Traced await Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do not merge This pull requests should not be merged right now internal An internal refactor or improvement python Related to Python Polars rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant