-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Closed
Milestone
Description
by kell.sommers:
Benchmarking a web socket server I started hitting a single threaded wall. It seems messages/second performance on OSX doesn't increase when set beyond 1. Some others on the IRC channel took my short reproducible code for a run on other Macs and other Linux and FreeBSD machines and verified there is something going on with Go on OSX. I did additional tests figure further down to out if the OSX problem is on the client or on the server side. It seems it is on the server side. This test goes over the network not over localhost. I know this isn't a localhost issue because I have a C based HTTP server that can do 500,000 HTTP requests/second on this machine over localhost with the much bulkier HTTP protocol. Go 1.2 on all machines tested. The test code can be found here: https://gist.github.com/kellabyte/8032308 ---------------------------------------------- OSX i7-3720QM CPU @ 2.60GHz go1.2 darwin/amd64 ---------------------------------------------- Performance doesn't increase with GOMAXPROCS it gets worse on OSX! GOMAXPROCS=1 ./websocket_client 4 100000 Sent 400000 in 2.389414969s for a rate of 167404/second GOMAXPROCS=2 ./websocket_client 4 100000 Sent 400000 in 6.219798526s for a rate of 64310/second <-- Lost 100K msgs/second! GOMAXPROCS=3 ./websocket_client 4 100000 Sent 400000 in 5.487955623s for a rate of 72886/second GOMAXPROCS=4 ./websocket_client 4 100000 Sent 400000 in 7.428882557s for a rate of 53843/second --------------- 2013 MBP retina --------------- Confirmed again on someone elses OSX machine. $ sysctl -n machdep.cpu.brand_string Intel(R) Core(TM) i5-3230M CPU @ 2.60GHz $ go version go version go1.2 darwin/amd64 $ ./client 1 100000 Sent 100000 in 896.185619ms for a rate of 111584/second $ ./client 4 100000 Sent 400000 in 3.661056594s for a rate of 109258/second $ GOMAXPROCS=4 ./client 1 100000 Sent 100000 in 923.826561ms for a rate of 108245/second $ GOMAXPROCS=4 ./client 4 100000 Sent 400000 in 3.254549872s for a rate of 122904/second ---------------------------------------- Ubuntu 13.10, cpu is Intel Core i5-2500K ---------------------------------------- This one seems to scale with GOMAXPROCS! $ go version go version go1.2 linux/amd64 $ ./client 1 100000 Sent 100000 in 428.895171ms for a rate of 233157/second $ ./client 4 100000 Sent 400000 in 1.79000027s for a rate of 223463/second $ GOMAXPROCS=4 ./client 1 100000 Sent 100000 in 454.46171ms for a rate of 220040/second $ GOMAXPROCS=4 ./client 4 100000 Sent 400000 in 700.25884ms for a rate of 571217/second -------------------------------------------------- 2.2GHz dual core Ivy Bridge FreeBSD 10.0rc1 Go 1.2 -------------------------------------------------- GOMAXPROCS=1: ./client 4 100000 Sent 400000 in 2.723452743s for a rate of 146872/second GOMAXPROCS=2: ./client 4 100000 Sent 400000 in 3.107706227s for a rate of 128712/second GOMAXPROCS=3: ./client 4 100000 Sent 400000 in 1.903976998s for a rate of 210086/second GOMAXPROCS=4: ./client 4 100000 Sent 400000 in 1.736387681s for a rate of 230363/second ------------------------------------- Ubuntu server and OSX client over GbE LAN ------------------------------------- Server: Ubuntu AMD Phenom(tm) 9150e Quad-Core Processor Client: OSX i7-3720QM CPU @ 2.60GHz GOMAXPROCS=4 on both client and server ./websocket_client 4 400000 Sent 1600000 in 3.354864357s for a rate of 476919/second ------------------------------------- OSX server and Ubuntu client over GbE LAN ------------------------------------- The OSX machine never goes above 115% CPU so the other 3 cores aren't used much. Server: OSX i7-3720QM CPU @ 2.60GHz Client: Ubuntu AMD Phenom(tm) 9150e Quad-Core Processor GOMAXPROCS=4 on both client and server ./websocket_client 4 400000 Sent 1600000 in 7.687288138s for a rate of 208135/second