Abacn opened a new pull request, #40915:
URL: https://github.com/apache/beam/pull/40915
- Inline `_next_uint()` in Cython `LCGenerator` (`fast_test_utils.pyx`) to
eliminate two `cpdef` calls (`next_uint` -> `seed`) per 4-byte chunk in
`randbytes`.
- Generate key and value bytes separately in `SyntheticSource._gen_kv_pair`
when `gen_algo == 'lcg'` and `key_size % 4 == 0` to avoid allocating and
slicing an intermediate combined `bytes` object while preserving identical
output for any seed.
Benchmark results:
| Benchmark (`1,000,000` elements / run) | Baseline Median (per element) |
Optimized Median (per element) | Time Saved | Speedup |
| :--- | :---: | :---: | :---: | :---: |
| **`LCGenerator_Key24_Val1000`** (`seed` + `random_sample` +
`randbytes(1024)`) | `1.640e-06 sec` (2.23% std) | **`3.653e-07 sec`** (3.18%
std) | **-77.7%** (`-1,275 ns`) | **4.49x** |
| **`SyntheticSourceGenKv_Key24_Val1000`** (`_gen_kv_pair`) | `1.815e-06
sec` (5.45% std) | **`4.266e-07 sec`** (4.40% std) | **-76.5%** (`-1,389 ns`) |
**4.25x** |
| **`SyntheticSourceRead_Key24_Val1000`** (`source.read`) | `1.828e-06 sec`
(0.47% std) | **`7.581e-07 sec`** (5.03% std) | **-58.5%** (`-1,069 ns`) |
**2.41x** |
<!--
Thank you for your contribution! Follow this checklist to help us
incorporate your contribution quickly and easily:
- [ ] If this contribution is large, please file an Apache [Individual
Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
- [ ] Replace these instructions with a description of your change and why
you have made it.
- [ ] Mention the appropriate issue in your description (for example:
`addresses #123` or `fixes #456`).
- [ ] Update `CHANGES.md` with noteworthy changes.
See [CONTRIBUTING.md]() for more details.
-->
--
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]