So the statement was actually true for Tomcat 9 (which we use) but false for 
Tomcat 10, which loads tcnative-2 first.

I now run several benchmarks to find out if tcnative-1.dll or tcnative-2.dll 
make a difference compared to each other and to running without them.
I noticed that when connector is configured to use APR 
(org.apache.coyote.http11.Http11AprProtocol), then tcnative-1 is required or 
Tomcat does not start.
So if you plan to use APR, then you must not have tcnative-2 included.
I think that it would be better to load the library that is used by the 
connector instead of loading one of them depending on the Tomcat version.
Of course if Tomcat stops supporting APR, then this problem goes away.

In those benchmarks, I noticed that when using NIO, then Tomcat was slightly 
faster without using tcnative-1 or tcnative-2, and tcnative-2 was a bit faster 
than -1.
When using APR (and tcnative-1), it was slightly faster than NIO without any 
native library.
This was with Java 11.
JDK 24 with NIO (without native library) was faster than Java 11 with APR (and 
tcnative-1).

So general finding was that perhaps Tomcat is better without using any native 
libraries, but if using APR, then it tcnative-1 is required.

-Harri

-----Original Message-----
From: Michael Osipov <micha...@apache.org>
Sent: tiistai 16. syyskuuta 2025 21.20
To: users@tomcat.apache.org
Subject: Re: Tomcat Native 1.3.1 vs 2.0.9

On 2025/09/16 09:09:45 Mark Thomas wrote:
> On 16/09/2025 08:49, Michael Osipov wrote:
> > On 2025/09/12 14:46:44 Mark Thomas wrote:
> >> On 12/09/2025 15:33, Harri Pesonen wrote:
> >>> Thanks, currently we have option to use APR but NIO is the default.
> >>> Perhaps we drop APR and then switch to Tomcat Native 2.
> >>>
> >>> What if we have both tcnative-1.dll and tcnative-2.dll available,
> >>> I guess that Tomcat will use tcnative-2.dll with NIO and
> >>> tcnative-1.dll with APR ? 😊
> >>
> >> You can only load one version of Tomcat Native into the JVM at any
> >> one time. If both are present, 1.x is used in preference to 2.x.
> >
> > Not true for 9.0.x
>
> Which part (or parts) of the above statement are you claiming is (are)
> not true?

This: 
https://github.com/apache/tomcat/blob/ef14a983ab626d7ca777cc1a9e79fe96b9308cd4/java/org/apache/tomcat/jni/Library.java#L31
But from 10.x+: 
https://github.com/apache/tomcat/blob/6dcdd3db93253c3599045e29b4491c4fe16c3a9e/java/org/apache/tomcat/jni/Library.java#L24

Preference depends on the version.

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

Reply via email to