Lucee
Lucee copied to clipboard
LDEV-3723: Refactor/page source impl thread safety
Ticket: https://luceeserver.atlassian.net/browse/LDEV-3723
Reason for the MR:
Currently Component loader relly heavily on PageSource.loadPageThrowTemplateException
This method is currently synchronized, and any helper used as a themed function repository will puth the lock under pressure, this refactoring aims at reducing the amount of time with the lock held,
If the idea floats, i'll add a small rework to ensure a single threads enters the compilation routine, and the others benefit from the result to avoid another thrampling.
We discovered this issue by having hoptpoints pointing to this stacktrace:
http-nio-192.168.35.136-8080-exec-3" #70 daemon prio=1 os_prio=0 tid=0x00007f054da75000 nid=0x3a46 waiting for monitor entry [0x00007f04a1025000]
java.lang.Thread.State: BLOCKED (on object monitor)
at lucee.runtime.PageSourceImpl.loadPageThrowTemplateException(PageSourceImpl.java:233)
- waiting to lock <0x000000052d207d38> (a lucee.runtime.PageSourceImpl)
at lucee.runtime.PageSourceImpl.loadPage(PageSourceImpl.java:1013)
at lucee.runtime.component.ComponentLoader._search(ComponentLoader.java:219)
at lucee.runtime.component.ComponentLoader._search(ComponentLoader.java:117)
at lucee.runtime.component.ComponentLoader.searchComponent(ComponentLoader.java:84)
at lucee.runtime.functions.other._GetStaticScope.call(_GetStaticScope.java:32)
at business.object_cfc$cf$1.udfCalla(/cfc/business/Object.cfc:510)
at business.object_cfc$cf$1.udfCall(/cfc/business/Object.cfc)
at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:106)
at lucee.runtime.type.UDFImpl._call(UDFImpl.java:344)
the code involved here was simply
Component A {
public static method test() { return 1; }
}
Component B {
public static method caller() { return A::test(); }
}
This on a high traffic created hotpoints around the A component, only allowing one thread at a time to move through this zone.
Let me know how to let that move forward
@xdecock wrong jira ticket? (btw can you always put a link to the ticket in the first comment?)
@zspitzer indeed swapped 2 numbers https://luceeserver.atlassian.net/browse/LDEV-3723
the code in question has changed a lot since this PR was made (sorry) and we did apply similar improvements, i will go through all changes made in PR and see if we can apply parts of it manually.