[6.0] Check for time-sensitive work when worker thread starvation is ongoing #61931
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.
Customer Impact
When thread pool worker thread starvation is ongoing timer callbacks may not run. This can be problematic because timers intended to identify such issues and cause timeouts may not be triggered. This change does not fix the root of the problem, it only reverts the behavior to something similar to what was done in CoreCLR's native thread pool. It is and always has been possible for some timer callbacks to not run in reasonable time in such situations (such as when multiple timer callbacks are scheduled to run). This fix is only a minimal fix to revert the behavior in the portable thread pool to something similar to before, which would run one timer callback per batch during starvation.
Regression?
Yes, from 5.0
Testing
Verified behavior in the issue's test case. The behavior is reasonably similar to the previous behavior. No change in perf was noticed in highly bursty test cases that heavily exercise the modified path.
Risk
Low, the behavior is more similar to before and it's a small change in a path that is not too hot.