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

   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 - 
https://docs.google.com/document/d/14lj7ECVov4T4EdwmIzNlWrRGE3lLDMOwX5xUMGzaLoc/edit?usp=sharing
   
   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
   
   Increases the per-element timeout budget and corresponding GC grace-period 
workload in 
`RunInferenceBaseTest.test_run_inference_timeout_does_garbage_collection` 
(`sdks/python/apache_beam/ml/inference/base_test.py`) so reloading the spawned 
`MultiProcessShared` model process does not time out on loaded ML CI runners.
   
   ### Root Cause
   
   Observed 4 times on `master` across Python 3.11 and 3.12 since PR #40816 
(`027f6191a92`):
   - [PreCommit Python ML run 
45684130635](https://github.com/apache/beam/actions/runs/45684130635) (py312)
   - [PreCommit Python ML run 
45683119862](https://github.com/apache/beam/actions/runs/45683119862) (py311)
   - [PreCommit Python ML run 
45622781598](https://github.com/apache/beam/actions/runs/45622781598) (py312)
   - [PreCommit Python ML run 
45467962605](https://github.com/apache/beam/actions/runs/45467962605) (py311)
   
   Commit `027f6191a92` switched `MultiProcessShared` `RunInference` models to 
`spawn_process=True` and bumped 
`test_run_inference_timeout_does_garbage_collection`'s timeout from `5s` to 
`9s`. After the first element (`[20]`) times out and marks the initial model 
tag invalid, the next element (`[1]`) triggers `self.update_model()` **inside** 
`_TimeoutDoFn.process(timeout=9)`, which spawns a fresh Python process in the 
ML tox environment (importing ML dependencies) plus `time.sleep(1)`. On loaded 
CI runners, spawning the child process + 1s inference regularly exceeds 9s, 
timing out `[1]` and causing a reload cascade (`_reload_1`..`_reload_N`) that 
fails the `assert_that` checks.
   
   ### Fix
   
   - In `sdks/python/apache_beam/ml/inference/base_test.py` 
(`test_run_inference_timeout_does_garbage_collection`):
     - Bump `timeout` from `9` to `20` (giving ~19s of headroom for spawning 
the reloaded `MultiProcessShared` child process).
     - Update `examples` from `[20] + [1] * 20` to `[35] + [1] * 45` 
(`expected_bad = [35]`, `expected_good = [1] * 45`) so:
       - The bad element (`35s`) reliably exceeds `timeout=20` and still 
finishes well before `2 * timeout` (`40s`) GC deletion (`35 < 20 + 40`).
       - The 45 good 1s elements exceed the `2 * timeout = 40s` GC grace period 
before `finish_bundle()` runs `get_tags_for_garbage_collection()`.
   
   ### Verification
   
   - Local:
     - `pytest -v -k test_run_inference_timeout_does_garbage_collection 
apache_beam/ml/inference/base_test.py` passed.
     - `yapf==0.43.0 --style setup.cfg --diff` clean on modified lines.
   - CI: triggering `.github/workflows/beam_PreCommit_Python_ML.yml` on this PR 
branch.
   
   ### Verification
   - Triggered `.github/workflows/beam_PreCommit_Python_ML.yml` workflow run on 
branch: [`45702305888`](https://github.com/apache/beam/actions/runs/45702305888)
   


-- 
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