Unnecessary getRootPath() file system access on every request adds overhead

Description

Now that I've added Lucee to the Techempower language benchmarks, I'm performance tuning the tests-- some of which just hit a hello world page with 512 threads to see how many requests the server can process a second.

One of the very first things I saw when profiling the JVM, was basically 512 threads all running the exact same code in the stack trace below.

Every page request to Lucee calls

as part of CFMLEngineImpl.getCFMLFactory() which results in a touch to the file system. This is not a check which needs to be run more than once per server restart since the servlet context root will not change. Lucee needs to cache this lookup and not invoke the file system hit every request.

FWIW, "inspect templates" was set to "never" during this test.

Environment

None

Activity

Show:
Tim Smolders
April 19, 2021, 9:56 AM

Could this have caused this error repeatedly showing up in stdout.log leading up to 500/server unresponsive?

  • [ERROR] io.undertow.request: UT005023: Exception handling request to /applicatie/index.cfm

  • javax.servlet.ServletException: cannot determinate webcontext root, the ServletContext from class [io.undertow.servlet.spec.ServletContextImpl] is returning null for the method call sc.getRealPath("/"), possibly due to configuration problem.

Brad Wood
April 13, 2021, 4:53 PM
Edited

That probably depends on whether the servlet's resource manager follows symlinks or not. If ServetContext.getRealPath() returns the location of the symlink, then it should still point to wherever the symlink points. You can probably test that by checking what you get from this:

See if you get your symlink back or if you get the folder that the symlink points to back.

Tom Chiverton
April 13, 2021, 2:36 PM

“This is not a check which needs to be run more than once per server restart since the servlet context root will not change”

What about if the target is a symlink ?

Zac Spitzer
March 10, 2021, 8:12 AM

Brad Wood
February 22, 2021, 7:37 PM

Thanks for the information!

Fixed
Your pinned fields
Click on the next to a field label to start pinning.

Assignee

Michael Offner

Reporter

Brad Wood

Priority

Major

Labels

Fix versions