Skip to content

fix: high cpu usage during livesync #4322

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 30, 2019

Conversation

rosen-vladimirov
Copy link
Contributor

@rosen-vladimirov rosen-vladimirov commented Jan 29, 2019

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

@rosen-vladimirov rosen-vladimirov added this to the 5.2.0 milestone Jan 29, 2019
@rosen-vladimirov rosen-vladimirov self-assigned this Jan 29, 2019
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.
@rosen-vladimirov rosen-vladimirov force-pushed the vladimirov/fix-high-cpu-usage branch from 4cb8c9f to 2dab797 Compare January 29, 2019 17:46
@rosen-vladimirov rosen-vladimirov merged commit 949f9a4 into master Jan 30, 2019
@rosen-vladimirov rosen-vladimirov deleted the vladimirov/fix-high-cpu-usage branch January 30, 2019 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants