Expose ShutdownManager poll interval to speed up TestWorkflowEnvironment teardown#2876
Open
brucearctor wants to merge 1 commit into
Open
Expose ShutdownManager poll interval to speed up TestWorkflowEnvironment teardown#2876brucearctor wants to merge 1 commit into
brucearctor wants to merge 1 commit into
Conversation
4edebfc to
5d644cf
Compare
maciejdudko
requested changes
May 14, 2026
Contributor
maciejdudko
left a comment
There was a problem hiding this comment.
Hi @brucearctor, thank you for your contribution. There are some minor issues that need to be addressed, but overall it's a great PR and hopefully we can get this merged soon.
Make the hard-coded 250ms CHECK_PERIOD_MS in ShutdownManager configurable through a new WorkerFactoryOptions.Builder#setShutdownCheckInterval(Duration) option. This allows test environments to use a much lower value (e.g. 1ms) to eliminate the shutdown polling overhead that dominates env-per-test teardown time (reported p50 = 506ms stock vs 7ms with a patched constant). The no-arg ShutdownManager constructor preserves the existing 250ms default for production use. When the option is set on WorkerFactoryOptions, WorkerFactory passes it through to the ShutdownManager constructor. Changes from review feedback: - Add DEFAULT_SHUTDOWN_CHECK_INTERVAL constant to WorkerFactoryOptions and apply it as default in validateAndBuildWithDefaults, similar to workflowCacheSize - Add @experimental annotation to setter and getter - Remove @nullable from field/getter since validated options always have the interval filled - Simplify WorkerFactory.doShutdown() by removing null check - Remove flaky/trivial ShutdownManagerTests, keep only validation tests - Update WorkerFactoryOptionsTest to verify default is 250ms Fixes temporalio#2869
5d644cf to
fb10321
Compare
Contributor
Author
|
@maciejdudko -- thanks for the thorough review! addressed |
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.
Summary
Makes the hard-coded 250ms
CHECK_PERIOD_MSinShutdownManagerconfigurable through a newWorkerFactoryOptions.Builder#setShutdownCheckInterval(Duration)option.Motivation
Resolves #2869. In env-per-test setups the 250ms shutdown poll interval dominates teardown wall-time:
Changes
ShutdownManagerCHECK_PERIOD_MSfrom a static constant to a configurable instance field. No-arg constructor preserves the 250ms default. NewShutdownManager(int checkPeriodMs)constructor with validation.WorkerFactoryOptionsshutdownCheckIntervalfield +Builder#setShutdownCheckInterval(Duration)with positive-duration validation.WorkerFactoryShutdownManagerindoShutdown().Usage
Backward Compatibility
Fully backward compatible — the no-arg
ShutdownManager()constructor and defaultWorkerFactoryOptionspreserve the existing 250ms behavior.