Repository navigation
perf(amber): replace Thread.sleep with event-driven waits in e2e specs - #4518
Merged
Merged
Conversation
PauseSpec.shouldPause used three Thread.sleep calls (4000+400+4000 ms) to wait for the engine to settle into PAUSED before each next action; ReconfigurationSpec.shouldReconfigure had one Thread.sleep(4000) after pauseWorkflow. AmberClient already exposes registerCallback for ExecutionStateUpdate, so a Promise that resolves on the target state is a drop-in replacement and exits as soon as the engine transitions. Add a stateReached helper to TestUtils and use it in both specs to wait for PAUSED. Local measurement: PauseSpec 41.87s -> 28.79s (~13s saved); ReconfigurationSpec change measured via CI since the spec's Python UDF path requires JDK 11. The 400ms sleep after resumeWorkflow stays for now: ResumeHandler does not emit an ExecutionStateUpdate (apache#4514). Once that fix lands, the 400ms sleep can be removed in a follow-up. The 1000ms sleep inside ReconfigurationSpec's COMPLETED callback is also left alone -- its TODO marks it as a workaround for a separate completion-reporting bug. Closes apache#4517
Once apache#4515 (ResumeHandler emits ExecutionStateUpdate) lands, the post-resume Thread.sleep(400) in PauseSpec.shouldPause can be replaced with stateReached(client, RUNNING). The test verifies pause/resume mechanics; it does not need to ensure tuple-level progress between the two pause-resume cycles, so a state-based wait is sufficient. Marks this PR as dependent on apache#4515.
Yicong-Huang
marked this pull request as draft
April 26, 2026 02:16
Await.result(resumeWorkflow) already blocks until ResumeHandler's .map block has run, by which point all workers have transitioned to RUNNING. The extra stateReached(RUNNING) wait was redundant and would have required ResumeHandler to broadcast a new ExecutionStateUpdate event, which is not warranted just for this test.
Yicong-Huang
marked this pull request as ready for review
April 26, 2026 02:24
Original code used Thread.sleep(4000) (4s); using a 30s ceiling for the event-driven replacement is way more than needed and would make genuine hangs slow to surface. 10s gives ample headroom over the typical sub-second transition while keeping failure feedback quick.
yangzhang75
pushed a commit
to yangzhang75/texera
that referenced
this pull request
Jun 22, 2026
apache#4518) ### What changes were proposed in this PR? `PauseSpec.shouldPause` and `ReconfigurationSpec.shouldReconfigure` used hardcoded `Thread.sleep` to wait for the engine to reach `PAUSED` (4s + 0.4s + 4s in `PauseSpec`, 4s in `ReconfigurationSpec`). Replaced with a `stateReached(client, target)` helper that resolves a `Promise` on the next matching `ExecutionStateUpdate`. The post-resume sleep is dropped entirely — `Await.result(resumeWorkflow)` already blocks until `ResumeHandler` finishes, by which point all workers are in `RUNNING`. Wait timeout: 10s (~2.5× the original sleep, leaves CI headroom while keeping hang feedback fast). ### Any related issues, documentation, discussions? Closes apache#4517. ### How was this PR tested? Local timing (warm sbt + DB): | | `Run completed in` | |---|---| | before | 41s 869ms | | after | 31s 355ms | `ReconfigurationSpec` can't be measured locally on JDK 17 (Arrow `MemoryUtil` reflection); CI on JDK 11 will exercise it. ### Was this PR authored or co-authored using generative AI tooling? Generated-by: Claude Code (Opus 4.7)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this PR?
PauseSpec.shouldPauseandReconfigurationSpec.shouldReconfigureused hardcodedThread.sleepto wait for the engine to reachPAUSED(4s + 0.4s + 4s inPauseSpec, 4s inReconfigurationSpec).Replaced with a
stateReached(client, target)helper that resolves aPromiseon the next matchingExecutionStateUpdate. The post-resume sleep is dropped entirely —Await.result(resumeWorkflow)already blocks untilResumeHandlerfinishes, by which point all workers are inRUNNING.Wait timeout: 10s (~2.5× the original sleep, leaves CI headroom while keeping hang feedback fast).
Any related issues, documentation, discussions?
Closes #4517.
How was this PR tested?
Local timing (warm sbt + DB):
Run completed inReconfigurationSpeccan't be measured locally on JDK 17 (ArrowMemoryUtilreflection); CI on JDK 11 will exercise it.Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 4.7)