$ go version go version go1.13 linux/amd64
I'm not sure how to deal with this phenomenon when I find that the parallel performance using go routine is not very good when writing database(olap) code. I have written the following example to verify this: ``` package main import ( "fmt" "hash/crc32" "time" ) const ( Loop = 10000 ) func main() { data := make([]byte, 4<<20) t := time.Now() for i := 0; i < Loop; i++ { crc32.ChecksumIEEE(data) } fmt.Printf("process: %v\n", time.Now().Sub(t)) } ``` ``` package main import ( "fmt" "hash/crc32" "sync" "time" ) const ( Mcpu = 8 Loop = 10000 / Mcpu ) func main() { data := make([]byte, 4<<20) var wg sync.WaitGroup t := time.Now() for i := 1; i < Mcpu; i++ { wg.Add(1) go func(idx int) { defer wg.Done() tt := time.Now() for j := 0; j < Loop; j++ { crc32.ChecksumIEEE(data) } fmt.Printf("%v's process: %v\n", idx, time.Now().Sub(tt)) }(i) } { tt := time.Now() for j := 0; j < Loop; j++ { crc32.ChecksumIEEE(data) } fmt.Printf("0's process: %v\n", time.Now().Sub(tt)) } wg.Wait() fmt.Printf("process: %v\n", time.Now().Sub(t)) } ``` My machine has exactly 8 cpu's and I found that the runtime does not decrease linearly when the number of go routines increases. -- 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 golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/04818152-6165-4c3b-b640-a3823153ccd4n%40googlegroups.com.