Skip to content

Skip WindowInto(GlobalWIndows()) elementwise if upstream pcoll is already global window in Write transform - #40911

Open
Abacn wants to merge 2 commits into
apache:masterfrom
Abacn:skip-windowinto
Open

Abacn wants to merge 2 commits into
apache:masterfrom
Abacn:skip-windowinto

Conversation

@Abacn

@Abacn Abacn commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

WriteImpl._expand_bounded previously applied WindowInto(GlobalWindows()) unconditionally to all input records before writing bundles, even when the input PCollection was already using the default global windowing strategy. In typical batch pipelines, this added an unnecessary per-element WindowInto pass across the entire dataset (~22% overhead in bounded write benchmarks).

Check windowing.is_default() at pipeline expansion time and only apply WindowInto(GlobalWindows()) when the input PCollection is not already in the default global window.

========

Benchmark Results (source: https://gist.github.com/Abacn/93fa3168450bf36838e70d853a77d2e3)

Benchmark Baseline Median (sec / elem) This change (sec / elem) Speedup Time Reduction
WriteImplBoundedPipeline 1.643e-05 1.281e-05 1.28x -22.0%

is already global window in Write transform

`WriteImpl._expand_bounded` previously applied `WindowInto(GlobalWindows())`
unconditionally to all input records before writing bundles, even when the
input `PCollection` was already using the default global windowing strategy. In
typical batch pipelines, this added an unnecessary per-element `WindowInto`
pass across the entire dataset (~22% overhead in bounded write benchmarks).

Check `windowing.is_default()` at pipeline expansion time and only apply
`WindowInto(GlobalWindows())` when the input `PCollection` is not already in the
default global window.
@github-actions github-actions Bot added python io size/xs XS: <10 lines changed labels Oct 30, 2026
@Abacn

Abacn commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

context: when benchmarking a batch FileIO write pipeline (https://github.com/Abacn/apache-beam-sstable), this path alone is found to cost 10% of total CPU time

image

While #40910 is a more generic fix for global window instantiate, for FileIO write batch, we can skip this overhead altogether and save 10% CPU time

@codecov

codecov Bot commented Oct 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 80.08%. Comparing base (12bbb17) to head (6d26e8c).
⚠️ Report is 12 commits behind head on master.

Files with missing lines Patch % Lines
sdks/python/apache_beam/io/iobase.py 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #40911      +/-   ##
==========================================
+ Coverage   79.83%   80.08%   +0.25%     
==========================================
  Files         494      494              
  Lines       83575    83586      +11     
==========================================
+ Hits        66722    66944     +222     
+ Misses      16853    16642     -211     
Flag Coverage Δ
python 80.08% <75.00%> (+0.25%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @tvalentyn for label python.
Backup reviewer: claudevdm (if the main reviewer is unresponsive, you can escalate to them by tagging their username)

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants