发送时间: 2014年7月31日 22:52
主题: Gob performance problem in heavy concurrent use
I am using gob to concurrently encode/decode data via network. But it seems that there is a bottleneck for the concurrent use of gob. Here is a code example that reproduces the problem: http://play.golang.org/p/W6X0yqdub9 . It simulates a concurrent decoding of large data sent over network by multiple goroutines. If you run the program, and then use the pprof tool to see the cpu usage, you may get something like this:
Total: 172 samples
97 56.4% 56.4% 97 56.4% sync/atomic.AddUint32
7 4.1% 60.5% 8 4.7% bytes.(*Buffer).WriteByte
7 4.1% 64.5% 13 7.6% encoding/gob.(*decoderState).decodeUint
7 4.1% 68.6% 7 4.1% runtime.memmove
6 3.5% 72.1% 23 13.4% encoding/gob.encInt
Half of the time is spent on AddUint32. If you let pprof to focus on the function, you can see it is from the mutex lock calls in gob.validUserType function (in type.go file of the gob package). The attached file clearly shows this.
My question is: is there something wrong with my concurrent use of gob ? Or there is a way to reduce the bottleneck ? Thanks !
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to email@example.com.
For more options, visit https://groups.google.com/d/optout.