Unnecessary getApplicationPageSource() file system access on every request adds overhead
Description
Environment
Attachments
- 22 Feb 2021, 09:14 am
causes
Activity
Brad Wood 26 February 2021 at 18:03
@Michael Offner Thanks for looking into this.
Michael Offner 26 February 2021 at 17:35Edited
I do not call PageSource.exists anymore, instead i load the page (what is done later anyway), benefit is that loading the page is based on the “inspect template“ rule. for loading i use a method that return null if the file does not exists and only throws a exception when it fails to compile.
Michael Offner 26 February 2021 at 17:33
Michael Offner 22 February 2021 at 19:54
@Brad Wood the execution of the application.cfc happens in 2 steps.
search for the Application.[.cfc|.cfm] depending on the rules defined in the Lucee Admin/cfconfig (mode and type).
if the Application.[.cfc|.cfm] is found the next step is to find out if the Application.[.cfc|.cfm] did change and need redeployment based on the “inspect template“ rule set.
The new https://luceeserver.atlassian.net/browse/LDEV-3293 i did open is only about #1, so adding a cache for searching the Application.[.cfc|.cfm] that can be configured. https://luceeserver.atlassian.net/browse/LDEV-3293 is not addressing a bug it is about adding a new feature to Lucee that because it is a feature will only be implemented in Lucee 6.
The main focus of THIS ticket IN MY OPINION is mainly about #2, so if Lucee has enabled “inspect template“ and for example if you call /index.cfm and next to that template is the Application.cfc, should Lucee still make a file access because Lucee has loaded the Application.cfc already into the pagepoolcache, in other words can Lucee use the PagePoolCache do find the application.cfc faster if “inspect template“ is set to “never”. There are scenarios where the Application.cfc can only be in one place like in my example just given, can Lucee optimize that exact scenario?
I do not know, but i will find out.
Brad Wood 22 February 2021 at 18:52
@Michael Offner To be clear, Lucee still checks for the existence of the Application.cfc file on every request even if it does exist and has been created previously. So I would agree then with you that this ticket is asking for that lookup to be cached so it doesn't happen every time.
Can you explain what the purpose of ticket https://luceeserver.atlassian.net/browse/LDEV-3293#icft=LDEV-3293 is since it seems you have merely duplicated this ticket, but with fewer details.
Details
Assignee
Michael OffnerMichael OffnerReporter
Brad WoodBrad WoodPriority
CriticalLabels
Fix versions
New Issue warning screen
Before you create a new Issue, please post to the mailing list first https://dev.lucee.org
Once the issue has been verified, one of the Lucee team will ask you to file an issue
Sprint
None
Details
Details
Assignee
Reporter
Priority
Labels
Fix versions
New Issue warning screen
Before you create a new Issue, please post to the mailing list first https://dev.lucee.org
Once the issue has been verified, one of the Lucee team will ask you to file an issue
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 above.
Every page request to Lucee calls
res.exists()
as part of MixedAppListener.getApplicationPageSource() to check for an Application.cfm or Application.cfc file which results in at least one touch to the file system. I had "inspect templates" set to "never" during this test so I would expect Lucee to cache this lookup and not perform it every page request.
java.lang.Thread.State: RUNNABLE at java.io.UnixFileSystem.getBooleanAttributes0(Native Method) at java.io.UnixFileSystem.getBooleanAttributes(UnixFileSystem.java:242) at java.io.File.exists(File.java:821) at lucee.commons.io.res.type.file.FileResource.exists(FileResource.java:550) at lucee.commons.io.res.util.ResourceUtil.exists(ResourceUtil.java:736) at lucee.runtime.PageSourceImpl.physcalExists(PageSourceImpl.java:808) at lucee.runtime.PageSourceImpl.exists(PageSourceImpl.java:802) at lucee.runtime.listener.MixedAppListener.getApplicationPageSourceCurrent(MixedAppListener.java:60) at lucee.runtime.listener.MixedAppListener.getApplicationPageSourceCurrToRoot(MixedAppListener.java:70) at lucee.runtime.listener.MixedAppListener.getApplicationPageSource(MixedAppListener.java:52) at lucee.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:40) at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2442) at lucee.runtime.PageContextImpl._execute(PageContextImpl.java:2432) at lucee.runtime.PageContextImpl.executeCFML(PageContextImpl.java:2403) at lucee.runtime.engine.Request.exe(Request.java:44) at lucee.runtime.engine.CFMLEngineImpl._service(CFMLEngineImpl.java:1174) at lucee.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:1120) at lucee.loader.engine.CFMLEngineWrapper.serviceCFML(CFMLEngineWrapper.java:97) at lucee.loader.servlet.CFMLServlet.service(CFMLServlet.java:51) at javax.servlet.http.HttpServlet.service(HttpServlet.java:590) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)