From 146c54274ba7726758ebc7b8034ae829def53c41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Tue, 3 Feb 2015 11:47:16 +0200 Subject: [PATCH] Repro #2, surface regression. --- gcrepro/gcrepro.go | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/gcrepro/gcrepro.go b/gcrepro/gcrepro.go index d6993b2..f36ff65 100644 --- a/gcrepro/gcrepro.go +++ b/gcrepro/gcrepro.go @@ -3,6 +3,7 @@ package main import ( "bytes" "fmt" + "io" "io/ioutil" "runtime" @@ -24,7 +25,6 @@ func random(length int) []byte { func main() { data := random(256 * 1024 * 1024) - run(data, 1) run(data, 1) run(data, 1) @@ -32,6 +32,45 @@ func main() { run(data, 8) run(data, 8) run(data, 8) + + fmt.Println() + fmt.Println() + + iter := 256 * 1024 + burst(iter, 1) + burst(iter, 1) + burst(iter, 1) + fmt.Println() + burst(iter, 8) + burst(iter, 8) + burst(iter, 8) +} + +func burst(iters int, threads int) { + runtime.GOMAXPROCS(threads) + + ir, iw := io.Pipe() + or, ow := io.Pipe() + + // Gather memory stats + start := new(runtime.MemStats) + runtime.ReadMemStats(start) + + // Run the operation + go bufioprop.Copy(ow, ir, 1024) + + input, output := []byte{0xff}, make([]byte, 1) + for i := 0; i < iters; i++ { + iw.Write(input) + or.Read(output) + } + ow.Close() + + // Gather memory stats and report + end := new(runtime.MemStats) + runtime.ReadMemStats(end) + + fmt.Printf("short bursts: gomaxprocs %d, allocs: %d, bytes: %d\n", runtime.GOMAXPROCS(0), end.Mallocs-start.Mallocs, end.TotalAlloc-start.TotalAlloc) } func run(data []byte, threads int) { @@ -48,5 +87,5 @@ func run(data []byte, threads int) { end := new(runtime.MemStats) runtime.ReadMemStats(end) - fmt.Printf("Gomaxprocs %d, allocs: %d, bytes: %d\n", runtime.GOMAXPROCS(0), end.Mallocs-start.Mallocs, end.TotalAlloc-start.TotalAlloc) + fmt.Printf("long run: gomaxprocs %d, allocs: %d, bytes: %d\n", runtime.GOMAXPROCS(0), end.Mallocs-start.Mallocs, end.TotalAlloc-start.TotalAlloc) }