-
Notifications
You must be signed in to change notification settings - Fork 144
FELIX-6778 Reduce number of re-creation(s) of SCR Component Registry thread #419
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
FELIX-6778 Reduce number of re-creation(s) of SCR Component Registry thread #419
Conversation
…l.Timer, with a ScheduledThreadPoolExecutor. This is configured to keep its core Thread(s) around for up to 10 seconds without any tasks. This enables a low 'ds.service.changecount.timeout' to be used, without having to pay the cost of a lot of short-lived threads being created.
Soundy interesting. |
In what area do you see the test execution struggling? I see one test failure (Felix6274Test), but that appears on main branch as well, and looks unrelated to this change. |
Without knowing much about this specific part of Felix and SCR in general, would java 21 virtual threads be of interest here? It would make the code more complex, as we want to support pre java 21 as well, but we have similar code in JettyService for Jetty 12. |
@paulrutter |
With reflection we could support both pre and post java 21 versions. felix-dev/http/jetty12/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java Line 284 in 54fd91e
|
In case of SCR, I don't think its use of threads (SCR Component Registry, or SCR Component Actor) benefit particularly from specific properties of virtual threads, as I interpret Oracle's description of virtual threads:
These properties do really fit with something like Jetty, but for SCR I don't really see what it would bring. |
I was triggered by this part of your description: 'without having to pay the cost of a lot of short-lived threads being created'. |
Wondered how this should work. |
Technically you could even use MR-Jar here, but I really don't think that Virtual Threads give a benefit here and a simple Threadpool would be sufficient. |
In the catch clause, one would just use a regular |
from my perspective, Java 11 is definitely no problem, Java 17 should be ok but might already cause problems for some, Java 21 will cause problems for more. Given the bandwidth I would go for a complicated solution that leverages Java 21, but also works with lower versions |
I just wanted to mention that there is some hard work going on to keep the core OSGi framework at java 8, moving SCR to anything higher would probably render this useless for those consumers. |
I need SCR on Java 8 for the now. Do we have performance metrics that show an improvement here? Can someone explain what |
I don't have a specific performance metric I can refer to, but I did notice that with a tiny Another benefit is that the code becomes a bit simpler, as there is no need to cancel midway (nor the synchronisation that is currently present to ensure this happens consistently).
I presume this is the reason, but I am not familiar with the exact reason(s) for this design. |
I fully agree. I wanted to understand what the reason was behind the setting to help me understand if there is a more simple way. I really don't like the current usage of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks fine and I don't see anything that requires Java > 8 here
scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java
Outdated
Show resolved
Hide resolved
Replaced the SCR Component Registry executor with the SCR Component Actor Added integration test that validates service.changecount property updates
scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java
Outdated
Show resolved
Hide resolved
scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java
Outdated
Show resolved
Hide resolved
scr/src/test/java/org/apache/felix/scr/integration/Felix6778Test.java
Outdated
Show resolved
Hide resolved
# Conflicts: # scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java
Removed m_componentActor parameter from ComponentRegistry.missingServicePresent()
You can rebase, than we have the logging fix in |
Thanks everyone for providing feedback and having this merged! |
Replaced the pattern of creating and cancelling a java.util.Timer, with a ScheduledThreadPoolExecutor. This is configured to keep its core Thread(s) around for up to 10 seconds without any tasks. This enables a low 'ds.service.changecount.timeout' to be used, without having to pay the cost of a lot of short-lived threads being created.