You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by re...@apache.org on 2026/01/19 16:49:43 UTC

(jackrabbit-filevault) 01/01: JCRVLT-831: improve logging

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

reschke pushed a commit to branch reschke/831logging
in repository https://gitbox.apache.org/repos/asf/jackrabbit-filevault.git

commit a6147ef0b9ca987acee43082b099128ef90042e5
Author: Julian Reschke <ju...@gmx.de>
AuthorDate: Mon Jan 19 17:49:21 2026 +0100

    JCRVLT-831: improve logging
---
 .../jackrabbit/vault/fs/impl/AggregateImpl.java    | 31 ++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/AggregateImpl.java b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/AggregateImpl.java
index 28b0e71b..9b50ceb2 100644
--- a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/AggregateImpl.java
+++ b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/AggregateImpl.java
@@ -29,6 +29,7 @@ import javax.jcr.Value;
 
 import java.io.IOException;
 import java.lang.ref.WeakReference;
+import java.time.Duration;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -104,6 +105,8 @@ public class AggregateImpl implements Aggregate {
     private List<AggregateImpl> leaves;
 
     private String[] namespacePrefixes;
+    private long nodesVisitedForPrefixScanning;
+    private long siblingNodesInOrderedCollectionVisitedForPrefixScanning;
 
     private char state = STATE_INITIAL;
 
@@ -625,10 +628,21 @@ public class AggregateImpl implements Aggregate {
             }
             try {
                 load();
+                log.debug("starting namespace prefix walk of '{}'", this.path);
+                long start = System.nanoTime();
                 Set<String> prefixes = new HashSet<String>();
                 // need to traverse the nodes to get all namespaces
                 loadNamespaces(prefixes, "", getNode());
                 namespacePrefixes = prefixes.toArray(new String[prefixes.size()]);
+                Duration duration = Duration.ofNanos(System.nanoTime() - start);
+                log.debug(
+                        "namespace prefix walk of '{}', visited {} nodes (of which {} siblings in ordered collections), prefixes: {}, elapsed {}ms, ({})",
+                        this.path,
+                        this.nodesVisitedForPrefixScanning,
+                        this.siblingNodesInOrderedCollectionVisitedForPrefixScanning,
+                        this.namespacePrefixes,
+                        duration.toMillis(),
+                        duration);
             } catch (RepositoryException e) {
                 throw new IllegalStateException("Internal error while loading namespaces", e);
             }
@@ -637,6 +651,7 @@ public class AggregateImpl implements Aggregate {
 
     private void loadNamespaces(Set<String> prefixes, String parentPath, Node node) throws RepositoryException {
         String name = node.getName();
+        nodesVisitedForPrefixScanning += 1;
         addNamespace(prefixes, name);
         for (PropertyIterator iter = node.getProperties(); iter.hasNext(); ) {
             Property p = iter.nextProperty();
@@ -655,8 +670,11 @@ public class AggregateImpl implements Aggregate {
             Node c = iter.nextNode();
             String relPath = parentPath + "/" + c.getName();
             if (includes(relPath)) {
+                nodesVisitedForPrefixScanning += 1;
                 loadNamespaces(prefixes, relPath, c);
             } else if (hasOrderableChildNodes) {
+                nodesVisitedForPrefixScanning += 1;
+                siblingNodesInOrderedCollectionVisitedForPrefixScanning += 1;
                 addNamespace(prefixes, c.getName());
             }
         }
@@ -719,10 +737,15 @@ public class AggregateImpl implements Aggregate {
         // get a node iterator suitable for the current node and the applicable filters
         NodeIterator nIter = getNodeIteratorFor(node, filter);
 
+        log.debug("starting aggregate walk of '{}'", this.path);
+        int visited = 0;
+        long startTime = System.nanoTime();
+
         // include "our" nodes to the include set and delegate the others to the
         // respective aggregator building sub aggregates
         while (nIter.hasNext()) {
             Node n = nIter.nextNode();
+            visited += 1;
             String path = n.getPath();
             log.trace("checking {}", path);
 
@@ -780,6 +803,14 @@ public class AggregateImpl implements Aggregate {
                 }
             }
         }
+
+        Duration duration = Duration.ofNanos(System.nanoTime() - startTime);
+        log.debug(
+                "aggregate walk of '{}', visited {} siblings in {}ms ({})",
+                node.getPath(),
+                visited,
+                duration.toMillis(),
+                duration);
     }
 
     private static NodeIterator getNodeIteratorFor(Node node, WorkspaceFilter filter) throws RepositoryException {