Skip to content

Commit

Permalink
Sim trace update (#249)
Browse files Browse the repository at this point in the history
* Started on reimplementing the SimTrace implementation

* updated trace format. Fragments now do not have a deadline, but a duration. The Fragments are executed in order.
  • Loading branch information
DanteNiewenhuis authored Sep 5, 2024
1 parent fa6e850 commit 3f05c61
Show file tree
Hide file tree
Showing 25 changed files with 193 additions and 169 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ internal class SimHostTest {

assertAll(
{ assertEquals(347908, cpuStats.activeTime, "Active time does not match") },
{ assertEquals(2652090, cpuStats.idleTime, "Idle time does not match") },
{ assertEquals(2652092, cpuStats.idleTime, "Idle time does not match") },
{ assertEquals(1, cpuStats.stealTime, "Steal time does not match") },
{ assertEquals(1499999, timeSource.millis()) },
{ assertEquals(1500000, timeSource.millis()) },
)
}

Expand Down Expand Up @@ -238,9 +238,9 @@ internal class SimHostTest {

assertAll(
{ assertEquals(629252, cpuStats.activeTime, "Active time does not match") },
{ assertEquals(2370746, cpuStats.idleTime, "Idle time does not match") },
{ assertEquals(2370748, cpuStats.idleTime, "Idle time does not match") },
{ assertEquals(18754, cpuStats.stealTime, "Steal time does not match") },
{ assertEquals(1499999, timeSource.millis()) },
{ assertEquals(1500000, timeSource.millis()) },
)
}

Expand Down Expand Up @@ -318,11 +318,11 @@ internal class SimHostTest {
val guestSysStats = host.getSystemStats(server)

assertAll(
{ assertEquals(2062044, cpuStats.idleTime, "Idle time does not match") },
{ assertEquals(2062046, cpuStats.idleTime, "Idle time does not match") },
{ assertEquals(347954, cpuStats.activeTime, "Active time does not match") },
{ assertEquals(1204999, sysStats.uptime.toMillis(), "Uptime does not match") },
{ assertEquals(1205000, 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") },
{ assertEquals(1205000, guestSysStats.uptime.toMillis(), "Guest uptime does not match") },
{ assertEquals(300000, guestSysStats.downtime.toMillis(), "Guest downtime does not match") },
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,15 @@ import org.opendc.trace.conv.TABLE_RESOURCES
import org.opendc.trace.conv.TABLE_RESOURCE_STATES
import org.opendc.trace.conv.resourceCpuCapacity
import org.opendc.trace.conv.resourceCpuCount
import org.opendc.trace.conv.resourceDuration
import org.opendc.trace.conv.resourceID
import org.opendc.trace.conv.resourceMemCapacity
import org.opendc.trace.conv.resourceStartTime
import org.opendc.trace.conv.resourceStateCpuUsage
import org.opendc.trace.conv.resourceStateDuration
import org.opendc.trace.conv.resourceStateTimestamp
import org.opendc.trace.conv.resourceStopTime
import org.opendc.trace.conv.resourceSubmissionTime
import java.io.File
import java.lang.ref.SoftReference
import java.time.Duration
import java.time.Instant
import java.util.UUID
import java.util.concurrent.ConcurrentHashMap
import kotlin.math.roundToLong
Expand Down Expand Up @@ -72,7 +70,6 @@ public class ComputeWorkloadLoader(private val baseDir: File) {
val reader = checkNotNull(trace.getTable(TABLE_RESOURCE_STATES)).newReader()

val idCol = reader.resolve(resourceID)
val timestampCol = reader.resolve(resourceStateTimestamp)
val durationCol = reader.resolve(resourceStateDuration)
val coresCol = reader.resolve(resourceCpuCount)
val usageCol = reader.resolve(resourceStateCpuUsage)
Expand All @@ -82,13 +79,12 @@ public class ComputeWorkloadLoader(private val baseDir: File) {
return try {
while (reader.nextRow()) {
val id = reader.getString(idCol)!!
val time = reader.getInstant(timestampCol)!!
val durationMs = reader.getDuration(durationCol)!!
val cores = reader.getInt(coresCol)
val cpuUsage = reader.getDouble(usageCol)

val builder = fragments.computeIfAbsent(id) { Builder() }
builder.add(time, durationMs, cpuUsage, cores)
builder.add(durationMs, cpuUsage, cores)
}

fragments
Expand All @@ -108,8 +104,8 @@ public class ComputeWorkloadLoader(private val baseDir: File) {
val reader = checkNotNull(trace.getTable(TABLE_RESOURCES)).newReader()

val idCol = reader.resolve(resourceID)
val startTimeCol = reader.resolve(resourceStartTime)
val stopTimeCol = reader.resolve(resourceStopTime)
val submissionTimeCol = reader.resolve(resourceSubmissionTime)
val durationCol = reader.resolve(resourceDuration)
val cpuCountCol = reader.resolve(resourceCpuCount)
val cpuCapacityCol = reader.resolve(resourceCpuCapacity)
val memCol = reader.resolve(resourceMemCapacity)
Expand All @@ -124,8 +120,8 @@ public class ComputeWorkloadLoader(private val baseDir: File) {
continue
}

val submissionTime = reader.getInstant(startTimeCol)!!
val endTime = reader.getInstant(stopTimeCol)!!
val submissionTime = reader.getInstant(submissionTimeCol)!!
val duration = reader.getLong(durationCol)
val cpuCount = reader.getInt(cpuCountCol)
val cpuCapacity = reader.getDouble(cpuCapacityCol)
val memCapacity = reader.getDouble(memCol) / 1000.0 // Convert from KB to MB
Expand All @@ -143,7 +139,7 @@ public class ComputeWorkloadLoader(private val baseDir: File) {
memCapacity.roundToLong(),
totalLoad,
submissionTime,
endTime,
duration,
builder.build(),
interferenceModel.getProfile(id),
),
Expand Down Expand Up @@ -240,11 +236,6 @@ public class ComputeWorkloadLoader(private val baseDir: File) {
*/
private val builder = SimTrace.builder()

/**
* The deadline of the previous fragment.
*/
private var previousDeadline = Long.MIN_VALUE

/**
* Add a fragment to the trace.
*
Expand All @@ -254,21 +245,13 @@ public class ComputeWorkloadLoader(private val baseDir: File) {
* @param cores Number of cores used.
*/
fun add(
deadline: Instant,
duration: Duration,
usage: Double,
cores: Int,
) {
val startTimeMs = (deadline - duration).toEpochMilli()
totalLoad += (usage * duration.toMillis()) / 1000.0 // avg MHz * duration = MFLOPs

if ((startTimeMs != previousDeadline) && (previousDeadline != Long.MIN_VALUE)) {
// There is a gap between the previous and current fragment; fill the gap
builder.add(startTimeMs, 0.0, cores)
}

builder.add(deadline.toEpochMilli(), usage, cores)
previousDeadline = deadline.toEpochMilli()
builder.add(duration.toMillis(), usage, cores)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ public data class VirtualMachine(
val memCapacity: Long,
val totalLoad: Double,
val startTime: Instant,
val stopTime: Instant,
val duration: Long,
val trace: SimTrace,
val interferenceProfile: VmInterferenceProfile?,
) {
val duration: Long = stopTime.toEpochMilli() - startTime.toEpochMilli()
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ class ScenarioIntegrationTest {
{ assertEquals(0, monitor.tasksActive, "All VMs should finish after a run") },
{ assertEquals(0, monitor.attemptsFailure, "No VM should be unscheduled") },
{ assertEquals(0, monitor.tasksPending, "No VM should not be in the queue") },
{ assertEquals(43795971955, monitor.idleTime) { "Incorrect idle time" } },
{ assertEquals(2864995687, monitor.activeTime) { "Incorrect active time" } },
{ assertEquals(148, monitor.stealTime) { "Incorrect steal time" } },
{ assertEquals(43101695530, monitor.idleTime) { "Incorrect idle time" } },
{ assertEquals(3489503997, monitor.activeTime) { "Incorrect active time" } },
{ assertEquals(142, monitor.stealTime) { "Incorrect steal time" } },
{ assertEquals(0, monitor.lostTime) { "Incorrect lost time" } },
{ assertEquals(3.3017632018246904E7, monitor.powerDraw, 1E4) { "Incorrect power draw" } },
{ assertEquals(9.905193072307465E9, monitor.energyUsage, 1E4) { "Incorrect energy usage" } },
{ assertEquals(3.3388920269258898E7, monitor.powerDraw, 1E4) { "Incorrect power draw" } },
{ assertEquals(1.0016142948422823E10, monitor.energyUsage, 1E4) { "Incorrect energy usage" } },
)
}

Expand Down Expand Up @@ -162,12 +162,12 @@ class ScenarioIntegrationTest {

// Note that these values have been verified beforehand
assertAll(
{ assertEquals(1374591279, monitor.idleTime) { "Idle time incorrect" } },
{ assertEquals(1217660672, monitor.activeTime) { "Active time incorrect" } },
{ assertEquals(1373412033, monitor.idleTime) { "Idle time incorrect" } },
{ assertEquals(1217675912, monitor.activeTime) { "Active time incorrect" } },
{ assertEquals(19, monitor.stealTime) { "Steal time incorrect" } },
{ assertEquals(0, monitor.lostTime) { "Lost time incorrect" } },
{ assertEquals(2539987.394500494, monitor.powerDraw, 1E4) { "Incorrect power draw" } },
{ assertEquals(7.619825262052509E8, monitor.energyUsage, 1E4) { "Incorrect energy usage" } },
{ assertEquals(7.617527900379665E8, monitor.energyUsage, 1E4) { "Incorrect energy usage" } },
)
}

Expand Down
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 3f05c61

Please sign in to comment.