tdewolff / minify

Go minifiers for web formats

Home Page:https://go.tacodewolff.nl/minify

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

High CPU Usage After Minification

c9845 opened this issue · comments

When I run minify -w -v -o website/static/css/styles.min.css website/static/css/styles.css sometimes, most times, my CPU will sit at 25%+ usage even after minification ends and until I kill the minify process. I am on W11 22H2 using the latest minify version, i7-12700 with 12 cores and 20 threads.

Minification itself is fast. I am minifying ~17KB of CSS (and ~1.3MB of JS). I am minifying single files in "watch" mode. When minification runs, the CPU spikes as expected, and the minification completes in a very short amount of time (<1ms for my CSS, ~15ms for my JS). However, the CPU then stays at ~25% even with no minification running...minify is just watching for changed at this point. It seems like watching is using up a ton of CPU for no good reason.

The high CPU during watching only occurs after minification has run. If I start minify in watch mode but don't change any files, the CPU usage stays at near zero. Only after minification has run does the CPU usage stay elevated.

It also seems that when the CPU stays elevated during watching, the -v logging output doesn't update.

Does this happen too when simply minifying without watching?

I've pushed out a possible fix with ca97b30. Are you able to test from the master branch? You need to clone the repository and run make install in the repo directory (or othersider go to cmd/minify/ and run go install). Thanks!

I did not test without watching.

I cloned the repo and tested. Your latest changes seem to have helped. The minify process does not consume a whole much of CPU while watching.

This has been fixed in v2.20.10!