From: Geneviève Bastien Date: Tue, 21 Feb 2017 19:35:45 +0000 (-0500) Subject: datastore: Keep a snapshot of the latest branch X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=2abec5dd6b714f1b693a632b534f9faf95ebe237;p=deliverable%2Ftracecompass.git datastore: Keep a snapshot of the latest branch This avoids making immutable copies of the same branch over and over. Also use the latest branch directly in the node insertion instead of the getter. This change alone removes all performance impact of the datastore when building. Change-Id: If85ae9bded364cfd6f1243416d025df6307cf909 Signed-off-by: Geneviève Bastien Reviewed-on: https://git.eclipse.org/r/91755 Reviewed-by: Hudson CI Reviewed-by: Loic Prieur-Drevon --- diff --git a/statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/internal/provisional/datastore/core/historytree/AbstractHistoryTree.java b/statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/internal/provisional/datastore/core/historytree/AbstractHistoryTree.java index 85df36becf..b61152059e 100644 --- a/statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/internal/provisional/datastore/core/historytree/AbstractHistoryTree.java +++ b/statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/internal/provisional/datastore/core/historytree/AbstractHistoryTree.java @@ -118,6 +118,8 @@ public abstract class AbstractHistoryTree fLatestBranchSnapshot = null; + /** * Create a new State History from scratch, specifying all configuration * parameters. @@ -364,8 +366,15 @@ public abstract class AbstractHistoryTree getLatestBranch() { - return ImmutableList.copyOf(fLatestBranch); + final List getLatestBranch() { + List latestBranchSnapshot = fLatestBranchSnapshot; + if (latestBranchSnapshot == null) { + synchronized (fLatestBranch) { + latestBranchSnapshot = ImmutableList.copyOf(fLatestBranch); + fLatestBranchSnapshot = latestBranchSnapshot; + } + } + return latestBranchSnapshot; } /** @@ -634,7 +643,7 @@ public abstract class AbstractHistoryTree= fLatestBranch.size()) { /*