Skip to content

Commit

Permalink
Extracting specification generator to a separate method
Browse files Browse the repository at this point in the history
Signed-off-by: Lazar Cvetković <[email protected]>
  • Loading branch information
cvetkovic committed Nov 25, 2024
1 parent cb757da commit 9587658
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
11 changes: 7 additions & 4 deletions cmd/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func parseTraceGranularity(cfg *config.LoaderConfiguration) common.TraceGranular
return common.MinuteGranularity
}

func runTraceMode(cfg *config.LoaderConfiguration, readIATFromFile bool, justGenerateIAT bool) {
func runTraceMode(cfg *config.LoaderConfiguration, readIATFromFile bool, writeIATsToFile bool) {
durationToParse := determineDurationToParse(cfg.ExperimentDuration, cfg.WarmupDuration)
yamlPath := parseYAMLSpecification(cfg)

Expand Down Expand Up @@ -208,10 +208,12 @@ func runTraceMode(cfg *config.LoaderConfiguration, readIATFromFile bool, justGen

log.Infof("Using %s as a service YAML specification file.\n", experimentDriver.Configuration.YAMLPath)

experimentDriver.RunExperiment(true, justGenerateIAT, readIATFromFile)
experimentDriver.GenerateSpecification()
experimentDriver.DumpSpecification(writeIATsToFile, readIATFromFile)
experimentDriver.RunExperiment()
}

func runRPSMode(cfg *config.LoaderConfiguration, readIATFromFile bool, justGenerateIAT bool) {
func runRPSMode(cfg *config.LoaderConfiguration, readIATFromFile bool, writeIATsToFile bool) {
rpsTarget := cfg.RpsTarget
coldStartPercentage := cfg.RpsColdStartRatioPercentage

Expand All @@ -230,5 +232,6 @@ func runRPSMode(cfg *config.LoaderConfiguration, readIATFromFile bool, justGener
Functions: generator.CreateRPSFunctions(cfg, warmFunction, warmStartCount, coldFunctions, coldStartCount),
})

experimentDriver.RunExperiment(false, justGenerateIAT, false)
experimentDriver.DumpSpecification(writeIATsToFile, readIATFromFile)
experimentDriver.RunExperiment()
}
14 changes: 6 additions & 8 deletions pkg/driver/trace_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ func (d *Driver) internalRun() {
log.Infof("Failure rate: \t\t\t%.2f", float64(statFailed)*100.0/float64(statSuccess+statFailed))
}

func (d *Driver) generateSpecs() {
func (d *Driver) GenerateSpecification() {
log.Info("Generating IAT and runtime specifications for all the functions")

for i, function := range d.Configuration.Functions {
Expand Down Expand Up @@ -547,13 +547,9 @@ func (d *Driver) outputIATsToFile() {
}
}

func (d *Driver) RunExperiment(generateSpecs bool, writeIATsToFile bool, readIATsFromFile bool) {
if generateSpecs && readIATsFromFile {
log.Fatal("Invalid loader configuration. Cannot be forced to generate IATs and read the from file in the same experiment.")
}

if generateSpecs {
d.generateSpecs()
func (d *Driver) DumpSpecification(writeIATsToFile bool, readIATsFromFile bool) {
if writeIATsToFile && readIATsFromFile {
log.Fatal("Invalid loader configuration. No point to read and write IATs within the same run.")
}

if writeIATsToFile {
Expand All @@ -576,7 +572,9 @@ func (d *Driver) RunExperiment(generateSpecs bool, writeIATsToFile bool, readIAT
d.Configuration.Functions[i].Specification = &spec
}
}
}

func (d *Driver) RunExperiment() {
if d.Configuration.WithWarmup() {
trace.DoStaticTraceProfiling(d.Configuration.Functions)
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/driver/trace_driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,8 @@ func TestDriverCompletely(t *testing.T) {
driver.Configuration.TraceGranularity = common.SecondGranularity
}

driver.RunExperiment(true, false, false)
driver.GenerateSpecification()
driver.RunExperiment()

f, err := os.Open(driver.outputFilename("duration"))
if err != nil {
Expand Down

0 comments on commit 9587658

Please sign in to comment.