grails-profiles / base

2 stars 12 forks source link

Grails CLI consumes 100% cpu while waiting for server to start up. #22

Closed valentingoebel closed 5 years ago

valentingoebel commented 6 years ago

Here are the profiler results: screenshot from 2018-04-17 15-14-23

As you can see isServerAvailable is called without any kind of rate limiting and consumes an entire core busy-waiting. This is especially bad if the server never starts because of an exception.

In the third row we see that isServerAvailable was called inside run-app.groovy

https://github.com/grails-profiles/base/blob/master/commands/run-app.groovy#L86

Usually the isServerAvailable function is called with a small delay as you can see in waitForStartup

waitForStartup sleeps 100 milliseconds between every call to isServerAvailable.

https://github.com/grails/grails-core/blob/master/grails-shell/src/main/groovy/org/grails/cli/profile/commands/io/ServerInteraction.groovy

Please add sleep 100 inside the while loop (https://github.com/grails-profiles/base/blob/master/commands/run-app.groovy#L86).

I would submit a PR but I have no idea how to build this project to test if I applied the change correctly.