Spike in CPU usage when iterating over large 'body' object with long timeout.
See original GitHub issueCurrent behavior:
Cypress interactive mode is trying things out with long timeouts.
CPU usage goes high and computer becomes warm.
Assumptions: Therefore doing too much on my CPU and network and therefore networks turns off.
https://youtu.be/IIpUElTV1Sk (Unlisted video, only you can see it)
When I kill the Cypress process, wifi turns on by itself.
Desired behavior:
Cypress does handle long timeouts.
It does not overflow the system and therefore does not overuse CPU and network, so that nothing turns itself off.
Test code to reproduce
Versions
MacOS 10.15.3
“cypress-cucumber-preprocessor”: “^2.0.1”, “cypress”: “^4.2.0”,
The timeout length is intentionally set:
{
"testFiles": "**/*.feature",
"chromeWebSecurity": false,
"defaultCommandTimeout": 60000,
"video": true
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How to create a CPU spike less than 1 cpu with a bash ...
With a 10% duty cycle, like 1 millisecond running a loop and then calling nanosleep to sleep for 9 milliseconds, you can achieve...
Read more >CPU spike causing nodes to go irresponsive - Yugabyte
This would cause the node to go unresponsive and any operations like SSH to eventually timeout.
Read more >How to fix high Java CPU usage problems - TheServerSide.com
CPU usage might skyrocket when your application is under load, but that spike might be attributable to a system process or a misconfiguration...
Read more >set_time_limit - Manual - PHP
When called, set_time_limit() restarts the timeout counter from zero. In other words, if the timeout is the default 30 seconds, and 25 seconds...
Read more >Paginate search results | Elasticsearch Guide [8.5] | Elastic
For deep pages or large sets of results, these operations can significantly increase memory and CPU usage, resulting in degraded performance or node ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Setting
numTestsKeptInMemory: 0
in thecypress.json
may help reduce the CPU usage. I’d suggest doing that to help for now.I think this is due to a few lines in your test, where you are wrapping over the entire body of an iframe and asserting against the body, with the increasing timeout making the issue worse.
There shouldn’t be a reason to have the
commandTimeout : 60000
for this specific.find()
command (since you already have the body object, retrying will not change the Object value) - and I’d suggest overwriting it with a lower timeout as a current workaround.I can recreate a spike in CPU using the following code:
index.html
iframe.html
Without
{ timeout: 60000 }
With
{ timeout: 60000 }
Seems to be spending a lot of time on this
formatProperty
method.https://github.com/cypress-io/cypress/blob/develop/packages/driver/src/cy/chai/inspect.js#L314:L314
This seems closely related to a bug fixed in 9,2, where unnecessary snapshots were being created while retrying commands. In some browsers this manifested as a memory leak followed by the browser crashing or hanging, while in others in caused an unnecessarily large amount of CPU usage, scaling with the size of the page under test.
https://github.com/cypress-io/cypress/issues/18549
A more technical discussion of the causes and resolution of the issue can be found in the PR that closed it: https://github.com/cypress-io/cypress/pull/19311
I’m going close this issue as resolved in 9.2,0 - if anyone involved is still seeing it after updating to that release, please let me know and I’ll reopen.