views:

70

answers:

2

So I'm using Velocity in a legacy project. And even rendering moderately large pages takes FOREVER. Literally 10+ minutes.

There has to be some kind of bug I'm hitting... anyone else have bad experiences with Velocity in general? I'm about to start stepping through the source code and see where it hangs/etc but I wanted to see what SO had to say. :)

A: 

I used velocity on and off over the last years and I find it a robust and dependable templating engine. I have not faced the problems you describe and found it always fast enough.

These kind of delays look like there is something calling an external service. Velocity makes it easy to call methods on objects.

Maybe a profiler might shed light on this issue.

Peter Tillemans
We're using Eclipse for development. Do you have a suggestion on a good (preferably free) profiler?
bobber205
There is a profiler in the TPTP module of eclipse, but I never have had a lot of luck with TPTP. A recent version of visualvm (https://visualvm.dev.java.net/profiler.html) works quite well. Both are free.
Peter Tillemans
Top methods called are jj_scan_token (nearly 1 million times) with some jj_3R_XX in there as well.
bobber205
1 million? Your template is obscenely large or you have some non-terminating loop/recursion going on, probably involving some VTL evaluation (velocimacro, #parse, #evaluate, etc).
Nathan Bubna
There are calls to #parse in there.
bobber205
+1  A: 

What version are you using? If you don't say 1.6.4 or 1.7-beta1, then that's your first problem. 1.5 had some serious performance issues for anyone using velocimacros heavily.

And is it just on first render or on subsequent ones too? What resource loader are you using? Is caching on? Are you trying to use it as a scripting language?

Do not waste time stepping through. This is what profilers are for.

Your question, if it can be called that, is severely lacking in information. All you said is "X is slow". If you want help, you're gonna have to share some info about what you're actually doing. And asking an actual question wouldn't hurt either.

Nathan Bubna
Questions answered in order:
bobber205
1) Were using 1.5. Switching to 1.7 soon. Tried it just now. Problem persists.
bobber205
2) Not sure on which render. 3) Not sure on resource loader. 4) Not sure on caching. :P 5) What do you mean by scripting language?
bobber205
Sorry about all the comments. Annoyed that return submits. :(
bobber205
1) Good.2) Uh, why not? Restart the app, render, render again. Then answer.
Nathan Bubna
Nathan Bubna
And i'll tell you right now, that Velocity is not slow. If your app is slow, the hangup is there. You are either loading resources over a slow network and not caching, calling out to some extremely slow methods, using obscenely large and complex templates with many velocimacros, or some combination of the three. 10 minutes is absolutely unheard of. You're doing something wrong.
Nathan Bubna
Confirmed with coworkers. We do NOT use macros. :) I've narrowed down the speed problems to a few specific files. What should I be looking for? :)
bobber205
The slowdown is seen when the server is running off of and loading off of localhost.
bobber205
And caching? As in your (superior) repeat of this question, this looks like a non-cached VTL evaluation in a very large or infinite loop/recursion. If you have caching off, then it could be a #parse call, otherwise it would be an #evaluate or $render tool use or something like that.
Nathan Bubna