Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add customizability to JaxelEngine #24

Open
Selaron opened this issue Nov 14, 2023 · 0 comments
Open

Add customizability to JaxelEngine #24

Selaron opened this issue Nov 14, 2023 · 0 comments

Comments

@Selaron
Copy link
Contributor

Selaron commented Nov 14, 2023

In order to play with performance relevant options I'd like to be able to customize more properties of the JexlExpressionHandler:

Including:

  1. cache size (max number of cached expressions; default 5000)
  2. cacheThreshold (max length of expressions to be cached; default 64)
  3. debug (whether or not to provide debug info; default true)

While the advantage of being able to play around with 1 and 2 is quite self explaining, 3 maybe not:

As debug is enabled by default and all these options do not seem to be customizable easily without implementing a very custom ExpressionHandler, each rendering (huge) pug templates results in thousands of these executions:

    public JexlInfo() {
       final StackTraceElement[] stack = new Throwable().getStackTrace();
       ...
     }

which produces a lot of full stack traces of arbitrary length and is likely to hit the rendering speed.

As a simple solution maybe it would be enough to have the method de.neuland.pug4j.expression.JexlExpressionHandler#getJexlEngine refactored to use a PugJexlBuilder received from a protected method which we can override like:

@Override
protected PugJexlBuilder getPugJexlBuilder() {
   PugJexlBuilder builder = super.getPugJexlBuilder();
   builder.debug(false);
   builder.cache(10000);
   builder.cacheThreshold(256);
   return builder;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant