Repository navigation
[Data] Skip filtered-out WebDataset tar member payloads - #68403
owenowenisme merged 4 commits into
Conversation
Signed-off-by: Yin-1022 <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request optimizes the WebDataset datasource by delaying the extraction of file payloads until after the filename suffix is checked, preventing unnecessary reads. A corresponding unit test was also added to verify this behavior. Feedback on the changes points out a redundant duplicate check of _check_suffix that was left in the code after moving the extraction logic, which should be removed.
| if not _check_suffix(fname, fileselect): | ||
| continue | ||
|
|
||
| data = stream.extractfile(tarinfo).read() |
There was a problem hiding this comment.
There was a problem hiding this comment.
Thanks for catching. Removed the redundant fileselect check and kept the filtering logic before payload extraction.
Signed-off-by: Yin-1022 <[email protected]>
71b44f8 to
ea90750
Compare
Efutrrionpy
left a comment
There was a problem hiding this comment.
LGTM. Could we say “Only materializes selected payloads” in the table? In streaming mode, tarfile still reads through the skipped members.
Thanks for the clarification! I've updated the comparison table to say "Only materializes selected payloads" to distinguish memory allocation from the underlying streaming reads. |
fellowship: 提名 Yin-1022 (ray, 2026-11) 建議等級:2 萬 - [x] 關係人宣告:提名人與被提名者無親屬、僱傭、財務、業務合作或其他可能影響公正判斷之利害關係 - 在兩個月內自己找到 8 個 Ray Data Issue 並開了 PR,其中 6 個 PR 被 Merged ([Merged PRs](https://github.com/ray-project/ray/pulls?q=is%3Apr+author%3AYin-1022+is%3Amerged+merged%3A%3C%3D2026-11-24)) - 兩個月內共 review 28 個 PR,其中 10 個提出的問題有被作者採納修正([#68402](https://github.com/ray-project/ray/pull/68402)、[#68290](https://github.com/ray-project/ray/pull/68290)、[#67524](https://github.com/ray-project/ray/pull/67524)) - 大部分 PR 都有清楚列出 Before/After 的差距,performance 相關的會附上數據 ([#67935](ray-project/ray#67935), [#68403](ray-project/ray#68403)) - 對於 Maintainer 的 Review 會清楚了解之後回覆 ([#67935 comment](ray-project/ray#67935 (comment)), [#66878 comment](ray-project/ray#66878 (comment)), [#67505 comment](ray-project/ray#67505 (comment)))
Signed-off-by: Yin-1022 <[email protected]>
Head branch was pushed to by a user without write access
Signed-off-by: Yin-1022 <[email protected]>
|
I resolved the merge conflict by adapting the fix to the shared WebDataset utilities introduced by the DataSource V2 migration. The original filtering behavior is preserved, and the fix now applies to both V1 and V2. Revalidated on Linux:
No additional behavioral changes were introduced. |
Description
This PR addresses unnecessary memory allocations in Ray Data's WebDataset TAR reader, where
_tar_file_iterator()reads the full payload of each regular TAR member before applyingfileselect, including members that are ultimately excluded.The change moves filename filtering ahead of payload extraction, avoiding materialization of filtered-out data while preserving existing behavior.
Changes
extractfile().read()afterfilerenameandfileselectchecks in_tar_file_iterator().filerenameis applied beforefileselect.Before / After Comparison
Behavior:
fileselectoutputfilerenamesemanticsMemory benchmark:
Using a TAR archive containing a 64 MiB excluded member and a small selected
.txtmember, a standalone benchmark compared the original reader against an early-filtering implementation.Measurements represent peak Python-tracked memory allocations collected with
tracemalloc, not process RSS. No consistent execution-time improvement is claimed.Related issues
Closes #68352
Additional information
Test results
Ran the full
test_webdataset.pytest suite on both the modified branch and the unmodifiedmaster(Windows environment).The modified branch introduced one additional passing regression test, with no new test failures compared to
master.The same 13 tests failed on both branches:
torchdependency.ValueErrorinvolving Windows temporary paths.The new
test_webdataset_fileselect_skips_unselected_payloadsregression test passed on the modified branch and failed before the fix, confirming that excluded TAR members are no longer unnecessarily extracted while preservingfilerenameandfileselectbehavior.Environment: Windows, Ray master commit
8b69afe261.