From: Ronald Rojas <ronladred@gmail.com>
To: xen-devel <xen-devel@lists.xen.org>,
Ian Jackson <ian.jackson@eu.citrix.com>,
Wei Liu <wei.liu2@citrix.com>,
George Dunlap <george.dunlap@citrix.com>,
George Dunlap <dunlapg@umich.edu>
Subject: [PATCH RFC 15/59] controller: Move "running" code to a separate file
Date: Wed, 28 Dec 2016 20:14:08 -0500 [thread overview]
Message-ID: <1482974092-15891-15-git-send-email-ronladred@gmail.com> (raw)
In-Reply-To: <1482974092-15891-1-git-send-email-ronladred@gmail.com>
From: George Dunlap <george.dunlap@citrix.com>
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
---
Makefile | 2 +-
benchmark.go | 153 --------------------------------------------------
run.go | 178 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 179 insertions(+), 154 deletions(-)
create mode 100644 run.go
diff --git a/Makefile b/Makefile
index 7a33cfb..2e06f87 100644
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@ BINALL = $(BIN)
.PHONY: all
all: $(BIN)
-schedbench: main.go processworker.go xenworker.go benchmark.go
+schedbench: main.go processworker.go xenworker.go benchmark.go run.go
go build -o $@ $^
.PHONY: clean
diff --git a/benchmark.go b/benchmark.go
index 4354a47..2e03fe5 100644
--- a/benchmark.go
+++ b/benchmark.go
@@ -21,8 +21,6 @@ package main
import (
"fmt"
"os"
- "os/signal"
- "time"
"io/ioutil"
"encoding/json"
)
@@ -71,11 +69,6 @@ const (
SEC = MSEC * 1000
)
-type WorkerState struct {
- w Worker
- LastReport WorkerReport
-}
-
func Throughput(lt int, lm int, t int, m int) (tput float64) {
time := float64(t - lt) / SEC
mops := m - lm
@@ -84,80 +77,6 @@ func Throughput(lt int, lm int, t int, m int) (tput float64) {
return
}
-func Report(ws *WorkerState, r WorkerReport) {
- //fmt.Println(r)
-
- lr := ws.LastReport
-
- if (lr.Now > 0) {
- time := float64(r.Now - lr.Now) / SEC
- mops := r.Mops - lr.Mops
-
- tput := Throughput(lr.Now, lr.Mops, r.Now, r.Mops)
-
- fmt.Printf("%v Time: %2.3f Mops: %d Tput: %4.2f\n", r.Id, time, mops, tput);
- }
-
- ws.LastReport = r
-}
-
-type WorkerList map[WorkerId]*WorkerState
-
-func (ws *WorkerList) Start(report chan WorkerReport, done chan bool) (i int) {
- i = 0
- for j := range *ws {
- go (*ws)[j].w.Process(report, done)
- i++
- }
- return
-}
-
-func (ws *WorkerList) Stop() {
- for i := range *ws {
- (*ws)[i].w.Shutdown()
- }
-}
-
-const (
- WorkerProcess = iota
- WorkerXen = iota
-)
-
-func NewWorkerList(workers []WorkerSet, workerType int) (wl WorkerList, err error) {
- wl = WorkerList(make(map[WorkerId]*WorkerState))
-
- for wsi := range workers {
- for i := 0; i < workers[wsi].Count; i = i+1 {
- Id := WorkerId{Set:wsi,Id:i}
-
- ws := wl[Id]
-
- if ws != nil {
- panic("Duplicate worker for id!")
- }
-
- ws = &WorkerState{}
-
- switch workerType {
- case WorkerProcess:
- ws.w = &ProcessWorker{}
- case WorkerXen:
- ws.w = &XenWorker{}
- default:
- err = fmt.Errorf("Unknown type: %d", workerType)
- return
- }
-
- ws.w.SetId(Id)
-
- ws.w.Init(workers[wsi].Params)
-
- wl[Id] = ws
- }
- }
- return
-}
-
type BenchmarkRunData struct {
Raw []WorkerReport `json:",omitempty"`
Summary map[WorkerId]*WorkerSummary `json:",omitempty"`
@@ -171,59 +90,6 @@ type BenchmarkRun struct {
Results BenchmarkRunData
}
-func (run *BenchmarkRun) Run() (err error) {
- Workers, err := NewWorkerList(run.Workers, WorkerXen)
- if err != nil {
- fmt.Println("Error creating workers: %v", err)
- return
- }
-
- report := make(chan WorkerReport)
- done := make(chan bool)
- signals := make(chan os.Signal, 1)
-
- signal.Notify(signals, os.Interrupt)
-
- i := Workers.Start(report, done)
-
- // FIXME:
- // 1. Make a zero timeout mean "never"
- // 2. Make the signals / timeout thing a bit more rational; signal then timeout shouldn't hard kill
- timeout := time.After(time.Duration(run.RuntimeSeconds) * time.Second);
- stopped := false
- for i > 0 {
- select {
- case r := <-report:
- run.Results.Raw = append(run.Results.Raw, r)
- Report(Workers[r.Id], r)
- case <-done:
- i--;
- fmt.Println(i, "workers left");
- case <-timeout:
- if ! stopped {
- Workers.Stop()
- stopped = true
- run.Completed = true
- }
- case <-signals:
- if ! stopped {
- fmt.Println("SIGINT receieved, shutting down workers")
- Workers.Stop()
- stopped = true
- if run.RuntimeSeconds == 0 {
- run.Completed = true
- }
- err = fmt.Errorf("Interrupted")
- } else {
- err = fmt.Errorf("Interrupted")
- fmt.Println("SIGINT received after stop, exiting without cleaning up")
- return
- }
- }
- }
- return
-}
-
func (run *BenchmarkRun) checkSummary() (done bool, err error) {
if run.Results.Summary != nil {
done = true
@@ -328,25 +194,6 @@ type BenchmarkPlan struct {
Runs []BenchmarkRun
}
-func (plan *BenchmarkPlan) Run() (err error) {
- for i := range plan.Runs {
- if ! plan.Runs[i].Completed {
- fmt.Printf("Running test [%d] %s\n", i, plan.Runs[i].Label)
- err = plan.Runs[i].Run()
- if err != nil {
- return
- }
- }
- fmt.Printf("Test [%d] %s completed\n", i, plan.Runs[i].Label)
- err = plan.Save()
- if err != nil {
- fmt.Println("Error saving: ", err)
- return
- }
- }
- return
-}
-
func LoadBenchmark(filename string) (plan BenchmarkPlan, err error) {
plan.filename = filename
diff --git a/run.go b/run.go
new file mode 100644
index 0000000..7b5ef0a
--- /dev/null
+++ b/run.go
@@ -0,0 +1,178 @@
+/*
+ * Copyright (C) 2016 George W. Dunlap, Citrix Systems UK Ltd
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License only.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+package main
+
+import (
+ "fmt"
+ "os"
+ "os/signal"
+ "time"
+)
+
+type WorkerState struct {
+ w Worker
+ LastReport WorkerReport
+}
+
+func Report(ws *WorkerState, r WorkerReport) {
+ //fmt.Println(r)
+
+ lr := ws.LastReport
+
+ if (lr.Now > 0) {
+ time := float64(r.Now - lr.Now) / SEC
+ mops := r.Mops - lr.Mops
+
+ tput := Throughput(lr.Now, lr.Mops, r.Now, r.Mops)
+
+ fmt.Printf("%v Time: %2.3f Mops: %d Tput: %4.2f\n", r.Id, time, mops, tput);
+ }
+
+ ws.LastReport = r
+}
+
+type WorkerList map[WorkerId]*WorkerState
+
+func (ws *WorkerList) Start(report chan WorkerReport, done chan bool) (i int) {
+ i = 0
+ for j := range *ws {
+ go (*ws)[j].w.Process(report, done)
+ i++
+ }
+ return
+}
+
+func (ws *WorkerList) Stop() {
+ for i := range *ws {
+ (*ws)[i].w.Shutdown()
+ }
+}
+
+const (
+ WorkerProcess = iota
+ WorkerXen = iota
+)
+
+func NewWorkerList(WorkerSets []WorkerSet, workerType int) (wl WorkerList, err error) {
+ wl = WorkerList(make(map[WorkerId]*WorkerState))
+
+ for wsi := range WorkerSets {
+ for i := 0; i < WorkerSets[wsi].Count; i = i+1 {
+ Id := WorkerId{Set:wsi,Id:i}
+
+ ws := wl[Id]
+
+ if ws != nil {
+ panic("Duplicate worker for id!")
+ }
+
+ ws = &WorkerState{}
+
+ switch workerType {
+ case WorkerProcess:
+ ws.w = &ProcessWorker{}
+ case WorkerXen:
+ ws.w = &XenWorker{}
+ default:
+ err = fmt.Errorf("Unknown type: %d", workerType)
+ return
+ }
+
+ ws.w.SetId(Id)
+
+ ws.w.Init(WorkerSets[wsi].Params)
+
+ wl[Id] = ws
+ }
+ }
+ return
+}
+
+func (run *BenchmarkRun) Run() (err error) {
+ Workers, err := NewWorkerList(run.Workers, WorkerXen)
+ if err != nil {
+ fmt.Println("Error creating workers: %v", err)
+ return
+ }
+
+ report := make(chan WorkerReport)
+ done := make(chan bool)
+ signals := make(chan os.Signal, 1)
+
+ signal.Notify(signals, os.Interrupt)
+
+ i := Workers.Start(report, done)
+
+ // FIXME:
+ // 1. Make a zero timeout mean "never"
+ // 2. Make the signals / timeout thing a bit more rational; signal then timeout shouldn't hard kill
+ timeout := time.After(time.Duration(run.RuntimeSeconds) * time.Second);
+ stopped := false
+ for i > 0 {
+ select {
+ case r := <-report:
+ run.Results.Raw = append(run.Results.Raw, r)
+ Report(Workers[r.Id], r)
+ case <-done:
+ i--;
+ fmt.Println(i, "workers left");
+ case <-timeout:
+ if ! stopped {
+ Workers.Stop()
+ stopped = true
+ run.Completed = true
+ }
+ case <-signals:
+ if ! stopped {
+ fmt.Println("SIGINT receieved, shutting down workers")
+ Workers.Stop()
+ stopped = true
+ if run.RuntimeSeconds == 0 {
+ run.Completed = true
+ }
+ err = fmt.Errorf("Interrupted")
+ } else {
+ err = fmt.Errorf("Interrupted")
+ fmt.Println("SIGINT received after stop, exiting without cleaning up")
+ return
+ }
+ }
+ }
+ return
+}
+
+func (plan *BenchmarkPlan) Run() (err error) {
+ for i := range plan.Runs {
+ if ! plan.Runs[i].Completed {
+ fmt.Printf("Running test [%d] %s\n", i, plan.Runs[i].Label)
+ err = plan.Runs[i].Run()
+ if err != nil {
+ return
+ }
+ }
+ fmt.Printf("Test [%d] %s completed\n", i, plan.Runs[i].Label)
+ err = plan.Save()
+ if err != nil {
+ fmt.Println("Error saving: ", err)
+ return
+ }
+ }
+ return
+}
+
--
2.7.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-12-29 1:14 UTC|newest]
Thread overview: 67+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-29 1:13 [PATCH RFC 01/59] Initial controller framework Ronald Rojas
2016-12-29 1:13 ` [PATCH RFC 02/59] controller: Revamp communication structure Ronald Rojas
2016-12-29 1:13 ` [PATCH RFC 03/59] controller: Initial attempt to generalize process / vm creation Ronald Rojas
2016-12-29 1:13 ` [PATCH RFC 04/59] Controller: Move process worker into its own file Ronald Rojas
2016-12-29 1:13 ` [PATCH RFC 05/59] controller: Add WorkerParams argument to Init in Worker interface Ronald Rojas
2016-12-29 1:13 ` [PATCH RFC 06/59] Reorganize to enable "Dist" directory Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 07/59] controller: Introduce basic Xen functionality Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 08/59] controller: Exit after second SIGINT Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 09/59] controller: Refactor creation and stopping of workers into WorkerList methods Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 10/59] controller: First cut at BenchmarkParams Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 11/59] Refactor to move towards benchmark "plans" and data analysis Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 12/59] Basic 'report' functionality Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 13/59] Add GPL headers / COPYING file (v2 only) Ronald Rojas
2016-12-29 10:51 ` Wei Liu
2016-12-29 1:14 ` [PATCH RFC 14/59] benchmark: Store data in terms of worker sets and worker ids Ronald Rojas
2016-12-29 1:14 ` Ronald Rojas [this message]
2016-12-29 1:14 ` [PATCH RFC 16/59] controller: Rename an element in BenchmarkRun to be more accurate Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 17/59] controller: Collect and display statistics on WorkerSets Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 18/59] controller: Add cpupool global config Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 19/59] Add basic libxl framework, get domain cpu_time Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 20/59] xenworker: Use libxl_domain_unpause rather than forking xl Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 21/59] Report utilization statistics Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 22/59] Use tsc for time rather than rumpkernel clock_gettime() Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 23/59] run: Don't collect results reported after command to stop guests is issued Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 24/59] report: Lots of changes Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 25/59] main: Change default workload to something a bit more extreme Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 26/59] Use kops rather than mops Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 27/59] report: Allow report verbosity to be specified Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 28/59] controller: Handle worker early death Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 29/59] report: Add basic html report Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 30/59] htmlreport: Include utilization scatterplots Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 31/59] Make a binary that can run reports on a system without libxl Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 32/59] controller: Allow specification of an input file Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 33/59] controller: Add verbosity argument and update README with new instructions Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 34/59] controller: Make a useful config file Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 35/59] libxl: Add ListCpupool Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 36/59] controller: Make 'dummy' at the level of 'run' rather than xenworker Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 37/59] libxl.go: Provide a single global context by default Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 38/59] controller: Allow multiple schedulers in the same benchmark file Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 39/59] libxl.go: Put common link flags in libxl.go Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 40/59] controller: Add / update GPL text Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 41/59] libxl.go: Link statically rather than dynamically Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 42/59] plan: Allow "templating" from other runs Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 43/59] libxl: Add bitmap support Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 44/59] libxl: Implement CpupoolCreate Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 45/59] libxl: Implement Destroy, Add/Remove operations Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 46/59] libxl: Reorganize bitmapGotoC Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 47/59] libxl: Reorganize code Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 48/59] libxl: Add Ctx.CheckOpen Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 49/59] libxl: Implement libxl_cpupool_info and Scheduler.FromString() Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 50/59] libxl: Fix Bitmap.Max(), make Test() / Clear() more robust Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 51/59] controller: Make and/or modify cpupools when possible Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 52/59] libxl: Implement Bitmap.String() Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 53/59] controller: Add WorkerConfig.SoftAffinity Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 54/59] controller/run: Add RunConfig.NumaDisable Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 55/59] plan: Make the matrix generation more programmatic Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 56/59] controller/plan: Add NumaDisable to SimpleMatrix Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 57/59] tools/blktap2: remove unused inclusion of sys/sysctl.l Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 58/59] remove irrelevant files from old repository Ronald Rojas
2016-12-29 1:14 ` [PATCH RFC 59/59] tools/xenlight: Create interface for xenlight info Ronald Rojas
2016-12-29 10:34 ` George Dunlap
2016-12-29 10:52 ` Wei Liu
2016-12-29 13:49 ` Ronald Rojas
2016-12-29 13:45 ` George Dunlap
2016-12-29 20:20 ` George Dunlap
2017-01-03 17:45 ` Ronald Rojas
2017-01-04 16:44 ` George Dunlap
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1482974092-15891-15-git-send-email-ronladred@gmail.com \
--to=ronladred@gmail.com \
--cc=dunlapg@umich.edu \
--cc=george.dunlap@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).