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

reschke 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 9eb03e0  SLING-12222: INFO-level log not only query time but also # of 
resources (and rate) for sling:alias and sling:vanityPath (#112)
9eb03e0 is described below

commit 9eb03e021669a2520f96598968c00832ff6c0f47
Author: Julian Reschke <[email protected]>
AuthorDate: Tue Jan 16 10:44:35 2024 +0100

    SLING-12222: INFO-level log not only query time but also # of resources 
(and rate) for sling:alias and sling:vanityPath (#112)
    
    * SLING-12222: INFO-level log not only query time but also # of resources 
(and rate) for sling:alias and sling:vanityPath
    
    * SLING-12222: tune log message
---
 .../apache/sling/resourceresolver/impl/mapping/MapEntries.java | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

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 947fe91..a1372de 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
@@ -352,7 +352,10 @@ public class MapEntries implements
                 drainQueue(resourceChangeQueue);
 
                 long initElapsed = System.nanoTime() - initStart;
-                log.info("vanity path initialization - end, elapsed {}ms", 
TimeUnit.NANOSECONDS.toMillis(initElapsed));
+                long resourcesPerSecond = (vanityResourcesOnStartup.get() * 
TimeUnit.SECONDS.toNanos(1) / (initElapsed == 0 ? 1 : initElapsed));
+                log.info(
+                        "vanity path initialization - completed, processed {} 
resources with sling:vanityPath properties in {}ms (~{} resource/s)",
+                        vanityResourcesOnStartup.get(), 
TimeUnit.NANOSECONDS.toMillis(initElapsed), resourcesPerSecond);
             } catch (LoginException ex) {
                 log.error("Vanity path init failed", ex);
             } finally {
@@ -1162,6 +1165,7 @@ public class MapEntries implements
             it = queryUnpaged("alias", baseQueryString);
         }
 
+        log.debug("alias initialization - start");
         long count = 0;
         long processStart = System.nanoTime();
         while (it.hasNext()) {
@@ -1169,7 +1173,9 @@ public class MapEntries implements
             loadAlias(it.next(), map);
         }
         long processElapsed = System.nanoTime() - processStart;
-        log.debug("processed {} resources with sling:alias properties in 
{}ms", count, TimeUnit.NANOSECONDS.toMillis(processElapsed));
+        long resourcePerSecond = (count * TimeUnit.SECONDS.toNanos(1) / 
(processElapsed == 0 ? 1 : processElapsed));
+        log.info("alias initialization - completed, processed {} resources 
with sling:alias properties in {}ms (~{} resource/s)",
+                count, TimeUnit.NANOSECONDS.toMillis(processElapsed), 
resourcePerSecond);
 
         this.aliasResourcesOnStartup.set(count);
 

Reply via email to