Jose Antonio created CXF-9028:
---------------------------------

             Summary: CXF produces thread pinning when using virtual threads
                 Key: CXF-9028
                 URL: https://issues.apache.org/jira/browse/CXF-9028
             Project: CXF
          Issue Type: Bug
            Reporter: Jose Antonio
         Attachments: image-2024-06-11-13-14-36-151.png, 
image-2024-06-11-13-15-39-139.png

When using virtual threads, it's important to avoid the use of synchronized 
objects and methods because I/O operations executed in them will pin the 
virtual thread to its carrier thread, blocking the carrier thread instead of 
the virtual one.

Executing some tests with a CXF client in a Tomcat server using virtual threads 
I see that, if I spawn a few tens of virtual threads I get a lot of thread 
pinning due to the code in 

 
{code:java}
PhaseInterceptorChain{code}
 

In this class, there's a method that's invoked for all requests 

 
{code:java}
public synchronized boolean doIntercept(Message message){code}
 

This method pins the virtual thread to the carrier thread for all the duration 
of the request and response, which might be a lot of time and it hinders the 
multithreaded applications throughput. Just changing the use of synchronized 
keywords for ReentrantLocks will solve this issue.

 

!image-2024-06-11-13-15-39-139.png|width=769,height=357!

 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to