Skip to content

Commit

Permalink
factor out check.go; update some traces
Browse files Browse the repository at this point in the history
  • Loading branch information
Sajmani committed Oct 20, 2017
1 parent 70b6cd3 commit fd785b6
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 36 deletions.
2 changes: 2 additions & 0 deletions coffee/README.md
Expand Up @@ -5,6 +5,8 @@ go-torch -b ./sync-$mode.pprof -f ./torch-$mode.svg
end

# https://github.com/aclements/perflock
# Prevents multiple benchmarks from running at once,
# and keeps CPU from running too hot and so triggering CPU throttling.

# Disable hyperthreading on 12-core Linux machine
sudo su root
Expand Down
29 changes: 0 additions & 29 deletions coffee/main.go
Expand Up @@ -16,7 +16,6 @@ import (
"os"
"runtime"
"runtime/trace"
"sort"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -576,31 +575,3 @@ func modeParam(mode, prefix string, n *int) bool {
}
return true
}

func checkVariance() {
checkFunc("useCPU", func() {
useCPU(*duration)
})
var mu sync.Mutex
checkFunc("useCPULocked", func() {
mu.Lock()
useCPU(*duration)
mu.Unlock()
})
}

func checkFunc(kind string, f func()) {
log.Printf("Running %s(%s) 100 times, change with --dur", kind, *duration)
var ds []time.Duration
for i := 0; i < 100; i++ {
start := time.Now()
f()
elapsed := time.Since(start)
ds = append(ds, elapsed)
}
log.Println(ds)
sort.Slice(ds, func(i, j int) bool {
return ds[i] < ds[j]
})
log.Println(ds)
}
21 changes: 14 additions & 7 deletions coffee/perf.go
Expand Up @@ -29,15 +29,25 @@ func (arg perfArg) String() string {

const maxSamples = 10000

func utilization() func() (walltime, exectime time.Duration) {
var ru1, ru2 syscall.Rusage
syscall.Getrusage(syscall.RUSAGE_SELF, &ru1)
start := time.Now()
return func() (walltime, exectime time.Duration) {
syscall.Getrusage(syscall.RUSAGE_SELF, &ru2)
return time.Since(start),
time.Duration(syscall.TimevalToNsec(ru2.Utime) -
syscall.TimevalToNsec(ru1.Utime))
}
}

// perfTest runs f repeatedly until arg.dur elapses, then returns a
// perfResult containing up to maxSamples uniformly selected
// durations. If arg.interval > 0, it specifies the rate at which to
// attempt requests and increment res.drops on failure.
func perfTest(arg perfArg, f func()) (res perfResult) {
// Pipeline: request generator -> workers -> sampler
var ru1, ru2 syscall.Rusage
syscall.Getrusage(syscall.RUSAGE_SELF, &ru1)
start := time.Now()
timings := utilization()

// Generate requests until arg.dur elapses
stop := time.NewTimer(arg.dur)
Expand Down Expand Up @@ -109,10 +119,7 @@ func perfTest(arg perfArg, f func()) (res perfResult) {
res.samples[j] = elapsed
}
}
syscall.Getrusage(syscall.RUSAGE_SELF, &ru2)
res.exectime = time.Duration(syscall.TimevalToNsec(ru2.Utime) -
syscall.TimevalToNsec(ru1.Utime))
res.walltime = time.Since(start)
res.walltime, res.exectime = timings()
return
}

Expand Down
Binary file modified coffee/trace-finelocking.out
Binary file not shown.
Binary file modified coffee/trace-linearpipe-0.out
Binary file not shown.
Binary file modified coffee/trace-linearpipe-1.out
Binary file not shown.
Binary file modified coffee/trace-multipipe-2.out
Binary file not shown.

0 comments on commit fd785b6

Please sign in to comment.