On 21/01/2025 11:17, joan.balagu...@ventusproxy.com wrote:
Hi,

Virtual threads only shine on I/O bound tasks, in terms of throughput (not 
latency). They were created for that, don't expect any improvement on CPU bound 
tasks.

+1.

If I had to guess, I'd guess something to do with concurrency levels and context switching.

If you want to know the real answer then you'll need to use a profiler. I use YourKit because they give free copies to open source developers. Other profilers are available.

Mark



Regards,

Joan.

-----Original Message-----
From: Owner <o8076...@gmail.com>
Sent: Tuesday, January 21, 2025 11:32 AM
To: Tomcat Users List <users@tomcat.apache.org>
Subject: Re: Tomcat Virtual Threads Performance

Hi Maxim,

https://postimg.cc/N9n8CQW7

there you go! Do let me know if it's not up :)

Regards
Andy

On Tue, Jan 21, 2025 at 6:30 PM Maxim Solodovnik <solomax...@gmail.com>
wrote:

your image was dropped :((
please use some image image service and provide the URL here :))

On Tue, 21 Jan 2025 at 16:40, Owner <o8076...@gmail.com> wrote:

Hey Tomcat,

Andy here. I'm not sure if this is the place to ask this question,
but I wanted to check regarding performances of virtual threads vs
using a conventional worker thread pool.

I set up an endpoint with a CPU task of calculating factorials like
the
below:

@GetMapping("/fullCPU")
     public void allCPU() throws InterruptedException {
         factorialCalculator();
     }

public void factorialCalculator() {
         int numberOfOperations = 35;
         BigInteger factorial = BigInteger.ONE;
         int n = 4000;
         for (int i = 1; i <= numberOfOperations; i++) {
             for (int j = 1; j <= n; j++) {
                 factorial = factorial.multiply(BigInteger.valueOf(j));
             }
             factorial = BigInteger.ONE;
         }

When enabling virtual threads (using spring.virtual.threads.enabled
with Tomcat 10.1.33), the results I get are as follows. I utilise
JMeter to do stress testing -
[image: image.png]
Is there a reason why for CPU tasks, the performance for virtual
threads is so much worse? Theoretically both virtual threads and
platform threads should take the same amount of CPU time right?

Thank you!

Regards,
Andy



--
Best regards,
Maxim



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to