Details
-
Improvement
-
Resolution: Fixed
-
Major
-
17.10.0
-
Unit
-
Unknown
-
N/A
-
N/A
-
Description
Every call to VelocityManager#getVelocityContext() re-synchronizes the request's Velocity context with the JSR-223 script context: ScriptVelocityContext#setScriptContext() copies all bindings of the global and engine scopes into the Velocity context. As ScriptVelocityContext#internalPut() writes every Velocity #set back into the engine scope, that scope contains every variable set by every template rendered so far in the request (237 on a simple page view of the standard flavor), and all of them are put again on each call although they are already there. Each put() interns the key (String.intern(), a native string table lookup), updates the map and writes the value back into the script context.
On a local profile of Sandbox.WebHome (standard flavor, master), getScriptVelocityContext() takes 14% of the request CPU, String.intern() alone ~10%. It is called for each template, Velocity macro, title, UI extension parameter and, through the Velocity fallback of icon themes, for each rendered icon.
Change
Skip the bindings whose value is already the one in the Velocity context. The remaining work per binding is a map lookup.
Attachments
Issue Links
- is related to
-
XCOMMONS-3912 Global script bindings override engine bindings and Velocity variables with the same name
-
- Closed
-