From e097aeb16d77c260126b65c7f13330076d800d52 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Thu, 16 Apr 2020 01:35:33 +0200 Subject: perf: Convert traces to Parquet format --- .../com/atlarge/opendc/compute/core/image/VmImage.kt | 2 +- .../opendc/compute/virt/driver/SimpleVirtDriver.kt | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'opendc/opendc-compute/src') diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/image/VmImage.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/image/VmImage.kt index b37f05a7..e3227540 100644 --- a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/image/VmImage.kt +++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/image/VmImage.kt @@ -23,7 +23,7 @@ class VmImage( val clock = simulationContext.clock val job = coroutineContext[Job]!! - for (fragments in flopsHistory.chunked(1024)) { + for (fragments in flopsHistory.chunked(128)) { for (fragment in fragments) { job.ensureActive() diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/SimpleVirtDriver.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/SimpleVirtDriver.kt index 2c25c0fa..8a32bc43 100644 --- a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/SimpleVirtDriver.kt +++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/SimpleVirtDriver.kt @@ -57,6 +57,9 @@ import kotlinx.coroutines.selects.select import java.util.Objects import java.util.TreeSet import java.util.UUID +import kotlin.coroutines.Continuation +import kotlin.coroutines.resume +import kotlin.coroutines.suspendCoroutine import kotlin.math.ceil import kotlin.math.max import kotlin.math.min @@ -325,7 +328,7 @@ class SimpleVirtDriver( requests.removeAll(vmRequests) // Return vCPU `run` call: the requested burst was completed or deadline was exceeded - vm.chan.send(Unit) + vm.chan?.resume(Unit) } } @@ -371,7 +374,7 @@ class SimpleVirtDriver( val vm: VmServerContext, val vcpu: ProcessingUnit, var burst: Long, - val limit: Double + var limit: Double ) { /** * The usage that was actually granted. @@ -395,7 +398,7 @@ class SimpleVirtDriver( private var finalized: Boolean = false lateinit var burst: LongArray var deadline: Long = 0L - val chan: Channel = Channel(Channel.CONFLATED) + var chan: Continuation? = null private var initialized: Boolean = false internal val job: Job = launch { @@ -452,6 +455,7 @@ class SimpleVirtDriver( require(burst.size == limit.size) { "Array dimensions do not match" } this.deadline = deadline this.burst = burst + val requests = cpus.asSequence() .take(burst.size) .mapIndexed { i, cpu -> @@ -466,13 +470,13 @@ class SimpleVirtDriver( // Wait until the burst has been run or the coroutine is cancelled try { - schedulingQueue.send(SchedulerCommand.Schedule(this, requests)) - chan.receive() + schedulingQueue.offer(SchedulerCommand.Schedule(this, requests)) + suspendCoroutine { chan = it } } catch (e: CancellationException) { // Deschedule the VM requests.forEach { it.isCancelled = true } - schedulingQueue.send(SchedulerCommand.Interrupt) - chan.receive() + schedulingQueue.offer(SchedulerCommand.Interrupt) + suspendCoroutine { chan = it } e.assertFailure() } } -- cgit v1.2.3