grails 2 / groovy 2 / JDK7: how to reap the benefi

2019-03-11 08:41发布

问题:

I really love Grails but I was wondering how to get the performance benefits of Groovy 2. The question is how to configure the development and production environments in order to get that "close to Java" performance boost.

So, if I setup:

* JDK 7
* Groovy 2 (indie JAR to use invokedynamic)
* Grails 2.2

are there any guidelines in order to really speed my webapp out-of-the-box?

And do I need to do any re-factoring in my Grails webapp codebase? I mean that dependency injection stuff like referencing services in controllers should be statically compiled or should I keep writing code as the docs say?

ps: I guess Groovy @CompileStatic and Grails might be a relevant question...

回答1:

It depends on what might be slowing your web application down :) I know "it depends" is so often the answer, but it's still true.

Anyway, I've asked around and it seems that Grails and invokedynamic won't go together just yet. The reloading agent needs updating and there may be problems with the cglib/asm libraries used by Hibernate.

Regardless, internally Grails is making more and more use of @CompileStatic (for the stuff that wasn't already written in Java), so unless your app is doing a lot of work itself, you're unlikely to see a big boost with invokedynamic.

It would be useful to have some official information on this, but it's not out there right now.