fix: high cpu usage during livesync #4322
Merged
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.
During LiveSync operations (i.e.
tns run ...
), CLI may keep the CPU of the machine at a constantly high level even when it is not livesyncing. This is caused by the device detection changes that we are starting, which also checks for new emulator images.It turnes out the command
avdmanager list avds
takes really high usage of CPU on some machines when there are available AVD images.To fix this behavior split the current interval on two different ones - one will check for devices, which is run on 200ms and a second one which will check for emulator images, which will run once per minute.
Fix the
startDeviceDetectionInterval
method - it should just start the device detection instead of waiting for the first execution to receive results. This breaks the current behavior, so execute a single synchronous device detection before starting the interval - this way we keep the current behavior.PR Checklist
What is the current behavior?
Calling
tns run <platform>
on some Windows machines leads to constant high CPU utilization.What is the new behavior?
Calling
tns run <platform>
on some Windows machines leads to some rare spikes of high CPU utilization.Fixes issue #4324