Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplified the WorkloadLoader implementation #294

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ import kotlin.math.roundToLong
* @param baseDir The directory containing the traces.
*/
public class ComputeWorkloadLoader(
private val baseDir: File,
private val pathToFile: File,
private val checkpointInterval: Long,
private val checkpointDuration: Long,
private val checkpointIntervalScaling: Double,
) {
) : WorkloadLoader() {
/**
* The logger for this instance.
*/
Expand All @@ -61,7 +61,7 @@ public class ComputeWorkloadLoader(
/**
* The cache of workloads.
*/
private val cache = ConcurrentHashMap<String, SoftReference<List<Task>>>()
private val cache = ConcurrentHashMap<File, SoftReference<List<Task>>>()

/**
* Read the fragments into memory.
Expand Down Expand Up @@ -157,21 +157,18 @@ public class ComputeWorkloadLoader(
}

/**
* Load the trace with the specified [name] and [format].
* Load the trace at the specified [pathToFile].
*/
public fun get(
name: String,
format: String,
): List<Task> {
override fun load(): List<Task> {
val ref =
cache.compute(name) { key, oldVal ->
cache.compute(pathToFile) { key, oldVal ->
val inst = oldVal?.get()
if (inst == null) {
val path = baseDir.resolve(key)
// val path = baseDir.resolve(key)

logger.info { "Loading trace $key at $path" }
logger.info { "Loading trace $key at $pathToFile" }

val trace = Trace.open(path, format)
val trace = Trace.open(pathToFile, "opendc-vm")
val fragments = parseFragments(trace)
val vms = parseMeta(trace, fragments)

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 AtLarge Research
* Copyright (c) 2025 AtLarge Research
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -20,28 +20,19 @@
* SOFTWARE.
*/

package org.opendc.compute.workload.internal

package org.opendc.compute.workload
import mu.KotlinLogging
import org.opendc.compute.workload.ComputeWorkload
import org.opendc.compute.workload.ComputeWorkloadLoader
import org.opendc.compute.workload.Task
import java.util.random.RandomGenerator

/**
* A [ComputeWorkload] that is sampled based on total load.
*/
internal class LoadSampledComputeWorkload(val source: ComputeWorkload, val fraction: Double) : ComputeWorkload {
/**
* The logging instance of this class.
*/
public abstract class WorkloadLoader {
private val logger = KotlinLogging.logger {}

override fun resolve(
loader: ComputeWorkloadLoader,
random: RandomGenerator,
): List<Task> {
val vms = source.resolve(loader, random) // fixme: Should be shuffled, otherwise the first fraction is always chosen
public abstract fun load(): List<Task>

/**
* Load the workload at sample tasks until a fraction of the workload is loaded
*/
public fun sampleByLoad(fraction: Double): List<Task> {
val vms = this.load()
val res = mutableListOf<Task>()

val totalLoad = vms.sumOf { it.totalLoad }
Expand Down

This file was deleted.

Loading
Loading