Uros Bizjak <ubiz...@gmail.com> writes: >> This patch changes the Go library to multiplex goroutines onto operating >> system threads. Previously, each new goroutine ran in a separate >> thread. That is inefficient for programs with lots of goroutines. This >> patch changes the library such that it runs a certain numbers of >> threads, and lets each thread switch between goroutines. This is how >> the master Go library works, and this patch brings in code from the >> master Go library, adjusted for use by gccgo. > > For some reason I get this failure on alphaev68-pc-linux-gnu: > > --- FAIL: runtime_test.TestGcSys (4.64 seconds) > using 64 MB > using too much memory: 64 MB > > Raising the value in runtime/gc_test.go to 10e8 runs the test OK.
Thanks for reporting this. I just committed the appended patch to both the master Go library and to libgo. I hope this will fix this problem. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Ian
diff -r 832d9ebdb3c6 libgo/go/runtime/gc_test.go --- a/libgo/go/runtime/gc_test.go Tue Dec 13 14:24:59 2011 -0800 +++ b/libgo/go/runtime/gc_test.go Tue Dec 13 15:13:43 2011 -0800 @@ -6,16 +6,24 @@ ) func TestGcSys(t *testing.T) { + runtime.GC() + runtime.UpdateMemStats() + sys := runtime.MemStats.Sys + for i := 0; i < 1000000; i++ { workthegc() } // Should only be using a few MB. runtime.UpdateMemStats() - sys := runtime.MemStats.Sys - t.Logf("using %d MB", sys>>20) - if sys > 10e6 { - t.Fatalf("using too much memory: %d MB", sys>>20) + if sys > runtime.MemStats.Sys { + sys = 0 + } else { + sys = runtime.MemStats.Sys - sys + } + t.Logf("used %d extra bytes", sys) + if sys > 2<<20 { + t.Fatalf("using too much memory: %d bytes", sys) } }