14
votes

I'm using Grails 2.0. I used to develop under Grails 1.3.7 but when running an application under Grails 2.0 the performance is very slow. A page can take more than 30 seconds to show and it's very embarrassing and unproductive.

I googled and I found that GSPs in 2.0 are in some cases 10 times slower than 1.3.7 ; Greame explained that there is a new way of handling GSPs in dev mod, but when executing grails prod run-app I have almost the same problem.

What should I do to speed up development process ? I'm loosing too much time.

PS : My GRAILS_OPTS are "-‬server‭ -‬Xmx600M‭ -‬Xms600M‭ -‬XX:MaxPermSize=250m‭ -‬Dfile.encoding=UTF-8 -Dserver.port=9090‭"‬

3
I just moved from 1.3.7 to 2.1.1 and I don't see any performance issues, rather I see imnprovement. Can you update to 2.1.1. Also can you convert all your actions to be methods instead of closures and see if that helps ? - allthenutsandbolts
Try profiling your app with, say, VisualVM. You cannot improve performance when you don't know which part to improve. - Victor Sergienko
It's mainly GSPs that are very slow. There is also resources plugin that makes a lot of nose in the console - Houcem Berrayana

3 Answers

7
votes

I posted an small announcement on the mailing list about 20 minutes ago: http://grails.1312388.n4.nabble.com/GSP-Compilation-tt4632864.html#a4635595

This issue was fixed: http://jira.grails.org/browse/GRAILS-9423

Please test the performance of the latest 2.1.x snapshot build.

Try these

export GRAILS_OPTS="-server -noverify -XX:PermSize=256m
-XX:MaxPermSize=256m -Xmx600M -Xms600m -XX:+UseParallelGC -Djava.net.preferIPv4Stack=true 
-Dsun.reflect.inflationThreshold=100000"

For me, the trick was to set Xmx and Xms to the same value and set the PermSize and MaxPermSize to the same value. sun.reflect.inflationThreshold helps with the permgen. (http://jira.grails.org/browse/GRAILS-7878?focusedCommentId=66447&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-66447 in the Grails jira for the explanation)

btw. I filed this issue 10 mins ago: http://jira.grails.org/browse/GRAILS-9444 If it's interesting, please vote on the issue.

3
votes

Grails 2.x is slower than 1.3.x for development mode because of the reloading improvements. It uses Spring-Loaded reloading agent that is similar to JRebel.

Make sure that your development laptop has enough memory (>4GB), a SSD and a fast i7 CPU.

Get a recent laptop with 16GB memory & a fast SSD and you won't be thinking of slowness anymore. I'd also recommend a i7 series CPU. That costs only about $1200 currently.

2
votes

To make sure you are using the latest fixes to the Spring-Loaded reloading agent, use Grails 2.1.x instead of Grails 2.0.x . For Grails 2.1.1 you might want to upgrade the Spring-Loaded reloading agent to a snapshot version.

You can get the latest snapshot from: https://repo.springsource.org/snapshot/com/springsource/springloaded/springloaded-core/

Currently it's https://repo.springsource.org/snapshot/com/springsource/springloaded/springloaded-core/1.1.1.BUILD-SNAPSHOT/springloaded-core-1.1.1.BUILD-20120821.173635-2.jar .

Replace $GRAILS_HOME/lib/com.springsource.springloaded/springloaded-core/jars/springloaded-core-1.0.6.jar with the downloaded snapshot (rename the snapshot to the same file name springloaded-core-1.0.6.jar).

This answer will be outdated as soon as springloaded-core version 1.1.1 gets released.