Added code to throttle high cpu usage. #1187
Closed
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.
Description
Added a HighCycleThrottle class which can be used by defining USE_EPOLL_SELECTOR_FIX as an environment variable. When this variable is defined, the HighCycleThrottle class will introduce a 1 ms delay when high cycling is detected and remove the 1 ms delay when running normal.
Related Issue
This is related to issue 896.
Motivation and Context
When running the WebSocketServer on AWS, we see times when the CPU Load goes to 100% and stays there for about 2 hours. This is caused when the selector.select() quits blocking causing excessive cycles through the code. After about 2 hours the selector.select() will start blocking again and the CPU load returns to normal.
CPU only goes to 20% instead of 100% with these code changes.
Logging issue:
Issue cleared:
How Has This Been Tested?
We ran this code on AWS until we saw the condition reported in the logs, observed the throttling, and saw the condition clear. This code has been running several weeks without any issues.
Types of changes
Checklist: