damccorm opened a new pull request, #41160:
URL: https://github.com/apache/beam/pull/41160

   ### Description
   
   Optimizes `PerWindowInvoker` window argument caching and placeholder binding 
in `sdks/python/apache_beam/runners/common.py`:
   
   1. **Cache `args_for_process` / `kwargs_for_process` when side inputs are 
globally windowed:**
      - Sets `self.recalculate_window_args` based on `not 
all(si.is_globally_windowed() for si in side_inputs)` rather than 
`self.has_windowed_inputs`, and hoists `window` extraction outside the 
`self.has_cached_window_args` / `self.has_cached_window_batch_args` branch so 
`DoFn`s that take `DoFn.WindowParam` (without windowed side inputs) reuse 
`args_for_process` across windows instead of calling 
`util.insert_values_in_args` on every window.
   2. **Short-circuit `_DoFnParam` placeholder checks with identity (`p is 
...`) before equality (`==`).**
   
   ### Benchmarks & Performance Impact
   
   - **Microbenchmark:** [`bench_09_per_window_invoker_window_args` 
(`c2feb961eef`)](https://github.com/damccorm/beam/blob/c2feb961eef2e7d2410825aab9537c62a95e6790/sdks/python/apache_beam/testing/benchmarks/python_sdk_perf/microbenchmarks.py#L193-L195)
 (on branch 
[`perf/py-benchmarks-suite`](https://github.com/damccorm/beam/tree/perf/py-benchmarks-suite))
 — Part of the `PerWindowInvoker` optimization suite that improved 200,000 
windowed `DoFn` invocations (`DoFn.WindowParam`) by **2.68x (`0.218s` -> 
`0.081s`)** (~**1.22x** isolated).
   - **End-to-End Cloud Dataflow Benchmark (`core_window_row_combine`):** 
Included in [`run_core_window_row_combine_pipeline` 
(`c2feb961eef`)](https://github.com/damccorm/beam/blob/c2feb961eef2e7d2410825aab9537c62a95e6790/sdks/python/apache_beam/testing/benchmarks/python_sdk_perf/dataflow_e2e_benchmarks.py#L274-L302)
 (3,000,000 generated events -> 9,000,000 sliding-windowed elements on a single 
`n2-standard-4` worker), which improved end-to-end worker stage execution time 
by **1.80x (`-44.5%`, `599.6s` -> `332.9s`)** and reduced total billable 
Dataflow vCPU/Memory/PD usage by **`-26.1%` (`1,134` -> `838` vCPU-s)**.
   
   ### Testing
   - Verified with `pytest sdks/python/apache_beam/runners/common_test.py`.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to