You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Henri Biestro (JIRA)" <ji...@apache.org> on 2016/08/31 10:50:20 UTC

[jira] [Resolved] (JEXL-215) JexlEngine.createInfo() is redundantly called when debug and caching is enabled leading to sub-optimal performance

     [ https://issues.apache.org/jira/browse/JEXL-215?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henri Biestro resolved JEXL-215.
--------------------------------
       Resolution: Fixed
         Assignee: Henri Biestro
    Fix Version/s: 3.1

Create default jexlinfo in parse() rather than in multiple places.
src/main/java/org/apache/commons/jexl3/internal/Engine.java
Committed revision 1758579.

> JexlEngine.createInfo() is redundantly called when debug and caching is enabled leading to sub-optimal performance
> ------------------------------------------------------------------------------------------------------------------
>
>                 Key: JEXL-215
>                 URL: https://issues.apache.org/jira/browse/JEXL-215
>             Project: Commons JEXL
>          Issue Type: Improvement
>    Affects Versions: 3.0
>            Reporter: Dmitri Blinov
>            Assignee: Henri Biestro
>             Fix For: 3.1
>
>
> The following two methods {{Engine.createScript()}} and {{Engine.createExpression()}} are calling {{JexlEngine.createInfo()}} when debug mode is enabled and JexlInfo is not provided. But if caching is enabled the method {{Engine.parse()}} will not use provided JexlInfo if the requested statement is already in the cache. This leads to sub-optimal performance, in my measurements up to 100 times slower. The suggestion is to refactor by removing the following code 
> {code}
>         if (info == null && debug) {
>             info = createInfo();
>         }
> {code}
> from methods {{Engine.createScript()}} and {{Engine.createExpression()}} and adding to the method {{Engine.parse()}} after the cache check, like this
> {code}
>     protected ASTJexlScript parse(JexlInfo info, String src, Scope scope, boolean registers, boolean expression) {
>         final boolean cached = src.length() < cacheThreshold && cache != null;
>         ASTJexlScript script;
>         synchronized (parser) {
>             if (cached) {
>                 script = cache.get(src);
>                 if (script != null) {
>                     Scope f = script.getScope();
>                     if ((f == null && scope == null) || (f != null && f.equals(scope))) {
>                         return script;
>                     }
>                 }
>             }
>             if (info == null && debug) {
>                 info = createInfo();
>             }
>             script = parser.parse(info, src, scope, registers, expression);
>             if (cached) {
>                 cache.put(src, script);
>             }
>         }
>         return script;
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)