Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Piché2019-05-22 15:56:34 -0400
committerMatthew Khouzam2019-06-12 19:21:37 -0400
commit5911d7971d47e5c746e0f046b6951fc26208bf00 (patch)
treec7d61eb70890382e5dd47a48ad36f1efe4c7c702
parentb395ad7f97b51e0b0d20b080d0a4464cc952bad4 (diff)
downloadorg.eclipse.tracecompass-5911d7971d47e5c746e0f046b6951fc26208bf00.tar.gz
org.eclipse.tracecompass-5911d7971d47e5c746e0f046b6951fc26208bf00.tar.xz
org.eclipse.tracecompass-5911d7971d47e5c746e0f046b6951fc26208bf00.zip
StateSystem: Use HTVarInt encoding for start
HTInterval start can be computed with linked HTNode's start, making it easier to encode this attribute using HTVarInt encoding. However, since HTInterval's computeSizeOnDisk() now depends on HTNode's start time, HTInterval's sizeOnDisk can no longer be final. Reduced HT_IO cache size to optimal size according to benchmarks. Change-Id: I3db49feed00b60cb4aecdfbf974a304c44af4566 Signed-off-by: David Piché <david.piche@ericsson.com> Reviewed-on: https://git.eclipse.org/r/143220 Reviewed-by: Simon Delisle <simon.delisle@ericsson.com> Tested-by: Simon Delisle <simon.delisle@ericsson.com> Tested-by: CI Bot Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com> Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
-rw-r--r--statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/backend/historytree/HTIntervalStringReadWriteTest.java4
-rw-r--r--statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/backend/historytree/HistoryTreeTest.java77
-rw-r--r--statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HTInterval.java55
-rw-r--r--statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HTNode.java11
-rw-r--r--statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HT_IO.java2
-rw-r--r--statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/classic/CoreNode.java33
-rw-r--r--statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/classic/HistoryTreeClassic.java5
7 files changed, 124 insertions, 63 deletions
diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/backend/historytree/HTIntervalStringReadWriteTest.java b/statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/backend/historytree/HTIntervalStringReadWriteTest.java
index ef85e8edde..0a28df37a2 100644
--- a/statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/backend/historytree/HTIntervalStringReadWriteTest.java
+++ b/statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/backend/historytree/HTIntervalStringReadWriteTest.java
@@ -156,7 +156,7 @@ public class HTIntervalStringReadWriteTest {
bb.order(ByteOrder.LITTLE_ENDIAN);
bb.clear();
- interval.writeInterval(bb);
+ interval.writeInterval(bb, 1);
bb.flip();
int written = fc.write(bb);
assertEquals(sizeOnDisk, written);
@@ -174,7 +174,7 @@ public class HTIntervalStringReadWriteTest {
int read = fc.read(bb);
assertEquals(sizeOnDisk, read);
bb.flip();
- readInterval = HTInterval.readFrom(bb);
+ readInterval = HTInterval.readFrom(bb, 1);
}
assertEquals(interval, readInterval);
diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/backend/historytree/HistoryTreeTest.java b/statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/backend/historytree/HistoryTreeTest.java
index 13b759c353..71b4d94290 100644
--- a/statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/backend/historytree/HistoryTreeTest.java
+++ b/statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/backend/historytree/HistoryTreeTest.java
@@ -111,7 +111,20 @@ public class HistoryTreeTest {
return setupSmallTree(3);
}
- private static long fillValues(IHistoryTree ht, TmfStateValue value, int nbValues, long start) {
+ /**
+ * Adds intervals a certain number of times
+ *
+ * @param ht
+ * The history tree to add the intervals to
+ * @param value
+ * The state value for every interval to have
+ * @param nbValues
+ * The number of intervals to add to the node
+ * @param start
+ * Start time of the first interval to add
+ * @return The end time of the last interval added
+ */
+ private static long addValues(IHistoryTree ht, TmfStateValue value, int nbValues, long start) {
for (int i = 0; i < nbValues; i++) {
ht.insertInterval(new HTInterval(start + i, start + i + 1, 1, value));
}
@@ -119,6 +132,33 @@ public class HistoryTreeTest {
}
/**
+ * Fills intervals in node until it is full
+ *
+ * @param ht
+ * The history tree to add the intervals to
+ * @param value
+ * The state value for every interval to have
+ * @param node
+ * The node
+ * @param start
+ * Start time of the first interval to add
+ * @return The end time of the last interval added
+ */
+ private static long fillValues(IHistoryTree ht, TmfStateValue value, HTNode node, long start) {
+ int i = 0;
+ while(true) {
+ HTInterval interval = new HTInterval(start + i, start + i + 1, 1, value);
+ if (interval.getSizeOnDisk(node.getNodeStart()) > node.getNodeFreeSpace()) {
+ break;
+ }
+ ht.insertInterval(interval);
+ i++;
+ }
+ return start + i;
+
+ }
+
+ /**
* Insert intervals in the tree to fill the current leaf node to capacity,
* without exceeding it.
*
@@ -136,10 +176,7 @@ public class HistoryTreeTest {
/* Fill the following leaf node */
HTNode node = ht.getLatestLeaf();
- int intervalSize = STRING_INTERVAL.getSizeOnDisk();
- int nodeFreeSpace = node.getNodeFreeSpace();
- int nbIntervals = nodeFreeSpace / intervalSize;
- long ret = fillValues(ht, STRING_VALUE, nbIntervals, leafNodeStart);
+ long ret = fillValues(ht, STRING_VALUE, node, leafNodeStart);
/* Make sure we haven't changed the depth or node count */
assertEquals(prevCount, ht.getNodeCount());
@@ -165,28 +202,28 @@ public class HistoryTreeTest {
int nodeFreeSpace = node.getNodeFreeSpace();
int intervalSize = NULL_INTERVAL.getSizeOnDisk();
int nbIntervals = nodeFreeSpace / 10 / intervalSize;
- long start = fillValues(ht, TmfStateValue.nullValue(), nbIntervals, 1);
+ long start = addValues(ht, TmfStateValue.nullValue(), nbIntervals, 1);
assertEquals(nodeFreeSpace - nbIntervals * intervalSize , node.getNodeFreeSpace());
/* Add integer intervals up to ~20% */
nodeFreeSpace = node.getNodeFreeSpace();
intervalSize = INT_INTERVAL.getSizeOnDisk();
nbIntervals = nodeFreeSpace / 10 / intervalSize;
- start = fillValues(ht, INT_VALUE, nbIntervals, start);
+ start = addValues(ht, INT_VALUE, nbIntervals, start);
assertEquals(nodeFreeSpace - nbIntervals * intervalSize , node.getNodeFreeSpace());
/* Add long intervals up to ~30% */
nodeFreeSpace = node.getNodeFreeSpace();
intervalSize = LONG_INTERVAL.getSizeOnDisk();
nbIntervals = nodeFreeSpace / 10 / intervalSize;
- start = fillValues(ht, LONG_VALUE, nbIntervals, start);
+ start = addValues(ht, LONG_VALUE, nbIntervals, start);
assertEquals(nodeFreeSpace - nbIntervals * intervalSize , node.getNodeFreeSpace());
/* Add string intervals up to ~40% */
nodeFreeSpace = node.getNodeFreeSpace();
intervalSize = STRING_INTERVAL.getSizeOnDisk();
nbIntervals = nodeFreeSpace / 10 / intervalSize;
- start = fillValues(ht, STRING_VALUE, nbIntervals, start);
+ start = addValues(ht, STRING_VALUE, nbIntervals, start);
assertEquals(nodeFreeSpace - nbIntervals * intervalSize , node.getNodeFreeSpace());
}
@@ -201,38 +238,32 @@ public class HistoryTreeTest {
/* Fill a first node */
HTNode node = ht.getLatestLeaf();
- int nodeFreeSpace = node.getNodeFreeSpace();
- int nbIntervals = nodeFreeSpace / (STRING_INTERVAL.getSizeOnDisk());
- long start = fillValues(ht, STRING_VALUE, nbIntervals, 1);
+ long start = fillValues(ht, STRING_VALUE, node, 1);
/* Add intervals that should add a sibling to the node */
assertEquals(1, ht.getNodeCount());
assertEquals(1, ht.getDepth());
- start = fillValues(ht, STRING_VALUE, 1, start);
+ start = addValues(ht, STRING_VALUE, 1, start);
assertEquals(3, ht.getNodeCount());
assertEquals(2, ht.getDepth());
/* Fill the latest leaf node (2nd child) */
node = ht.getLatestLeaf();
- nodeFreeSpace = node.getNodeFreeSpace();
- nbIntervals = nodeFreeSpace / (STRING_INTERVAL.getSizeOnDisk());
- start = fillValues(ht, STRING_VALUE, nbIntervals, start);
+ start = fillValues(ht, STRING_VALUE, node, start);
/*
* Add an interval that should add another sibling to the previous nodes
*/
- start = fillValues(ht, STRING_VALUE, 1, start);
+ start = addValues(ht, STRING_VALUE, 1, start);
assertEquals(4, ht.getNodeCount());
assertEquals(2, ht.getDepth());
/* Fill the latest leaf node (3rd and last child) */
node = ht.getLatestLeaf();
- nodeFreeSpace = node.getNodeFreeSpace();
- nbIntervals = nodeFreeSpace / (STRING_INTERVAL.getSizeOnDisk());
- start = fillValues(ht, STRING_VALUE, nbIntervals, start);
+ start = fillValues(ht, STRING_VALUE, node, start);
/* The new node created here should generate a new branch */
- start = fillValues(ht, STRING_VALUE, 1, start);
+ start = addValues(ht, STRING_VALUE, 1, start);
assertEquals(7, ht.getNodeCount());
assertEquals(3, ht.getDepth());
}
@@ -275,7 +306,7 @@ public class HistoryTreeTest {
assertEquals(-1, branch.get(0).getParentSequenceNumber());
/* Create a new branch */
- start = fillValues(ht, STRING_VALUE, 1, start);
+ start = addValues(ht, STRING_VALUE, 1, start);
start = fillNextLeafNode(ht, start);
assertEquals(3, ht.getNodeCount());
assertEquals(2, ht.getDepth());
@@ -294,7 +325,7 @@ public class HistoryTreeTest {
assertEquals( 1, branch.get(1).getParentSequenceNumber());
/* Create a third branch */
- start = fillValues(ht, STRING_VALUE, 1, start);
+ start = addValues(ht, STRING_VALUE, 1, start);
start = fillNextLeafNode(ht, start);
assertEquals(6, ht.getNodeCount());
assertEquals(3, ht.getDepth());
diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HTInterval.java b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HTInterval.java
index 98c65472c2..82a7a31d8c 100644
--- a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HTInterval.java
+++ b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HTInterval.java
@@ -57,7 +57,7 @@ public final class HTInterval implements ITmfStateInterval {
private final @Nullable Object fStateValue;
/** Number of bytes used by this interval when it is written to disk */
- private final int fSizeOnDisk;
+ private int fSizeOnDisk;
/**
* Standard constructor
@@ -84,19 +84,26 @@ public final class HTInterval implements ITmfStateInterval {
fDuration = intervalEnd - intervalStart;
fAttribute = attribute;
fStateValue = (value instanceof TmfStateValue) ? ((ITmfStateValue) value).unboxValue() : value;
- fSizeOnDisk = computeSizeOnDisk(fStateValue);
+ fSizeOnDisk = computeSizeOnDisk(fStateValue, 0);
}
/**
* Compute how much space (in bytes) an interval will take in its serialized
- * form on disk. This is dependent on its state value.
+ * form on disk. This is dependent on its state value and the start time of
+ * the node it is linked to.
+ *
+ * @param stateValue
+ * The state value
+ * @param nodeStart
+ * The start time of the node the interval is linked to
+ * @return The computed size on disk (with HTVarInt encoding)
*/
- private int computeSizeOnDisk(Object stateValue) {
+ private int computeSizeOnDisk(Object stateValue, long nodeStart) {
/*
- * Minimum size is 1x long (start), a value determined by HTVarInt (duration), 1x int (attribute) and 1x
+ * Minimum size is a 2x bytes (start), 2x bytes (duration), 1x int (attribute) and 1x
* byte (value type).
*/
- int minSize = Long.BYTES + HTVarInt.getEncodedLengthLong(fDuration) + Integer.BYTES + Byte.BYTES;
+ int minSize = HTVarInt.getEncodedLengthLong(fStart - nodeStart) + HTVarInt.getEncodedLengthLong(fDuration) + Integer.BYTES + Byte.BYTES;
if (stateValue == null) {
return minSize;
@@ -155,8 +162,8 @@ public final class HTInterval implements ITmfStateInterval {
* The interval is just a start, end, attribute and value, this is the
* layout of the HTInterval on disk
* <ul>
- * <li>start (8 bytes)</li>
- * <li>end (8 bytes)</li>
+ * <li>start (2-9 bytes)</li>
+ * <li>end (2-9 bytes)</li>
* <li>attribute (4 bytes)</li>
* <li>sv type (1 byte)</li>
* <li>sv ( 0 bytes for null, 4 for int , 8 for long and double, and the
@@ -165,16 +172,18 @@ public final class HTInterval implements ITmfStateInterval {
*
* @param buffer
* The ByteBuffer from which to read the information
+ * @param nodeStart
+ * The start time of the node this interval is linked to
* @return The interval object
* @throws IOException
* If there was an error reading from the buffer
*/
- public static final HTInterval readFrom(ByteBuffer buffer) throws IOException {
+ public static final HTInterval readFrom(ByteBuffer buffer, long nodeStart) throws IOException {
Object value;
int posStart = buffer.position();
/* Read the Data Section entry */
- long intervalStart = buffer.getLong();
+ long intervalStart = HTVarInt.readLong(buffer) + nodeStart;
long intervalEnd = HTVarInt.readLong(buffer) + intervalStart;
int attribute = buffer.getInt();
@@ -242,8 +251,8 @@ public final class HTInterval implements ITmfStateInterval {
* The interval is just a start, end, attribute and value, this is the
* layout of the HTInterval on disk
* <ul>
- * <li>start (8 bytes)</li>
- * <li>end (8 bytes)</li>
+ * <li>start (2-9 bytes)</li>
+ * <li>end (2-9 bytes)</li>
* <li>attribute (4 bytes)</li>
* <li>sv type (1 byte)</li>
* <li>sv ( 0 bytes for null, 4 for int , 8 for long and double, and the
@@ -253,8 +262,8 @@ public final class HTInterval implements ITmfStateInterval {
* @param buffer
* The already-allocated ByteBuffer corresponding to a SHT Node
*/
- public void writeInterval(ByteBuffer buffer) {
- buffer.putLong(fStart);
+ public void writeInterval(ByteBuffer buffer, long nodeStart) {
+ HTVarInt.writeLong(buffer, fStart - nodeStart);
HTVarInt.writeLong(buffer, fDuration);
buffer.putInt(fAttribute);
@@ -334,6 +343,24 @@ public final class HTInterval implements ITmfStateInterval {
return fSizeOnDisk;
}
+ /**
+ * Computes serialized size of this interval with linked node start time
+ *
+ * @param nodeStart
+ * The start time of the node the interval is linked to
+ * @return The size of the interval on disk using the HTVarInt encoding
+ */
+ public int getSizeOnDisk(long nodeStart) {
+ return computeSizeOnDisk(fStateValue, nodeStart);
+ }
+
+ /**
+ * @param sizeOnDisk the sizeOnDisk to set
+ */
+ public void setSizeOnDisk(int sizeOnDisk) {
+ fSizeOnDisk = sizeOnDisk;
+ }
+
@Override
public boolean equals(Object obj) {
if (this == obj) {
diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HTNode.java b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HTNode.java
index 9568802c5b..d7f8107995 100644
--- a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HTNode.java
+++ b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HTNode.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2016 Ericsson, École Polytechnique de Montréal, and others
+ * Copyright (c) 2010, 2019 Ericsson, École Polytechnique de Montréal, and others
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
@@ -236,7 +236,7 @@ public abstract class HTNode {
* should only have the intervals left
*/
for (int i = 0; i < intervalCount; i++) {
- HTInterval interval = HTInterval.readFrom(buffer);
+ HTInterval interval = HTInterval.readFrom(buffer, start);
newNode.fIntervals.add(interval);
newNode.fSizeOfIntervalSection += interval.getSizeOnDisk();
}
@@ -287,7 +287,7 @@ public abstract class HTNode {
/* Back to us, we write the intervals */
for (HTInterval interval : fIntervals) {
- interval.writeInterval(buffer);
+ interval.writeInterval(buffer, fNodeStart);
}
if (blockSize - buffer.position() != getNodeFreeSpace()) {
throw new IllegalStateException("Wrong free space: Actual: " + (blockSize - buffer.position()) + ", Expected: " + getNodeFreeSpace()); //$NON-NLS-1$ //$NON-NLS-2$
@@ -398,7 +398,8 @@ public abstract class HTNode {
/*
* Just in case, should be checked before even calling this function
*/
- if (newInterval.getSizeOnDisk() > getNodeFreeSpace()) {
+ int newSizeOnDisk = newInterval.getSizeOnDisk(fNodeStart);
+ if (newSizeOnDisk > getNodeFreeSpace()) {
// Could be an IO exception, but that would change the API
throw new IllegalStateException("Insufficient disk space."); //$NON-NLS-1$
}
@@ -417,7 +418,7 @@ public abstract class HTNode {
*/
index = -index - 1;
}
-
+ newInterval.setSizeOnDisk(newSizeOnDisk);
fIntervals.add(index, newInterval);
fNodeEnd = Long.max(fNodeEnd, newInterval.getEndTime());
fMinQuark = Integer.min(fMinQuark, newInterval.getAttribute());
diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HT_IO.java b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HT_IO.java
index 7a29daf8ae..c166723d44 100644
--- a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HT_IO.java
+++ b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HT_IO.java
@@ -87,7 +87,7 @@ public class HT_IO {
}
}
- private static final int CACHE_SIZE = 256;
+ private static final int CACHE_SIZE = 200;
private static final CacheLoader<CacheKey, HTNode> NODE_LOADER = new CacheLoader<CacheKey, HTNode>() {
@Override
diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/classic/CoreNode.java b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/classic/CoreNode.java
index 03a07c8fb4..abde5a0850 100644
--- a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/classic/CoreNode.java
+++ b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/classic/CoreNode.java
@@ -26,6 +26,7 @@ import org.eclipse.tracecompass.internal.provisional.datastore.core.condition.In
import org.eclipse.tracecompass.internal.provisional.datastore.core.condition.TimeRangeCondition;
import org.eclipse.tracecompass.internal.statesystem.core.backend.historytree.HTConfig;
import org.eclipse.tracecompass.internal.statesystem.core.backend.historytree.HTNode;
+import org.eclipse.tracecompass.internal.statesystem.core.backend.historytree.HTVarInt;
import org.eclipse.tracecompass.internal.statesystem.core.backend.historytree.ParentNode;
import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException;
@@ -103,12 +104,12 @@ public final class CoreNode extends ParentNode {
fChildStart = new long[size];
for (int i = 0; i < size; i++) {
- fChildStart[i] = buffer.getLong();
+ fChildStart[i] = HTVarInt.readLong(buffer);
}
fChildEnd = new long[size];
for (int i = 0; i < size; i++) {
- fChildEnd[i] = buffer.getLong();
+ fChildEnd[i] = HTVarInt.readLong(buffer);
}
fChildMin = new int[size];
@@ -133,12 +134,12 @@ public final class CoreNode extends ParentNode {
/* Write the "children's start times" array */
for (long start : fChildStart) {
- buffer.putLong(start);
+ HTVarInt.writeLong(buffer, start);
}
/* Write the "children's end times" array */
for (long end : fChildEnd) {
- buffer.putLong(end);
+ HTVarInt.writeLong(buffer, end);
}
/* Write the "children's min quark" array */
@@ -320,18 +321,18 @@ public final class CoreNode extends ParentNode {
@Override
protected int getSpecificHeaderSize() {
int maxChildren = getConfig().getMaxChildren();
- return Integer.BYTES /* 1x int (nbChildren) */
-
- /* MAX_NB * int ('children' table) */
- + Integer.BYTES * maxChildren
-
- /* MAX_NB * Timevalue ('childStart' table) */
- + Long.BYTES * maxChildren
- /* MAX_NB * Timevalue ('childEnd' table) */
- + Long.BYTES * maxChildren
-
- /* MAX_NB * quark ('childMin' and 'childMax' table) */
- + 2 * Integer.BYTES * maxChildren;
+ int ret = 0;
+ /* 1x int (nbChildren) */
+ ret += Integer.BYTES;
+ for (int i = 0; i < getConfig().getMaxChildren(); i++) {
+ ret += HTVarInt.getEncodedLengthLong(fChildStart[i]);
+ ret += HTVarInt.getEncodedLengthLong(fChildEnd[i]);
+ }
+ /* MAX_NB * int ('children' table) */
+ ret += Integer.BYTES * maxChildren;
+ /* MAX_NB * quark ('childMin' and 'childMax' table) */
+ ret += 2 * Integer.BYTES * maxChildren;
+ return ret;
}
@Override
diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/classic/HistoryTreeClassic.java b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/classic/HistoryTreeClassic.java
index d6dd75564f..c6345b0fcf 100644
--- a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/classic/HistoryTreeClassic.java
+++ b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/classic/HistoryTreeClassic.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2016 Ericsson, École Polytechnique de Montréal, and others
+ * Copyright (c) 2010, 2019 Ericsson, École Polytechnique de Montréal, and others
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
@@ -466,7 +466,8 @@ public class HistoryTreeClassic implements IHistoryTree {
HTNode targetNode = fLatestBranch.get(indexOfNode);
/* Verify if there is enough room in this node to store this interval */
- if (interval.getSizeOnDisk() > targetNode.getNodeFreeSpace()) {
+ int newSizeOnDisk = interval.getSizeOnDisk(targetNode.getNodeStart());
+ if (newSizeOnDisk > targetNode.getNodeFreeSpace()) {
/* Nope, not enough room. Insert in a new sibling instead. */
addSiblingNode(indexOfNode, interval.getStartTime());
tryInsertAtNode(interval, fLatestBranch.size() - 1);

Back to the top