Hash scan tasks without re-hashing the base scan's payload #25498
<!-- coderabbit-ai-generated:v1 -->
<!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- review_stack_entry_start -->
<a href="https://app.coderabbit.ai/change-stack/NVIDIA/cudf/pull/25498?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg" alt="Explain Change →" height="32"></picture></a>
<!-- review_stack_entry_end -->
<!-- recent_review_status_start -->
No actionable comments were generated in the recent review.
<!-- recent_review_status_end -->
<!-- walkthrough_start -->
<details>
<summary><strong>Summary</strong></summary>
<dl>
<dd>
<br>
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
Summary by CodeRabbit
Refactor
Updated how scan operations are distinguished, while preserving their existing path, split, schema, and Parquet details. This is an internal change and does not alter user-facing functionality or interfaces.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->ScanTask.get_hashable and ParquetScanTask.get_hashable now include the base_scan object directly in their tuples. The existing path, split, schema, and Parquet-specific values remain included.
Changes: Scan task hashing
|Layer / File(s)|Summary|
|:---|:---|
|Update scan task hashable tuples <br> python/cudf_polars/cudf_polars/streaming/io.py|Both get_hashable methods now include self.base_scan directly instead of self.base_scan.get_hashable(). Other tuple values remain unchanged.|
<!-- change_assessment_start -->
Estimated code review effort: 2 (Simple) | ~10 minutes
<!-- change_assessment_commit:"8d2c8df77af8aee04f616a689fd427d47250b27f" -->
<!-- change_assessment_priority:{"version":1,"urgency":"p2","manual":false} -->
Change: Refactor
<!-- change_assessment_end -->
Suggested labels: Python, Performance
Suggested reviewers: rjzamora, matt711
</dd>
</dl>
</details>
<!-- walkthrough_end -->
<details>
<summary><strong>Merge Risk:</strong> <strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/risk-unassessed-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minimal</strong> · up to <code>8d2c8</code></summary>
<dl>
<dd>
<br>
<!-- final_review_risk_start -->
<!-- final_review_risk_label
Merge Risk: ⚪ Minimal · up to 8d2c8
-->
<!-- final_review_risk_coverage:{"sourceCommitId":"8d2c8df77af8aee04f616a689fd427d47250b27f","coveredCommitId":"8d2c8df77af8aee04f616a689fd427d47250b27f","kind":"reviewed"} -->
This change reduces repeated hashing of the base scan's full path list when scan tasks are lowered. No concrete defect was found, and it looks safe to merge.
<!-- final_review_risk_end -->
</dd>
</dl>
</details>
<details>
<summary><strong>Security architecture risk:</strong> <strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/risk-unassessed-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minimal</strong> · up to <code>8d2c8</code></summary>
<dl>
<dd>
<br>
<!-- architecture_review_start -->
<!-- architecture_review_label
Security Architecture Review
Security architecture risk: ⚪ Minimal · up to 8d2c8
-->
Equivalent queries can receive different diagnostic identifiers before and after this update. The change does not alter which files a query reads or what permissions it uses.
Retained concerns
No architecture-level concerns identified.
<details>
<summary><strong>Security review details</strong></summary>
<dl>
<dd>
<br>
Trust Boundaries and Controls
</dd>
</dl>
</details>
<!-- architecture_review_end -->
</dd>
</dl>
</details>
<!-- pre_merge_checks_walkthrough_start -->
<details>
<summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4</strong></summary>
<dl>
<dd>
<br>
| Check name | Status | Explanation |
| :------------------------ | :--------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Title check | !Passed | The title states the main change: scan task hashes no longer re-hash the base scan's full payload. The raw summary and objectives confirm that ScanTask and ParquetScanTask now embed the base scan node… |
| Description check | !Passed | The description explains the problem (the base scan's full hashable payload, including every query path, is hashed once per scan task, which is quadratic in file count). It also describes the fix (emb… |
| Linked Issues check | !Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | !Passed | Check skipped because no linked issues were found for this pull request. |
<details>
<summary><strong>Full details: Title check</strong></summary>
<dl>
<dd>
<br>
Explanation
The title states the main change: scan task hashes no longer re-hash the base scan's full payload. The raw summary and objectives confirm that ScanTask and ParquetScanTask now embed the base scan node rather than its full hashable representation. The title is specific and matches the changeset.
</dd>
</dl>
</details>
<details>
<summary><strong>Full details: Description check</strong></summary>
<dl>
<dd>
<br>
Explanation
The description explains the problem (the base scan's full hashable payload, including every query path, is hashed once per scan task, which is quadratic in file count). It also describes the fix (embedding the base scan Node so its cached digest is used) and gives performance measurements. This matches the changes in the raw summary.
</dd>
</dl>
</details>
</dd>
</dl>
</details>
<!-- pre_merge_checks_walkthrough_end -->
<!-- finishing_touch_checkbox_start -->
<details>
<summary><strong>Finishing Touches</strong></summary>
<dl>
<dd>
<br>
<details open>
<summary><strong>Generate unit tests (beta)</strong></summary>
<dl>
<dd>
<br>
</dd>
</dl>
</details>
</dd>
</dl>
</details>
<!-- finishing_touch_checkbox_end -->
<!-- autopilot:start -->
<!-- autopilot:end -->
<!-- recent_review_start -->
<h6>
<details>
<summary><strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="12" height="12" align="absmiddle" alt=""></picture> Recent review info</strong></summary>
<dl>
<dd>
<br>
<!-- review_info_content -->
<details>
<summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</strong></summary>
<dl>
<dd>
<br>
2dd73eea-6e23-4e8e-bb5f-0fda8dbde2c8</dd>
</dl>
</details>
<details>
<summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</strong></summary>
<dl>
<dd>
<br>
Reviewing files that changed from the base of the PR and between cd9b31cc1746ab8bca9fc697c934292b92351fd1 and 8d2c8df77af8aee04f616a689fd427d47250b27f.
</dd>
</dl>
</details>
<details>
<summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 1</strong></summary>
<dl>
<dd>
<br>
python/cudf_polars/cudf_polars/streaming/io.py</dd>
</dl>
</details>
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.
</dd>
</dl>
</details>
</h6>
<!-- recent_review_end -->
I agree with the spirit of this change, but not the implementation, I think... I need to remind myself how this fits together
wence-
pentschev
ScanTask.get_hashable()andParquetScanTask.get_hashable()embedself.base_scan.get_hashable(), i.e. the base scan's full hashable payload, which contains every path of the query.StreamingScan.get_hashable()hashes all of its tasks, so when lowering computes stable ids (lower_ir_graph_with_node_map->Node.get_stable_id->_update_stable_hasher), the full path list is fed to MD5 once per scan task. The cost is quadratic in the number of input files (tasks x paths).The proposed change puts the base scan node into the task's hashable instead.
_update_stable_hasheruses a Node's cached digest, so the base scan is hashed once. Hashing and equality still cover the base scan, only the stable id values change (identically on all ranks).With about 70k S3 parquet files on 32 ranks (two scans of the same files, about 4,300 tasks per rank), every rank spent ~150 s in
_update_stable_hasherbefore starting any work. With this change that phase disappears in a large query on 4x8 B200 and the end-to-end time drops from 491 s to ~285 s (identical, verified results). For a smaller range (~23k files) the idle phase was ~20 s, consistent with the quadratic growth.