James Kleeh
James Kleeh

Reputation: 12228

Grails development enviornment page loads very slow

So I'm getting page load times in the range of 30-45 seconds.

Some history:

This was not always the case for this project. This project is in production so I haven't really touched the code in a while. I noticed it started happening the last time I was updating the code. I don't recall anything specific that I changed that should have anything to do with the problem. I have other projects that are running with the same Grails versions with no problem.

I think it started happening in 2.2.3. I am now running 2.2.4.

I am using x64 JDK 1.7.0_25, Windows 7 x64.

I'm not sure what else to put here that would be relevant. Any assistance is appreciated!

Edit: running with -noreloading has no effect.

Edit2: I've tried deleting my .grails folder entirely, running clean, and deleting my target folder and stacktrace log.

Edit3: It does seem that the amount of time it takes is dependent on the amount of data displayed/read. Small pages take 3-4 seconds. Medium pages 10-12 seconds...

Edit4: I'm running it via IntelliJ IDEA 12.1.4 x64 (idea64.exe). I've also tried it outside of IntelliJ with the same results.

Edit5: The database is Oracle enterprise that supports the entire company. It is managed by full time adminstrators. This isn't a MySQL server on my local machine.

Edit6: The application also functions normally when deployed in TEST (test war), but still is slow when ran with test run-app.

Starting to get somewhere: I downloaded JDK 1.7.21 and ran the app with that and it started working no problem! I then ran clean which triggered a recompile and it stopped working... grr

Now with 1.7.21 still active, I tried -noreloading and it works!

Annnd... now it works even if I don't use -noreloading..........

I've gone back to 1.7.25.. ran clean, and it works. Sooooooo yeah... explain that.

And now it doesn't anymore.

Upvotes: 2

Views: 3869

Answers (4)

James Kleeh
James Kleeh

Reputation: 12228

So the reason why this was happening:

JDK 1.7.25

Upvotes: 0

user235273
user235273

Reputation:

  1. Delete stacktrace file in the target folder of your project. It can get huge. (At present mine is 48 GB).
  2. Check if there is enough space in your C directory.
  3. If you are hot swapping code, then page loads can get slow. So in such cases, restart the dev server (grails app).
  4. Sometimes, requests to the server can hang, where focusing (left or right clicking on the cmd) on the command prompt seems to skip the pause. (weird)
  5. Increasing the JVM permgen, heap spaces depending on your memory might help as well.
  6. Try running the server using command prompt rather within an IDE.
  7. Better use methods for actions than closures.

For a system with 3GB RAM, my environment variable setting is:

JAVA_OPTS
-Xms512m -Xmx1g  

The STS.ini settings:

-startup
plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.100.v20110502
-product
com.springsource.sts.ide
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
384M
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xmn128m
-Xms1024m
-Xmx1024m
-Xss2m
-XX:PermSize=256m
-XX:MaxPermSize=512m
-XX:MaxGCPauseMillis=10
-XX:MaxHeapFreeRatio=50
-XX:+UseConcMarkSweepGC
-XX:+CMSIncrementalMode
-XX:+CMSIncrementalPacing
-XX:+UserParallelGC

8) Maybe the problem is with the JDK and grails versions combination. There seems to be an error with OpenJDK 1.7u25 and spring loaded. Okay, you are not using OpenJDK, but try with other version anyway. Try with JDK1.7u03.
9) Try JVM with -server flag, and see if it improves runtime performance.

grails run-app -server

Upvotes: 0

V H
V H

Reputation: 8587

This is under Linux but will maybe useful:

If you are running the code within an IDE:

ps auwx|grep java

-Dgrails.console.class=grails.build.logging.GrailsEclipseConsole -Dosgi.requiredJavaVersion=1.6 -Xms40m -Xmx768m -XX:MaxPermSize=256m -

As you can see the memory settings Xms and Xmx are quite low...

In your IDE there should be an INI file:

more STS.ini 
      1 -vm
      2 /usr/lib/jvm/java-6-openjdk-amd64/bin/java
      3 -startup
      4 plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
      5 --launcher.library
      6 plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1.200.v20120913-144807
      7 -product
      8 org.springsource.sts.ide
      9 --launcher.defaultAction
     10 openFile
     11 -vmargs
     12 -Dgrails.console.enable.interactive=false
     13 -Dgrails.console.enable.terminal=false
     14 -Djline.terminal=jline.UnsupportedTerminal
     15 -Dgrails.console.class=grails.build.logging.GrailsEclipseConsole
     16 -Dosgi.requiredJavaVersion=1.6
     17 -Xms40m
     18 -Xmx768m
     19 -XX:MaxPermSize=256m

You can up these value and try restarting your IDE...

I would also suggest you run something like nmon before/during and monitor whilst the code is running and monitor disk/cpu/network throughputs.

You may find you are hammering your dev box which is causing the issue.

If the production is fine I really don't see what the problem is..

E2A Ahhh forgot it was under windows so no nmon for windblows but hey not that I tried it - http://sourceforge.net/projects/jnmonanalyser/

E2A again: 1. Enable DataSource.groovy debugging:

dataSource {
    pooled = true
    driverClassName ="com.mysql.jdbc.Driver"
    username = "aaa"
    password = "aaaa"
    //SQL Logging - refer to Config.groovy at hibernate.sql now
    logSql=true
    ...
  1. config.groovy - this will stop your app from running if you have issues with lets say records you are trying to add in your BootStrap

    // Return error when it fails //grails.gorm.failOnError=true

Enable log4j and use this or part of it:

// log4j configuration
log4j {
    appender.stdout = "org.apache.log4j.ConsoleAppender"
    appender.'stdout.layout'="org.apache.log4j.PatternLayout"
    appender.'stdout.layout.ConversionPattern'='[%r] %c{2} %m%n'
    appender.stacktraceLog = "org.apache.log4j.FileAppender"
    appender.'stacktraceLog.layout'="org.apache.log4j.PatternLayout"
    appender.'stacktraceLog.layout.ConversionPattern'='[%r] %c{2} %m%n'
    appender.'stacktraceLog.File'="stacktrace.log"
    appender.'stacktraceLog.MaxFileSize'="1MB"
    rootLogger="error,stdout"
    logger {
        grails="error"
        StackTrace="error,stacktraceLog"
        org {
            codehaus.groovy.grails.web.servlet="error"  //  controllers
            codehaus.groovy.grails.web.pages="error" //  GSP
            codehaus.groovy.grails.web.sitemesh="error" //  layouts
            codehaus.groovy.grails."web.mapping.filter"="error" // URL mapping
            codehaus.groovy.grails."web.mapping"="error" // URL mapping
            codehaus.groovy.grails.commons="info" // core / classloading
            codehaus.groovy.grails.plugins="error" // plugins
            codehaus.groovy.grails.orm.hibernate="error" // hibernate integration

            // Hibernate should be on - if you want to catch sql logs
            springframework="off"
            hibernate="on"
            //hibernate.SQL = 'debug'
            //hibernate.type = 'trace'
            //hibernate.SQL = 'info,hibernate'
            //hibernate.type = 'info,hibernate'
            //hibernate = 'info,hibernate'


            //apache.commons.digester.Digester = 'debug,javaclasses'
        }
    }
    additivity.StackTrace=false
}

try and capture what it is doing, it is also worth running developer tools on your browser whether its firefox of chrome and trying to figure out on what elements it is taking that time - but between the logs and the browser developer tools should lie your answer.

Upvotes: 1

Sliq
Sliq

Reputation: 16494

Usually you can fix this by doing

grails clean

on the grails command line (I open it via CRTL+ALT+G in IntelliJ IDEA). This erases all compiled files and will recompile your project from scratch (afaik), which usually erases errors like that. This is not a real fix for the underlying problem, but it solves the problem. Grails is highly experimental and unstable if you ask me, i have a lot of weird error that usually disappear when doing a clean. Btw i'm using 2.1.5 on Windows 7 x64, too.

Upvotes: 0

Related Questions