You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by mr...@apache.org on 2019/02/07 13:28:30 UTC
svn commit: r1853131 - in /jackrabbit/oak/trunk/oak-store-document/src:
main/java/org/apache/jackrabbit/oak/plugins/document/
test/java/org/apache/jackrabbit/oak/plugins/document/
Author: mreutegg
Date: Thu Feb 7 13:28:30 2019
New Revision: 1853131
URL: http://svn.apache.org/viewvc?rev=1853131&view=rev
Log:
OAK-8029: Additional merge metrics
Added:
jackrabbit/oak/trunk/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/MergeStats.java (with props)
Modified:
jackrabbit/oak/trunk/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/CommitBuilder.java
jackrabbit/oak/trunk/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/CommitDiff.java
jackrabbit/oak/trunk/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBranch.java
jackrabbit/oak/trunk/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreStats.java
jackrabbit/oak/trunk/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreStatsCollector.java
jackrabbit/oak/trunk/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreStatsCollectorIT.java
Modified: jackrabbit/oak/trunk/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/CommitBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/CommitBuilder.java?rev=1853131&r1=1853130&r2=1853131&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/CommitBuilder.java (original)
+++ jackrabbit/oak/trunk/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/CommitBuilder.java Thu Feb 7 13:28:30 2019
@@ -254,6 +254,16 @@ class CommitBuilder {
addedNodes, removedNodes, nodesWithBinaries, bundledNodes);
}
+ /**
+ * Returns the number of operations currently recorded by this commit
+ * builder.
+ *
+ * @return the number of operations.
+ */
+ int getNumOperations() {
+ return operations.size();
+ }
+
//-------------------------< internal >-------------------------------------
private UpdateOp getUpdateOperationForNode(String path) {
Modified: jackrabbit/oak/trunk/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/CommitDiff.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/CommitDiff.java?rev=1853131&r1=1853130&r2=1853131&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/CommitDiff.java (original)
+++ jackrabbit/oak/trunk/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/CommitDiff.java Thu Feb 7 13:28:30 2019
@@ -119,6 +119,17 @@ class CommitDiff implements NodeStateDif
new CommitDiff(store, commit, child, builder, blobs));
}
+ /**
+ * The number of changes recorded by this commit diff. A change is defined
+ * as a set of updates on a document. This also includes updates for a new
+ * document.
+ *
+ * @return the number of changes.
+ */
+ int getNumChanges() {
+ return commit.getNumOperations();
+ }
+
//----------------------------< internal >----------------------------------
private void performBundlingRelatedOperations() {
Modified: jackrabbit/oak/trunk/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBranch.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBranch.java?rev=1853131&r1=1853130&r2=1853131&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBranch.java (original)
+++ jackrabbit/oak/trunk/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBranch.java Thu Feb 7 13:28:30 2019
@@ -195,7 +195,8 @@ class DocumentNodeStoreBranch implements
try {
NodeState result = branchState.merge(checkNotNull(hook),
checkNotNull(info), exclusive);
- store.getStatsCollector().doneMerge(numRetries, System.currentTimeMillis() - time, suspendMillis, exclusive);
+ store.getStatsCollector().doneMerge(branchState.getMergedChanges(),
+ numRetries, System.currentTimeMillis() - time, suspendMillis, exclusive);
return result;
} catch (FailedWithConflictException e) {
ex = e;
@@ -265,6 +266,7 @@ class DocumentNodeStoreBranch implements
* @param toPersist the state with the changes on top of {@code base}.
* @param base the base state.
* @param info the commit info.
+ * @param stats the merge stats.
* @return the state with the persisted changes.
* @throws ConflictException if changes cannot be persisted because a
* conflict occurred. The exception may contain the revisions of
@@ -274,13 +276,15 @@ class DocumentNodeStoreBranch implements
*/
private DocumentNodeState persist(final @NotNull NodeState toPersist,
final @NotNull DocumentNodeState base,
- final @NotNull CommitInfo info)
+ final @NotNull CommitInfo info,
+ final @NotNull MergeStats stats)
throws ConflictException, DocumentStoreException {
return persist(new Changes() {
@Override
public void with(@NotNull CommitBuilder commitBuilder) {
- toPersist.compareAgainstBaseState(base,
- new CommitDiff(store, commitBuilder, store.getBlobSerializer()));
+ CommitDiff diff = new CommitDiff(store, commitBuilder, store.getBlobSerializer());
+ toPersist.compareAgainstBaseState(base, diff);
+ stats.numDocuments += diff.getNumChanges();
}
}, base, info);
}
@@ -364,6 +368,10 @@ class DocumentNodeStoreBranch implements
return base;
}
+ int getMergedChanges() {
+ return 0;
+ }
+
@NotNull
abstract NodeState getHead();
@@ -441,7 +449,7 @@ class DocumentNodeStoreBranch implements
NodeState merge(@NotNull CommitHook hook,
@NotNull CommitInfo info,
boolean exclusive) {
- branchState = new Merged(base);
+ branchState = new Merged(base, new MergeStats());
return base;
}
}
@@ -526,17 +534,18 @@ class DocumentNodeStoreBranch implements
NodeState toCommit = TimingHook.wrap(hook, (time, unit) -> stats.doneCommitHookProcessed(unit.toMicros(time)))
.processCommit(base, head, info);
try {
+ MergeStats ms = new MergeStats();
NodeState newHead;
if (this != branchState) {
// branch state is not in-memory anymore
Persisted p = branchState.persist();
RevisionVector branchRev = p.getHead().getRootRevision();
newHead = store.getRoot(store.merge(branchRev, info));
- stats.doneMergeBranch(p.numCommits);
+ stats.doneMergeBranch(p.numCommits, p.getMergedChanges());
} else {
- newHead = DocumentNodeStoreBranch.this.persist(toCommit, base, info);
+ newHead = DocumentNodeStoreBranch.this.persist(toCommit, base, info, ms);
}
- branchState = new Merged(base);
+ branchState = new Merged(base, ms);
success = true;
return newHead;
} catch (ConflictException e) {
@@ -582,6 +591,8 @@ class DocumentNodeStoreBranch implements
*/
private int numCommits;
+ private final MergeStats ms = new MergeStats();
+
@Override
public String toString() {
return "Persisted[" + base + ", " + head + ']';
@@ -649,8 +660,8 @@ class DocumentNodeStoreBranch implements
persistTransientHead(toCommit);
DocumentNodeState newRoot = store.getRoot(store.merge(head.getRootRevision(), info));
success = true;
- branchState = new Merged(base);
- stats.doneMergeBranch(numCommits);
+ branchState = new Merged(base, ms);
+ stats.doneMergeBranch(numCommits, branchState.getMergedChanges());
return newRoot;
} catch (CommitFailedException e) {
throw e;
@@ -671,7 +682,7 @@ class DocumentNodeStoreBranch implements
private void persistTransientHead(NodeState newHead)
throws DocumentStoreException {
try {
- head = DocumentNodeStoreBranch.this.persist(newHead, head, CommitInfo.EMPTY)
+ head = DocumentNodeStoreBranch.this.persist(newHead, head, CommitInfo.EMPTY, ms)
.asBranchRootState(DocumentNodeStoreBranch.this);
} catch (ConflictException e) {
throw DocumentStoreException.convert(e);
@@ -728,8 +739,13 @@ class DocumentNodeStoreBranch implements
* Transitions to: none.
*/
private class Merged extends BranchState {
- protected Merged(DocumentNodeState base) {
+
+ private final MergeStats stats;
+
+ protected Merged(@NotNull DocumentNodeState base,
+ @NotNull MergeStats stats) {
super(base);
+ this.stats = stats;
}
@Override
@@ -760,6 +776,11 @@ class DocumentNodeStoreBranch implements
boolean exclusive) {
throw new IllegalStateException("Branch has already been merged");
}
+
+ @Override
+ int getMergedChanges() {
+ return stats.numDocuments;
+ }
}
/**
Modified: jackrabbit/oak/trunk/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreStats.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreStats.java?rev=1853131&r1=1853130&r2=1853131&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreStats.java (original)
+++ jackrabbit/oak/trunk/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreStats.java Thu Feb 7 13:28:30 2019
@@ -51,6 +51,7 @@ public class DocumentNodeStoreStats impl
private static final String MERGE_SUCCESS_NUM_RETRY = "DOCUMENT_NS_MERGE_SUCCESS_RETRY";
static final String MERGE_SUCCESS_COUNT = "DOCUMENT_NS_MERGE_SUCCESS_COUNT";
private static final String MERGE_SUCCESS_TIME = "DOCUMENT_NS_MERGE_SUCCESS_TIME";
+ private static final String MERGE_SUCCESS_NORMALIZED_TIME = "DOCUMENT_NS_MERGE_SUCCESS_NORMALIZED_TIME";
private static final String MERGE_SUCCESS_SUSPENDED = "DOCUMENT_NS_MERGE_SUCCESS_SUSPENDED";
private static final String MERGE_SUCCESS_EXCLUSIVE = "DOCUMENT_NS_MERGE_SUCCESS_EXCLUSIVE";
static final String MERGE_FAILED_EXCLUSIVE = "DOCUMENT_NS_MERGE_FAILED_EXCLUSIVE";
@@ -59,6 +60,7 @@ public class DocumentNodeStoreStats impl
private static final String MERGE_LOCK_TIME = "DOCUMENT_NS_MERGE_LOCK_TIME";
private static final String MERGE_COMMIT_HOOK_TIME = "DOCUMENT_NS_MERGE_COMMIT_HOOK_TIME";
private static final String MERGE_CHANGES_APPLIED_TIME = "DOCUMENT_NS_MERGE_CHANGES_APPLIED_TIME";
+ private static final String MERGE_CHANGES_RATE = "DOCUMENT_NS_MERGE_CHANGES_RATE";
static final String BRANCH_COMMIT_COUNT = "DOCUMENT_NS_BRANCH_COMMIT_COUNT";
static final String MERGE_BRANCH_COMMIT_COUNT = "DOCUMENT_NS_MERGE_BRANCH_COMMIT_COUNT";
@@ -90,6 +92,7 @@ public class DocumentNodeStoreStats impl
private final HistogramStats mergeSuccessRetries;
private final MeterStats mergeSuccessRate;
private final TimerStats mergeSuccessTime;
+ private final TimerStats mergeSuccessNormalizedTime;
private final MeterStats mergeSuccessExclusive;
private final MeterStats mergeSuccessSuspended;
private final MeterStats mergeFailedExclusive;
@@ -98,6 +101,7 @@ public class DocumentNodeStoreStats impl
private final TimerStats mergeLockTime;
private final TimerStats mergeCommitHookTime;
private final TimerStats mergeChangesApplied;
+ private final MeterStats mergeChangesRate;
// branch stats
private final MeterStats branchCommitRate;
@@ -128,6 +132,7 @@ public class DocumentNodeStoreStats impl
mergeSuccessRetries = sp.getHistogram(MERGE_SUCCESS_NUM_RETRY, StatsOptions.METRICS_ONLY);
mergeSuccessRate = sp.getMeter(MERGE_SUCCESS_COUNT, StatsOptions.DEFAULT); //Enable time series
mergeSuccessTime = sp.getTimer(MERGE_SUCCESS_TIME, StatsOptions.METRICS_ONLY);
+ mergeSuccessNormalizedTime = sp.getTimer(MERGE_SUCCESS_NORMALIZED_TIME, StatsOptions.METRICS_ONLY);
mergeSuccessExclusive = sp.getMeter(MERGE_SUCCESS_EXCLUSIVE, StatsOptions.METRICS_ONLY);
mergeSuccessSuspended = sp.getMeter(MERGE_SUCCESS_SUSPENDED, StatsOptions.METRICS_ONLY);
mergeFailedExclusive = sp.getMeter(MERGE_FAILED_EXCLUSIVE, StatsOptions.DEFAULT); //Enable time series
@@ -136,6 +141,7 @@ public class DocumentNodeStoreStats impl
mergeLockTime = sp.getTimer(MERGE_LOCK_TIME, StatsOptions.METRICS_ONLY);
mergeCommitHookTime = sp.getTimer(MERGE_COMMIT_HOOK_TIME, StatsOptions.METRICS_ONLY);
mergeChangesApplied = sp.getTimer(MERGE_CHANGES_APPLIED_TIME, StatsOptions.METRICS_ONLY);
+ mergeChangesRate = sp.getMeter(MERGE_CHANGES_RATE, StatsOptions.METRICS_ONLY);
branchCommitRate = sp.getMeter(BRANCH_COMMIT_COUNT, StatsOptions.DEFAULT);
mergeBranchCommitRate = sp.getMeter(MERGE_BRANCH_COMMIT_COUNT, StatsOptions.DEFAULT);
@@ -183,16 +189,26 @@ public class DocumentNodeStoreStats impl
}
@Override
- public void doneMergeBranch(int numCommits) {
+ public void doneMergeBranch(int numCommits, int numChanges) {
mergeBranchCommitRate.mark(numCommits);
+ mergeChangesRate.mark(numChanges);
}
@Override
- public void doneMerge(int numRetries, long timeMillis, long suspendMillis, boolean exclusive) {
+ public void doneMerge(int numChanges,
+ int numRetries,
+ long timeMillis,
+ long suspendMillis,
+ boolean exclusive) {
mergeSuccessRate.mark();
mergeSuccessRetries.update(numRetries);
mergeSuccessTime.update(timeMillis, TimeUnit.MILLISECONDS);
+ if (numChanges > 0) {
+ mergeSuccessNormalizedTime.update(timeMillis / numChanges, TimeUnit.MILLISECONDS);
+ mergeChangesRate.mark(numChanges);
+ }
+
if (exclusive) {
mergeSuccessExclusive.mark();
}
Modified: jackrabbit/oak/trunk/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreStatsCollector.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreStatsCollector.java?rev=1853131&r1=1853130&r2=1853131&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreStatsCollector.java (original)
+++ jackrabbit/oak/trunk/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreStatsCollector.java Thu Feb 7 13:28:30 2019
@@ -51,18 +51,26 @@ public interface DocumentNodeStoreStatsC
* Report to the collector that a branch was merged.
*
* @param numCommits the number of branch commits merged.
+ * @param numChanges the number of changes merged.
*/
- void doneMergeBranch(int numCommits);
+ void doneMergeBranch(int numCommits, int numChanges);
/**
- * Reports to the collector that a merge was done.
+ * Reports to the collector that a merge was done. The number of changes
+ * reported with this method is the number of documents that were modified
+ * with the merge.
*
+ * @param numChanges the number of changes in this merge.
* @param numRetries the number of retries that were necessary.
* @param timeMillis the time in milliseconds it took to merge the changes.
* @param suspendMillis the time in milliseconds the merge was suspended.
* @param exclusive whether the merge was holding an exclusive lock.
*/
- void doneMerge(int numRetries, long timeMillis, long suspendMillis, boolean exclusive);
+ void doneMerge(int numChanges,
+ int numRetries,
+ long timeMillis,
+ long suspendMillis,
+ boolean exclusive);
/**
* Reports to the collector that a merge failed.
Added: jackrabbit/oak/trunk/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/MergeStats.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/MergeStats.java?rev=1853131&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/MergeStats.java (added)
+++ jackrabbit/oak/trunk/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/MergeStats.java Thu Feb 7 13:28:30 2019
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.plugins.document;
+
+/**
+ * Statistics about a merge.
+ */
+class MergeStats {
+
+ /**
+ * The number of documents in this merge. This is the number of documents
+ * that were created or updated by a merge.
+ */
+ int numDocuments;
+}
Propchange: jackrabbit/oak/trunk/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/MergeStats.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jackrabbit/oak/trunk/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreStatsCollectorIT.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreStatsCollectorIT.java?rev=1853131&r1=1853130&r2=1853131&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreStatsCollectorIT.java (original)
+++ jackrabbit/oak/trunk/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreStatsCollectorIT.java Thu Feb 7 13:28:30 2019
@@ -96,8 +96,10 @@ public class DocumentNodeStoreStatsColle
public void doneMerge() throws Exception {
NodeBuilder nb = nodeStore.getRoot().builder();
nb.child("a");
+ nb.child("b");
+ nb.child("c");
nodeStore.merge(nb, EmptyHook.INSTANCE, CommitInfo.EMPTY);
- verify(statsCollector).doneMerge(eq(0), anyLong(), eq(0L), eq(false));
+ verify(statsCollector).doneMerge(eq(3), eq(0), anyLong(), eq(0L), eq(false));
}
@Test
@@ -135,10 +137,12 @@ public class DocumentNodeStoreStatsColle
for (int i = 0; i < updateLimit; i++) {
nb.child("node-" + i).setProperty("p", "v");
}
+ nb.child("foo");
+ nb.child("bar");
merge(nodeStore, nb);
verify(statsCollector, times(2)).doneBranchCommit();
- verify(statsCollector).doneMergeBranch(2);
+ verify(statsCollector).doneMergeBranch(eq(2), eq(updateLimit + 2));
}
@Test