This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Go patch committed: Multiplex goroutines onto OS threads
- From: Ian Lance Taylor <iant at google dot com>
- To: Uros Bizjak <ubizjak at gmail dot com>
- Cc: gcc-patches at gcc dot gnu dot org, gofrontend-dev at googlegroups dot com
- Date: Tue, 13 Dec 2011 15:15:51 -0800
- Subject: Re: Go patch committed: Multiplex goroutines onto OS threads
- References: <CAFULd4YULnVxGRFutAw1kcEcKX5Qt3z1H2bxc=PekQzByjL=4Q@mail.gmail.com>
Uros Bizjak <ubizjak@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)
}
}