commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dmitri Blinov (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (JEXL-215) JexlEngine.createInfo() is redundantly called when debug and caching is enabled leading to sub-optimal performance
Date Sat, 27 Aug 2016 11:57:20 GMT

    [ https://issues.apache.org/jira/browse/JEXL-215?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15441364#comment-15441364
] 

Dmitri Blinov commented on JEXL-215:
------------------------------------

The same applies to methods {{Engine.getProperty()}} and {{Engine.setProperty()}} also

> 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
>
> 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)

Mime
View raw message