From 2abec5dd6b714f1b693a632b534f9faf95ebe237 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Genevi=C3=A8ve=20Bastien?= Date: Tue, 21 Feb 2017 14:35:45 -0500 Subject: [PATCH] datastore: Keep a snapshot of the latest branch MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- .../core/historytree/AbstractHistoryTree.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) 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()) { /* -- 2.34.1