From d28002a3c151d198298574312f32f1cb43f3a660 Mon Sep 17 00:00:00 2001 From: Dante Niewenhuis Date: Fri, 16 Feb 2024 15:11:05 +0100 Subject: Metric update (#205) * Updated metrics to consistently be ms * Updated metrics to consistently be ms * Updated metric documentation on the site * Updated some tests to work with the updated metrics --- .../main/kotlin/org/opendc/compute/simulator/SimHost.kt | 8 ++++---- .../kotlin/org/opendc/compute/simulator/SimHostTest.kt | 16 ++++++++-------- .../telemetry/export/parquet/ParquetHostDataWriter.kt | 4 ++-- .../telemetry/export/parquet/ParquetServerDataWriter.kt | 6 +++--- .../telemetry/export/parquet/ParquetServiceDataWriter.kt | 3 +-- .../opendc/compute/telemetry/table/HostTableReader.kt | 8 ++++---- 6 files changed, 22 insertions(+), 23 deletions(-) (limited to 'opendc-compute') diff --git a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimHost.kt b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimHost.kt index 461a33f0..16ded689 100644 --- a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimHost.kt +++ b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimHost.kt @@ -248,10 +248,10 @@ public class SimHost( counters.sync() return HostCpuStats( - counters.cpuActiveTime / 1000L, - counters.cpuIdleTime / 1000L, - counters.cpuStealTime / 1000L, - counters.cpuLostTime / 1000L, + counters.cpuActiveTime, + counters.cpuIdleTime, + counters.cpuStealTime, + counters.cpuLostTime, hypervisor.cpuCapacity, hypervisor.cpuDemand, hypervisor.cpuUsage, diff --git a/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimHostTest.kt b/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimHostTest.kt index 0f6618ad..e9bac8db 100644 --- a/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimHostTest.kt +++ b/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimHostTest.kt @@ -128,9 +128,9 @@ internal class SimHostTest { val cpuStats = host.getCpuStats() assertAll( - { assertEquals(639, cpuStats.activeTime, "Active time does not match") }, - { assertEquals(2360, cpuStats.idleTime, "Idle time does not match") }, - { assertEquals(56, cpuStats.stealTime, "Steal time does not match") }, + { assertEquals(639564, cpuStats.activeTime, "Active time does not match") }, + { assertEquals(2360433, cpuStats.idleTime, "Idle time does not match") }, + { assertEquals(56251, cpuStats.stealTime, "Steal time does not match") }, { assertEquals(1499999, timeSource.millis()) } ) } @@ -215,9 +215,9 @@ internal class SimHostTest { val cpuStats = host.getCpuStats() assertAll( - { assertEquals(658, cpuStats.activeTime, "Active time does not match") }, - { assertEquals(2341, cpuStats.idleTime, "Idle time does not match") }, - { assertEquals(637, cpuStats.stealTime, "Steal time does not match") }, + { assertEquals(658502, cpuStats.activeTime, "Active time does not match") }, + { assertEquals(2341496, cpuStats.idleTime, "Idle time does not match") }, + { assertEquals(637504, cpuStats.stealTime, "Steal time does not match") }, { assertEquals(1499999, timeSource.millis()) } ) } @@ -287,8 +287,8 @@ internal class SimHostTest { val guestSysStats = host.getSystemStats(server) assertAll( - { assertEquals(1770, cpuStats.idleTime, "Idle time does not match") }, - { assertEquals(639, cpuStats.activeTime, "Active time does not match") }, + { assertEquals(1770344, cpuStats.idleTime, "Idle time does not match") }, + { assertEquals(639653, cpuStats.activeTime, "Active time does not match") }, { assertEquals(1204999, sysStats.uptime.toMillis(), "Uptime does not match") }, { assertEquals(300000, sysStats.downtime.toMillis(), "Downtime does not match") }, { assertEquals(1204999, guestSysStats.uptime.toMillis(), "Guest uptime does not match") }, diff --git a/opendc-compute/opendc-compute-telemetry/src/main/kotlin/org/opendc/compute/telemetry/export/parquet/ParquetHostDataWriter.kt b/opendc-compute/opendc-compute-telemetry/src/main/kotlin/org/opendc/compute/telemetry/export/parquet/ParquetHostDataWriter.kt index 8871570d..a6799ef8 100644 --- a/opendc-compute/opendc-compute-telemetry/src/main/kotlin/org/opendc/compute/telemetry/export/parquet/ParquetHostDataWriter.kt +++ b/opendc-compute/opendc-compute-telemetry/src/main/kotlin/org/opendc/compute/telemetry/export/parquet/ParquetHostDataWriter.kt @@ -170,7 +170,7 @@ public class ParquetHostDataWriter(path: File, bufferSize: Int) : .addFields( Types .required(PrimitiveType.PrimitiveTypeName.INT64) - .`as`(LogicalTypeAnnotation.timestampType(true, LogicalTypeAnnotation.TimeUnit.MILLIS)) +// .`as`(LogicalTypeAnnotation.timestampType(true, LogicalTypeAnnotation.TimeUnit.MILLIS)) .named("timestamp"), Types .required(PrimitiveType.PrimitiveTypeName.BINARY) @@ -232,7 +232,7 @@ public class ParquetHostDataWriter(path: File, bufferSize: Int) : .named("downtime"), Types .optional(PrimitiveType.PrimitiveTypeName.INT64) - .`as`(LogicalTypeAnnotation.timestampType(true, LogicalTypeAnnotation.TimeUnit.MILLIS)) +// .`as`(LogicalTypeAnnotation.timestampType(true, LogicalTypeAnnotation.TimeUnit.MILLIS)) .named("boot_time") ) .named("host") diff --git a/opendc-compute/opendc-compute-telemetry/src/main/kotlin/org/opendc/compute/telemetry/export/parquet/ParquetServerDataWriter.kt b/opendc-compute/opendc-compute-telemetry/src/main/kotlin/org/opendc/compute/telemetry/export/parquet/ParquetServerDataWriter.kt index 6645028e..e8a28016 100644 --- a/opendc-compute/opendc-compute-telemetry/src/main/kotlin/org/opendc/compute/telemetry/export/parquet/ParquetServerDataWriter.kt +++ b/opendc-compute/opendc-compute-telemetry/src/main/kotlin/org/opendc/compute/telemetry/export/parquet/ParquetServerDataWriter.kt @@ -152,7 +152,7 @@ public class ParquetServerDataWriter(path: File, bufferSize: Int) : .addFields( Types .required(PrimitiveType.PrimitiveTypeName.INT64) - .`as`(LogicalTypeAnnotation.timestampType(true, LogicalTypeAnnotation.TimeUnit.MILLIS)) +// .`as`(LogicalTypeAnnotation.timestampType(true, LogicalTypeAnnotation.TimeUnit.MILLIS)) .named("timestamp"), Types .required(PrimitiveType.PrimitiveTypeName.BINARY) @@ -195,11 +195,11 @@ public class ParquetServerDataWriter(path: File, bufferSize: Int) : .named("downtime"), Types .optional(PrimitiveType.PrimitiveTypeName.INT64) - .`as`(LogicalTypeAnnotation.timestampType(true, LogicalTypeAnnotation.TimeUnit.MILLIS)) +// .`as`(LogicalTypeAnnotation.timestampType(true, LogicalTypeAnnotation.TimeUnit.MILLIS)) .named("provision_time"), Types .optional(PrimitiveType.PrimitiveTypeName.INT64) - .`as`(LogicalTypeAnnotation.timestampType(true, LogicalTypeAnnotation.TimeUnit.MILLIS)) +// .`as`(LogicalTypeAnnotation.timestampType(true, LogicalTypeAnnotation.TimeUnit.MILLIS)) .named("boot_time") ) diff --git a/opendc-compute/opendc-compute-telemetry/src/main/kotlin/org/opendc/compute/telemetry/export/parquet/ParquetServiceDataWriter.kt b/opendc-compute/opendc-compute-telemetry/src/main/kotlin/org/opendc/compute/telemetry/export/parquet/ParquetServiceDataWriter.kt index 6908a018..a487203e 100644 --- a/opendc-compute/opendc-compute-telemetry/src/main/kotlin/org/opendc/compute/telemetry/export/parquet/ParquetServiceDataWriter.kt +++ b/opendc-compute/opendc-compute-telemetry/src/main/kotlin/org/opendc/compute/telemetry/export/parquet/ParquetServiceDataWriter.kt @@ -25,7 +25,6 @@ package org.opendc.compute.telemetry.export.parquet import org.apache.hadoop.conf.Configuration import org.apache.parquet.hadoop.api.WriteSupport import org.apache.parquet.io.api.RecordConsumer -import org.apache.parquet.schema.LogicalTypeAnnotation import org.apache.parquet.schema.MessageType import org.apache.parquet.schema.PrimitiveType import org.apache.parquet.schema.Types @@ -102,7 +101,7 @@ public class ParquetServiceDataWriter(path: File, bufferSize: Int) : .addFields( Types .required(PrimitiveType.PrimitiveTypeName.INT64) - .`as`(LogicalTypeAnnotation.timestampType(true, LogicalTypeAnnotation.TimeUnit.MILLIS)) +// .`as`(LogicalTypeAnnotation.timestampType(true, LogicalTypeAnnotation.TimeUnit.MILLIS)) .named("timestamp"), Types .required(PrimitiveType.PrimitiveTypeName.INT32) diff --git a/opendc-compute/opendc-compute-telemetry/src/main/kotlin/org/opendc/compute/telemetry/table/HostTableReader.kt b/opendc-compute/opendc-compute-telemetry/src/main/kotlin/org/opendc/compute/telemetry/table/HostTableReader.kt index 9af0a0c0..bfe2f281 100644 --- a/opendc-compute/opendc-compute-telemetry/src/main/kotlin/org/opendc/compute/telemetry/table/HostTableReader.kt +++ b/opendc-compute/opendc-compute-telemetry/src/main/kotlin/org/opendc/compute/telemetry/table/HostTableReader.kt @@ -84,22 +84,22 @@ public interface HostTableReader { public val cpuUtilization: Double /** - * The duration (in seconds) that a CPU was active in the host. + * The duration (in ms) that a CPU was active in the host. */ public val cpuActiveTime: Long /** - * The duration (in seconds) that a CPU was idle in the host. + * The duration (in ms) that a CPU was idle in the host. */ public val cpuIdleTime: Long /** - * The duration (in seconds) that a vCPU wanted to run, but no capacity was available. + * The duration (in ms) that a vCPU wanted to run, but no capacity was available. */ public val cpuStealTime: Long /** - * The duration (in seconds) of CPU time that was lost due to interference. + * The duration (in ms) of CPU time that was lost due to interference. */ public val cpuLostTime: Long -- cgit v1.2.3