Add Thread.Sleep(100)
to throttle REPL when it's non-interactive
#1694
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.
We integrated PSES into our project and noticed a considerable increase in CPU usage while PSES is running.
I downloaded the PSES project and was able to step through the code and see it is executing a
while
loop with zero throttling.Adding a
Thread.Sleep(100)
brought down the CPU of my application considerably when PSES was running. I did not notice any increase in latency when using PSES itself either.Here are the parameters we are using:
Using
Thread.Sleep(100)
is heavy handed, so the solution can likely be expanded to either take in a variable that specifies the sleep amount, or better yet, remove thewhile
loop entirely and refactor it into an even-driven approach and execute only when we have data in_taskQueue
.This solution works for us, but I am not at all familiar with the rest of this project. So please let me know if there are any obvious disadvantages with making this change. Thanks!