Re: Naïve Tomcat experiment--does this indicate pinning?
Rob Bygrave
robin.bygrave at gmail.com
Sun May 1 21:20:27 UTC 2022
I've done this same test with Jetty with a similarly modified executor
against a couple of EA builds and it works exactly as expected. Obviously
there are OS limits that we can hit so in running this test we need to find
that OS resource limit.
*> I was hoping that making 10000 requests*
The *client and OS also* needs to support 10K [concurrent] requests. That
is, also check that the client isn't hitting a resource limit. To me, it
does not sound like the server is hitting a resource limit unless it is
actually barfing and the client isn't reporting that?. For myself I used
*hey* as the client tool for testing this.
Also note, I've additionally done this test from the HttpClient perspective
using JDK HttpClient with Loom - https://avaje.io/http-client/#10k ...
noting that you firstly need a server to handle the large number of
concurrent requests in order to run this test. I used Jetty + Loom as the
server for the client test.
I need to redo these tests with the latest EA.
Cheers, Rob.
On Mon, 2 May 2022 at 05:01, Alan Bateman <Alan.Bateman at oracle.com> wrote:
> On 01/05/2022 17:38, Cay Horstmann wrote:
> > Hi, I am running a simple experiment with Tomcat where one can easily
> > replace the executor for what I presume are the threads for each
> > servlet request. I use the following executor to which I submit all
> > tasks:
> >
> > ThreadFactory myfactory = Thread.ofVirtual()
> > .name("myfactory-", 1)
> > .factory();
> > exec = Executors.newThreadPerTaskExecutor(myfactory);
> >
> > Now I run a servlet that sleeps for 100 ms and then returns
> > Thread.currentThread().toString().
> >
> > When I fire lots of concurrent requests at the servlet, those returned
> > strings look like this:
> >
> > VirtualThread[#13508,myfactory-13452]/runnable at ForkJoinPool-1-worker-16
> > VirtualThread[#13515,myfactory-13459]/runnable at ForkJoinPool-1-worker-16
> > VirtualThread[#13513,myfactory-13457]/runnable at ForkJoinPool-1-worker-11
> > VirtualThread[#13512,myfactory-13456]/runnable at ForkJoinPool-1-worker-15
> >
> > I was hoping that making 10000 requests would result in 10000 tasks
> > that would all complete after roughly 100 ms. But it takes over 2
> > minutes to complete.
> >
> > So, now I am wondering whether it is possible that those threads
> > acquire an object lock or do something else that pins them. After all,
> > if not, why would they execute on different worker threads? How would
> > one go about debugging such a scenario?
>
> Can you run with -Djdk.tracePinnedThreads=full and see if it prints
> anything? Or if you can get JFR recording then you can use `jfr print
> --events jdk.VirtualThreadPinned` to see if there are of these events.
> Another option is to get a thread dump while it is running with `jcmd
> <pid> Thread.dump_to_file -format=json <file>`. There's more on these
> diagnostics in the JEP.
>
> -Alan
>
>
More information about the loom-dev
mailing list