You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "David Costanzo (Jira)" <ji...@apache.org> on 2021/02/02 15:07:00 UTC
[jira] [Created] (JEXL-344) Don't fill stack trace for
JexlExpression#Return (to improve performance)
David Costanzo created JEXL-344:
-----------------------------------
Summary: Don't fill stack trace for JexlExpression#Return (to improve performance)
Key: JEXL-344
URL: https://issues.apache.org/jira/browse/JEXL-344
Project: Commons JEXL
Issue Type: Improvement
Affects Versions: 3.1
Reporter: David Costanzo
In profiling my JEXL-enabled application, I observed that nearly 10% of the execution time is spend filling in the {{JexlExpression#Return}} class's stack. As far as I can tell, the Return object's stack is not used by JEXL and so does not need to be present.
I read about an optimization technique where you override fillInStackTrace() to be a no-op when using exceptions for control flow. As I understand it, this practice was codified into Java 7 with the "writableStackTrace" parameter to Throwable's ctor that lets you disable filling in the stack trace.
For Java 6 and below, this is as easy as adding this to the body of {{Return}}.
{code:java}
@Override
public Throwable fillInStackTrace()
{
// Don't fill in the stack. It's not needed for return values.
return this;
}
{code}
In private testing, this has the expected effect: my application finishes in ~10% less time and all unit tests continue to pass.
There's a discussion of this on stack overflow:
[https://stackoverflow.com/questions/1836164/override-fillinstacktrace-for-control-flow-performance]
There's a better discussion in the answer given to:
[https://stackoverflow.com/questions/11434431/exception-without-stack-trace-in-java]
--
This message was sent by Atlassian Jira
(v8.3.4#803005)