here is the idea https://github.com/apache/tomcat/pull/576
Romain Manni-Bucau @rmannibucau <https://twitter.com/rmannibucau> | Blog <https://rmannibucau.metawerx.net/> | Old Blog <http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> | LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book <https://www.packtpub.com/application-development/java-ee-8-high-performance> Le mar. 24 janv. 2023 à 14:24, Mark Thomas <ma...@apache.org> a écrit : > Patches welcome if that is an itch someone wants to scratch. > > Mark > > > On 24/01/2023 13:22, Romain Manni-Bucau wrote: > > If you care about the (perf) diff, shouldnt tomcat have a config to be > able > > to disable stats overhead at all (using a Runnable or Counter {incr(), > > get()} as abstraction is sufficient) when it is not used (most of the > time > > in dev+prod - ie not sizing/tuning phases)? > > > > Romain Manni-Bucau > > @rmannibucau <https://twitter.com/rmannibucau> | Blog > > <https://rmannibucau.metawerx.net/> | Old Blog > > <http://rmannibucau.wordpress.com> | Github < > https://github.com/rmannibucau> | > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book > > < > https://www.packtpub.com/application-development/java-ee-8-high-performance > > > > > > > > Le mar. 24 janv. 2023 à 14:19, Rémy Maucherat <r...@apache.org> a écrit > : > > > >> On Tue, Jan 24, 2023 at 1:26 PM <ma...@apache.org> wrote: > >>> > >>> This is an automated email from the ASF dual-hosted git repository. > >>> > >>> markt pushed a commit to branch 9.0.x > >>> in repository https://gitbox.apache.org/repos/asf/tomcat.git > >>> > >>> commit a7bf4d84f753d69acb66f5e45f5bc767a1d55e49 > >>> Author: Mark Thomas <ma...@apache.org> > >>> AuthorDate: Tue Jan 24 12:22:01 2023 +0000 > >>> > >>> LongAdder is a better choice for statistics collection > >> > >> Never heard of that before, but I see it's already there in Java 8. > >> > >> Rémy > >> > >>> --- > >>> java/org/apache/catalina/webresources/Cache.java | 17 > +++++++++-------- > >>> 1 file changed, 9 insertions(+), 8 deletions(-) > >>> > >>> diff --git a/java/org/apache/catalina/webresources/Cache.java > >> b/java/org/apache/catalina/webresources/Cache.java > >>> index 949117f521..4893a289cb 100644 > >>> --- a/java/org/apache/catalina/webresources/Cache.java > >>> +++ b/java/org/apache/catalina/webresources/Cache.java > >>> @@ -22,6 +22,7 @@ import java.util.TreeSet; > >>> import java.util.concurrent.ConcurrentHashMap; > >>> import java.util.concurrent.ConcurrentMap; > >>> import java.util.concurrent.atomic.AtomicLong; > >>> +import java.util.concurrent.atomic.LongAdder; > >>> > >>> import org.apache.catalina.WebResource; > >>> import org.apache.catalina.WebResourceRoot.CacheStrategy; > >>> @@ -48,8 +49,8 @@ public class Cache { > >>> private int objectMaxSize = (int) maxSize / > OBJECT_MAX_SIZE_FACTOR; > >>> private CacheStrategy cacheStrategy; > >>> > >>> - private AtomicLong lookupCount = new AtomicLong(0); > >>> - private AtomicLong hitCount = new AtomicLong(0); > >>> + private LongAdder lookupCount = new LongAdder(); > >>> + private LongAdder hitCount = new LongAdder(); > >>> > >>> private final ConcurrentMap<String, CachedResource> > resourceCache = > >> new ConcurrentHashMap<>(); > >>> > >>> @@ -70,7 +71,7 @@ public class Cache { > >>> } > >>> } > >>> > >>> - lookupCount.incrementAndGet(); > >>> + lookupCount.increment(); > >>> > >>> CachedResource cacheEntry = resourceCache.get(path); > >>> > >>> @@ -138,14 +139,14 @@ public class Cache { > >>> cacheEntry.validateResource(useClassLoaderResources); > >>> } > >>> } else { > >>> - hitCount.incrementAndGet(); > >>> + hitCount.increment(); > >>> } > >>> > >>> return cacheEntry; > >>> } > >>> > >>> protected WebResource[] getResources(String path, boolean > >> useClassLoaderResources) { > >>> - lookupCount.incrementAndGet(); > >>> + lookupCount.increment(); > >>> > >>> // Don't call noCache(path) since the class loader only > caches > >>> // individual resources. Therefore, always cache collections > >> here > >>> @@ -196,7 +197,7 @@ public class Cache { > >>> > cacheEntry.validateResources(useClassLoaderResources); > >>> } > >>> } else { > >>> - hitCount.incrementAndGet(); > >>> + hitCount.increment(); > >>> } > >>> > >>> return cacheEntry.getWebResources(); > >>> @@ -291,11 +292,11 @@ public class Cache { > >>> } > >>> > >>> public long getLookupCount() { > >>> - return lookupCount.get(); > >>> + return lookupCount.sum(); > >>> } > >>> > >>> public long getHitCount() { > >>> - return hitCount.get(); > >>> + return hitCount.sum(); > >>> } > >>> > >>> public void setObjectMaxSize(int objectMaxSize) { > >>> > >>> > >>> --------------------------------------------------------------------- > >>> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org > >>> For additional commands, e-mail: dev-h...@tomcat.apache.org > >>> > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org > >> For additional commands, e-mail: dev-h...@tomcat.apache.org > >> > >> > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org > For additional commands, e-mail: dev-h...@tomcat.apache.org > >