This is an automated email from the ASF dual-hosted git repository.

cziegeler pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourceresolver.git


The following commit(s) were added to refs/heads/master by this push:
     new 53911d6  SLING-11394: improve diagnostics when # of vanity paths is 
close or greater than configured cache size (#74)
53911d6 is described below

commit 53911d6fc875641f01932cda6fe65b47dc0c8edd
Author: Julian Reschke <[email protected]>
AuthorDate: Thu Jul 7 06:49:21 2022 +0200

    SLING-11394: improve diagnostics when # of vanity paths is close or greater 
than configured cache size (#74)
    
    * SLING-11394: improve diagnostics when # of vanity paths is close or 
greater than configured cache size
    
    * Update 
src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java
    
    Co-authored-by: Jörg Hoh <[email protected]>
    
    * SLING-11394: minor rephrase
    
    Co-authored-by: Jörg Hoh <[email protected]>
---
 .../sling/resourceresolver/impl/mapping/MapEntries.java       | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git 
a/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java 
b/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java
index 1287a47..7c47a93 100644
--- 
a/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java
+++ 
b/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java
@@ -1253,6 +1253,7 @@ public class MapEntries implements
         log.debug("end vanityPath query; elapsed {}ms", 
TimeUnit.NANOSECONDS.toMillis(queryElapsed));
 
         long count = 0;
+        long countInScope = 0;
         long processStart = System.nanoTime();
 
         while (i.hasNext()) {
@@ -1260,13 +1261,21 @@ public class MapEntries implements
             final Resource resource = i.next();
             final String resourcePath = resource.getPath();
             if (Stream.of(this.factory.getObservationPaths()).anyMatch(path -> 
path.matches(resourcePath))) {
+                countInScope += 1;
                 final boolean addToCache = isAllVanityPathEntriesCached()
                         || vanityCounter.longValue() < 
this.factory.getMaxCachedVanityPathEntries();
                 loadVanityPath(resource, resolveMapsMap, targetPaths, 
addToCache);
             }
         }
         long processElapsed = System.nanoTime() - processStart;
-        log.debug("processed {} vanityPaths in {}ms", count, 
TimeUnit.NANOSECONDS.toMillis(processElapsed));
+        log.debug("processed {} vanityPaths (of which {} in scope) in {}ms", 
count, countInScope, TimeUnit.NANOSECONDS.toMillis(processElapsed));
+        if (!isAllVanityPathEntriesCached()) {
+            if (countInScope > this.factory.getMaxCachedVanityPathEntries()) {
+                log.warn("Number of vanity paths in scope ({}) exceeds 
configured cache size ({}); handling of uncached vanity paths will be much 
slower. Consider increasing the cache size or decreasing the number of vanity 
paths.", countInScope, this.factory.getMaxCachedVanityPathEntries());
+            } else if (countInScope > 
(this.factory.getMaxCachedVanityPathEntries() / 10) * 9) {
+                log.info("Number of vanity paths in scope ({}) within 10% of 
configured cache size ({})", countInScope, 
this.factory.getMaxCachedVanityPathEntries());
+            }
+        }
 
         return targetPaths;
     }

Reply via email to