damccorm opened a new pull request, #41278: URL: https://github.com/apache/beam/pull/41278
Note: this PR was auto-generated by tooling. Before moving it out of draft, the author has done a full review of the PR, specifically evaluating it on the following criteria: - The PR is an appropriate fix for the issue (e.g. we're not changing a test to avoid a bug) - The PR is a simple fix to the issue (e.g. we're not adding infra when we could just modify a test) - The PR is not covering for other problems (e.g. if we're bumping timeouts, it is not because we're covering for a performance problem) Full details of the methodology of generation and review can be found here - [Apache Beam Python SDK Performance PRs Methodology & Branches Impact Ranking](https://docs.google.com/document/d/1Edrmzp-qFHYs2j7dg9uFyV_jEMgq4QKt_JQDuuk-lmI/edit?usp=drivesdk) If you have concerns with the PR or with the underlying methodology used to generate this, please comment below - they will be addressed by the author not the tooling :) **Summary of changes:** Optimizes `_ParquetUtils.find_first_row_group_index` in `sdks/python/apache_beam/io/parquetio.py`: 1. **Replace $O(G)$ linear scan of Parquet row groups in `find_first_row_group_index` with $O(\log G)$ binary search:** - Row group start offsets (`_ParquetUtils.get_offset(pf, i)`) are monotonically increasing across row groups `0..G-1`. - Fast-paths `start_offset <= 0` (`O(1)`) and uses binary search (`O(log G)`) instead of calling `_ParquetUtils.get_offset(pf, i)` (which accesses PyArrow C++ row group metadata) linearly from index `0` on every split/read. **Dataflow benchmarks showing improvement:** - Before the change: [`2026-11-12_12_18_08-4507085723717661341`](https://console.cloud.google.com/dataflow/jobs/us-central1/2026-11-12_12_18_08-4507085723717661341?project=apache-beam-testing) - After the change: [`2026-11-12_12_18_08-760809507228610349`](https://console.cloud.google.com/dataflow/jobs/us-central1/2026-11-12_12_18_08-760809507228610349?project=apache-beam-testing) - Summary of perf improvement: In a single-worker (`n1-standard-8`, `--autoscaling_algorithm=NONE --num_workers=1 --max_num_workers=1`) Cloud Dataflow pipeline running `15,000,000` dict rows (`300` row groups) · `WriteToParquet` → `ReadAllFromParquet(desired_bundle_size=1024)`, built-in transform stage execution time improved from **`512,632 ms` -> `507,407 ms` (`1.01x` faster, `-1.0%`)** (total single-worker job vCPU time: `1627s` -> `1536s`). **Additional benchmarks** - **Strict Single-PR Isolated Microbenchmark (`upstream/master` vs `upstream/master` + this PR alone):** [`bench_48_parquet_and_textio_fastpath` (`c2feb961eef`)](https://github.com/damccorm/beam/blob/c2feb961eef2e7d2410825aab9537c62a95e6790/sdks/python/apache_beam/testing/benchmarks/python_sdk_perf/microbenchmarks.py#L662-L669) (on branch [`perf/py-benchmarks-suite`](https://github.com/damccorm/beam/tree/perf/py-benchmarks-suite)) — 50,000 `_ParquetUtils.find_first_row_group_index` lookups across a 64-row-group Parquet file improved from **`355.91 ms` -> `61.49 ms` (`5.79x` faster, `-82.7%`, `-294.42 ms`)**. - **End-to-End Cloud Dataflow Benchmark (`suite3_parquet_dataframe`):** Included in the Parquet & DataFrame lakehouse benchmark (`1,000,000` Parquet rows across `500` row groups on `n2-standard-4`), where worker stage execution time improved by **1.23x (`-18.7%`, `17.9s` -> `14.6s`)**. ### Testing - Verified with `pytest sdks/python/apache_beam/io/parquetio_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]
