You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-dev@jackrabbit.apache.org by "nfsantos (via GitHub)" <gi...@apache.org> on 2024/08/02 09:47:21 UTC
[PR] OAK-10999 - indexing-job: report nodes that take the longest to index [jackrabbit-oak]
nfsantos opened a new pull request, #1621:
URL: https://github.com/apache/jackrabbit-oak/pull/1621
- Log any document that takes more than 1 second to index.
- Log the top 20 slowest documents at the end of indexing.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] OAK-10999 - indexing-job: report nodes that take the longest to index [jackrabbit-oak]
Posted by "reschke (via GitHub)" <gi...@apache.org>.
reschke commented on PR #1621:
URL: https://github.com/apache/jackrabbit-oak/pull/1621#issuecomment-2265300703
> System.currentTimeMillis() is not guaranteed to be monotonically increasing or to match the real elapsed time
But that is only true when somebody changed the system clock; if this bothers us, there are probably many places in the code base we need to adjust...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] OAK-10999 - indexing-job: report nodes that take the longest to index [jackrabbit-oak]
Posted by "nfsantos (via GitHub)" <gi...@apache.org>.
nfsantos commented on code in PR #1621:
URL: https://github.com/apache/jackrabbit-oak/pull/1621#discussion_r1703888435
##########
oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/TopKSlowestPaths.java:
##########
@@ -0,0 +1,70 @@
+package org.apache.jackrabbit.oak.index.indexer.document;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.PriorityQueue;
+import java.util.stream.Collectors;
+
+/**
+ * Keeps track of the top K entries that took the longest to index.
+ */
+final class TopKSlowestPaths {
+ final static class PathAndTime implements Comparable<PathAndTime> {
+ final String path;
+ final long timeMillis;
+
+ public PathAndTime(String key, long timeMillis) {
+ this.path = key;
+ this.timeMillis = timeMillis;
+ }
+
+ @Override
+ public int compareTo(PathAndTime o) {
+ return Long.compare(timeMillis, o.timeMillis);
+ }
+
+ @Override
+ public String toString() {
Review Comment:
I don't think it is necessary or advisable. Once we know what are the paths of the nodes, we can easily retrieve the node from the backing store and investigate further. And as we can't log the full contents of the node, we would have to select which parts to log, and we risk not to include the relevant information. But I think the more important reason not to log the contents is that we would be exposing more customer information on the logs, which we should avoid as much as possible.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] OAK-10999 - indexing-job: report nodes that take the longest to index [jackrabbit-oak]
Posted by "Amoratinos (via GitHub)" <gi...@apache.org>.
Amoratinos commented on code in PR #1621:
URL: https://github.com/apache/jackrabbit-oak/pull/1621#discussion_r1703850058
##########
oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/DocumentStoreIndexerBase.java:
##########
@@ -350,15 +352,29 @@ public void reindex() throws CommitFailedException, IOException {
INDEXING_PHASE_LOGGER.info("[TASK:INDEXING:START] Starting indexing");
Stopwatch indexerWatch = Stopwatch.createStarted();
try {
-
if (flatFileStores.size() > 1) {
indexParallel(flatFileStores, indexer, progressReporter);
} else if (flatFileStores.size() == 1) {
FlatFileStore flatFileStore = flatFileStores.get(0);
+ TopKSlowestPaths slowestTopKElements = new TopKSlowestPaths(TOP_SLOWEST_PATHS_TO_LOG);
Review Comment:
Why not accommodate the `IndexingProgressReporter` to provide this information?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] OAK-10999 - indexing-job: report nodes that take the longest to index [jackrabbit-oak]
Posted by "nit0906 (via GitHub)" <gi...@apache.org>.
nit0906 commented on code in PR #1621:
URL: https://github.com/apache/jackrabbit-oak/pull/1621#discussion_r1703678977
##########
oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/DocumentStoreIndexerBase.java:
##########
@@ -350,15 +352,29 @@ public void reindex() throws CommitFailedException, IOException {
INDEXING_PHASE_LOGGER.info("[TASK:INDEXING:START] Starting indexing");
Stopwatch indexerWatch = Stopwatch.createStarted();
try {
-
if (flatFileStores.size() > 1) {
indexParallel(flatFileStores, indexer, progressReporter);
} else if (flatFileStores.size() == 1) {
FlatFileStore flatFileStore = flatFileStores.get(0);
+ TopKSlowestPaths slowestTopKElements = new TopKSlowestPaths(TOP_SLOWEST_PATHS_TO_LOG);
+ long entryStart = System.nanoTime();
for (NodeStateEntry entry : flatFileStore) {
reportDocumentRead(entry.getPath(), progressReporter);
indexer.index(entry);
+ // Avoid calling System.nanoTime() twice per each entry, by reusing the timestamp taken at the end
+ // of indexing an entry as the start time of the following entry. This is less accurate, because
+ // the measured times will also include the bookkeeping at the end of indexing each entry, but
+ // we are only interested in entries that take a significant time to index, so this extra
+ // inaccuracy will not significantly change the results.
+ long entryEnd = System.nanoTime();
+ long elapsedMillis = (entryEnd - entryStart) / 1_000_000;
+ entryStart = entryEnd;
+ slowestTopKElements.add(entry.getPath(), elapsedMillis);
+ if (elapsedMillis > 1000) {
+ log.info("Indexing {} took {} ms", entry.getPath(), elapsedMillis);
+ }
}
+ log.info("Top slowest nodes to index (ms): {}", slowestTopKElements);
Review Comment:
Would it make sense to log the content of the nodes as well ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] OAK-10999 - indexing-job: report nodes that take the longest to index [jackrabbit-oak]
Posted by "nit0906 (via GitHub)" <gi...@apache.org>.
nit0906 commented on code in PR #1621:
URL: https://github.com/apache/jackrabbit-oak/pull/1621#discussion_r1703674558
##########
oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/DocumentStoreIndexerBase.java:
##########
@@ -107,6 +107,8 @@ public abstract class DocumentStoreIndexerBase implements Closeable {
protected final IndexerSupport indexerSupport;
private static final int MAX_DOWNLOAD_ATTEMPTS = Integer.parseInt(System.getProperty("oak.indexer.maxDownloadRetries", "5")) + 1;
+ private static final int TOP_SLOWEST_PATHS_TO_LOG = 20;
Review Comment:
should we make this configurable ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] OAK-10999 - indexing-job: report nodes that take the longest to index [jackrabbit-oak]
Posted by "nfsantos (via GitHub)" <gi...@apache.org>.
nfsantos commented on code in PR #1621:
URL: https://github.com/apache/jackrabbit-oak/pull/1621#discussion_r1703893809
##########
oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/DocumentStoreIndexerBase.java:
##########
@@ -350,15 +352,29 @@ public void reindex() throws CommitFailedException, IOException {
INDEXING_PHASE_LOGGER.info("[TASK:INDEXING:START] Starting indexing");
Stopwatch indexerWatch = Stopwatch.createStarted();
try {
-
if (flatFileStores.size() > 1) {
indexParallel(flatFileStores, indexer, progressReporter);
} else if (flatFileStores.size() == 1) {
FlatFileStore flatFileStore = flatFileStores.get(0);
+ TopKSlowestPaths slowestTopKElements = new TopKSlowestPaths(TOP_SLOWEST_PATHS_TO_LOG);
Review Comment:
It seems to me that adapting `IndexingProgressReporter` to expose this information would require some refactoring. I'd rather keep this simple and orthogonal to existing mechanisms, at least until being more sure of the value of logging the slowest elements.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] OAK-10999 - indexing-job: report nodes that take the longest to index [jackrabbit-oak]
Posted by "nit0906 (via GitHub)" <gi...@apache.org>.
nit0906 commented on code in PR #1621:
URL: https://github.com/apache/jackrabbit-oak/pull/1621#discussion_r1703678977
##########
oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/DocumentStoreIndexerBase.java:
##########
@@ -350,15 +352,29 @@ public void reindex() throws CommitFailedException, IOException {
INDEXING_PHASE_LOGGER.info("[TASK:INDEXING:START] Starting indexing");
Stopwatch indexerWatch = Stopwatch.createStarted();
try {
-
if (flatFileStores.size() > 1) {
indexParallel(flatFileStores, indexer, progressReporter);
} else if (flatFileStores.size() == 1) {
FlatFileStore flatFileStore = flatFileStores.get(0);
+ TopKSlowestPaths slowestTopKElements = new TopKSlowestPaths(TOP_SLOWEST_PATHS_TO_LOG);
+ long entryStart = System.nanoTime();
for (NodeStateEntry entry : flatFileStore) {
reportDocumentRead(entry.getPath(), progressReporter);
indexer.index(entry);
+ // Avoid calling System.nanoTime() twice per each entry, by reusing the timestamp taken at the end
+ // of indexing an entry as the start time of the following entry. This is less accurate, because
+ // the measured times will also include the bookkeeping at the end of indexing each entry, but
+ // we are only interested in entries that take a significant time to index, so this extra
+ // inaccuracy will not significantly change the results.
+ long entryEnd = System.nanoTime();
+ long elapsedMillis = (entryEnd - entryStart) / 1_000_000;
+ entryStart = entryEnd;
+ slowestTopKElements.add(entry.getPath(), elapsedMillis);
+ if (elapsedMillis > 1000) {
+ log.info("Indexing {} took {} ms", entry.getPath(), elapsedMillis);
+ }
}
+ log.info("Top slowest nodes to index (ms): {}", slowestTopKElements);
Review Comment:
Would it make sense to log the content of the nodes as well ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] OAK-10999 - indexing-job: report nodes that take the longest to index [jackrabbit-oak]
Posted by "nit0906 (via GitHub)" <gi...@apache.org>.
nit0906 commented on code in PR #1621:
URL: https://github.com/apache/jackrabbit-oak/pull/1621#discussion_r1703680984
##########
oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/TopKSlowestPaths.java:
##########
@@ -0,0 +1,70 @@
+package org.apache.jackrabbit.oak.index.indexer.document;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.PriorityQueue;
+import java.util.stream.Collectors;
+
+/**
+ * Keeps track of the top K entries that took the longest to index.
+ */
+final class TopKSlowestPaths {
+ final static class PathAndTime implements Comparable<PathAndTime> {
+ final String path;
+ final long timeMillis;
+
+ public PathAndTime(String key, long timeMillis) {
+ this.path = key;
+ this.timeMillis = timeMillis;
+ }
+
+ @Override
+ public int compareTo(PathAndTime o) {
+ return Long.compare(timeMillis, o.timeMillis);
+ }
+
+ @Override
+ public String toString() {
Review Comment:
Would it make sense to log the node content as well ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] OAK-10999 - indexing-job: report nodes that take the longest to index [jackrabbit-oak]
Posted by "nfsantos (via GitHub)" <gi...@apache.org>.
nfsantos commented on PR #1621:
URL: https://github.com/apache/jackrabbit-oak/pull/1621#issuecomment-2265287827
> Do we really need "nanoTime" here?
`System.currentTimeMillis()` is not guaranteed to be monotonically increasing or to match the real elapsed time, so for tracking times `nanoTime()` is the only one that will provide accurate results in all conditions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] OAK-10999 - indexing-job: report nodes that take the longest to index [jackrabbit-oak]
Posted by "nfsantos (via GitHub)" <gi...@apache.org>.
nfsantos commented on PR #1621:
URL: https://github.com/apache/jackrabbit-oak/pull/1621#issuecomment-2265357678
> > System.currentTimeMillis() is not guaranteed to be monotonically increasing or to match the real elapsed time
>
> But that is only true when somebody changed the system clock; if this bothers us, there are probably many places in the code base we need to adjust...
Or when NTP adjusts the clock. Or in another situations that we may not be considering. For me the important point is that the specification of `System.currentTimeMillis()` does not give enough guarantees to be sure that the elapsed time is accurate, so I will not use it for that purpose. I don't think we should make assumptions about the situations where the results will be inaccurate and say that it will never happen in our case. It may even be true now, but change in the future. So I prefer to program to the specification and `System.nanoTime()` is what guarantees accurate calculation of elapsed time.
And I do think we should not make use of `System.currentTimeMillis()` to measure times, but this is up to the owners of those modules to decide. The chances of this causing us problems are small, especially that in most cases the results are only used for human consumption.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] OAK-10999 - indexing-job: report nodes that take the longest to index [jackrabbit-oak]
Posted by "nfsantos (via GitHub)" <gi...@apache.org>.
nfsantos commented on code in PR #1621:
URL: https://github.com/apache/jackrabbit-oak/pull/1621#discussion_r1703882633
##########
oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/DocumentStoreIndexerBase.java:
##########
@@ -107,6 +107,8 @@ public abstract class DocumentStoreIndexerBase implements Closeable {
protected final IndexerSupport indexerSupport;
private static final int MAX_DOWNLOAD_ATTEMPTS = Integer.parseInt(System.getProperty("oak.indexer.maxDownloadRetries", "5")) + 1;
+ private static final int TOP_SLOWEST_PATHS_TO_LOG = 20;
Review Comment:
Done.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] OAK-10999 - indexing-job: report nodes that take the longest to index [jackrabbit-oak]
Posted by "nfsantos (via GitHub)" <gi...@apache.org>.
nfsantos merged PR #1621:
URL: https://github.com/apache/jackrabbit-oak/pull/1621
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org