StateSystem: Add HTVarInt encoding for PotentialLeakSegment
Uses HTVarInt encoding to encode PotentialLeakSegment's duration instead
of the end time.
[Fixed] reduce the size of potential leak segment storage.
Change-Id: I52d070de84b15b8437a88ae4e165f06448f7946f
Signed-off-by: David Piché <dpiche.veg@gmail.com>
Reviewed-on: https://git.eclipse.org/r/c/tracecompass/org.eclipse.tracecompass/+/163120
Tested-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Tested-by: Trace Compass Bot <tracecompass-bot@eclipse.org>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
diff --git a/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/analysis/memory/PotentialLeakSegment.java b/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/analysis/memory/PotentialLeakSegment.java
index 5721985..a2fc4e9 100644
--- a/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/analysis/memory/PotentialLeakSegment.java
+++ b/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/analysis/memory/PotentialLeakSegment.java
@@ -12,6 +12,7 @@
package org.eclipse.tracecompass.internal.lttng2.ust.core.analysis.memory;
import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.tracecompass.datastore.core.encoding.HTVarInt;
import org.eclipse.tracecompass.datastore.core.interval.IHTIntervalReader;
import org.eclipse.tracecompass.datastore.core.serialization.ISafeByteBufferWriter;
import org.eclipse.tracecompass.segmentstore.core.BasicSegment;
@@ -31,7 +32,8 @@
* The factory to read this segment from a buffer
*/
public static final @NonNull IHTIntervalReader<@NonNull ISegment> MEMORY_SEGMENT_READ_FACTORY = buffer -> {
- return new PotentialLeakSegment(buffer.getLong(), buffer.getLong(), buffer.getLong());
+ long start = buffer.getLong();
+ return new PotentialLeakSegment(start, start + HTVarInt.readLong(buffer), buffer.getLong());
};
/**
@@ -58,13 +60,13 @@
@Override
public int getSizeOnDisk() {
- return Long.BYTES * 3;
+ return Long.BYTES * 2 + HTVarInt.getEncodedLengthLong(getEnd() - getStart());
}
@Override
public void writeSegment(@NonNull ISafeByteBufferWriter buffer) {
buffer.putLong(getStart());
- buffer.putLong(getEnd());
+ HTVarInt.writeLong(buffer, getEnd() - getStart());
buffer.putLong(fTid);
}