Something I've noticed since using Three.js on a project is how heavily my coding agent relies on headless Chrome to perform rendering checks.
My machine's fans were running constantly, and I mean CONSTANTLY. I checked CPU usage and all 16 cores were sitting at 100%, for hours at a time. Not surprisingly, the machine was becoming unstable and occasionally crashing.
The culprit turned out to be headless Chrome. Depending on its configuration and environment, Chrome may or may not have access to GPU acceleration. In my case, it looked like the 3D rendering workload was falling back heavily on the CPU, hammering all available cores during tests.
The fix: I now launch Chrome through a small wrapper (scripts/chrome.mjs) that uses Linux's systemd-run to limit its CPU usage and lower its scheduling priority:
systemd-run --user --scope -p CPUQuota=1120% nice -n 10 chrome ...
This caps Chrome at roughly 70% of my 16-core machine's total CPU capacity and gives other processes room to breathe. It all happens automatically, so there's nothing to remember.
A couple of useful options:
- Change the limit:
CHROME_CPU=50 node scripts/sample-thumbs.mjs ... - Disable the limit:
CHROME_CPU=off
One thing worth knowing if you use CPUQuota yourself: the percentage is based on a single CPU core, not the entire machine. So 100% means one full core. On a 16-core machine, 1120% is roughly 70% of total CPU capacity.
This might save someone else a few hours of wondering why their workstation sounds like it's preparing for takeoff.