Incredibly high CPU load during test running #2600
bhallstein posted onGitHub
Hi, I'm encountering some strange behaviour. I'm using an (I think) fairly standard ava + enzyme + babel setup.
I initially noticed my machine was running poorly — almost totally locked up — while ava tests were running. Investigating, I was astonished to find that CPU load was continuously over 100 during test running. The machine is so intensely locked up that Activity Monitor won't refresh any of its CPU or memory info until ava has finished running the tests. That 100 figure isn't a percentage, that's the actual CPU load figure, as a % it would be 10,000% CPU load. I thought I must be dreaming it, but it really is true.
My first thought was to try without concurrency (-c 1
), and that results in CPU load around 1 (100%) as expected. Test running takes ~40s with -c 1
and CPU load of about 1, compare with ~30s without -c
and CPU load of about 100, system all but unusable.
Thinking about this, and 3 things seem possible explanations:
- ava is getting the number of CPU cores available on the machine wrong, spawning too many threads/processes.
- a 'thread bomb' situation, where lots of threads are spawned continuously.
- inefficient inter-process communication is occurring. I wondered if poor multithreading support in one of the libraries, e.g. Enzyme, could have this effect? Or if there is a locking system for non-multithreaded shared libraries or some part of the test execution process that might be spin locking?
Or it could be something else. As I've never seen anything quite like this before, I'd really appreciate anyone's thoughts if they have further ideas.
Code: link to repo
- Tests are in src/test
- package.json
npm run t
is simplyava src/test/*
The machine is a MacBook Air, 1.3GHz, 2 real cores and SMT.