Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-27 Thread Changkun Ou
Many thank for the perf tool, it is pretty awesome. > On 27. Aug 2019, at 13:36, Robert Engels wrote: > > Ok maybe it wasn’t the cache issue, so then try this, below a certain number > of go routines given the workload the spin and cas works, beyond a certain > point it is forced into the sema

Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-27 Thread Robert Engels
t;> >> Still, you keep ignoring this aspect - in the context of actual workloads >> the difference is negligible. >> -Original Message----- >> From: changkun >> Sent: Aug 26, 2019 4:08 PM >> To: golang-nuts >> Subject: Re: [go-nuts] sync.Mutex encou

Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-26 Thread changkun
oroutines cache-references cache-misses hint/(hint+miss) >>> 2400 697103572 17641686 0.9753175194 >>> 3200 798160789 54169784 0.9364451004 >>> 3360 1387972473 148415678 0.9033996208 >>> 3600 1824541062 272166355 0.8701934506 >>> 4000 2053779401 39358

Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-26 Thread Michael Jones
ds > the difference is negligible. > > -Original Message- > From: changkun > Sent: Aug 26, 2019 4:08 PM > To: golang-nuts > Subject: Re: [go-nuts] sync.Mutex encounter large performance drop when > goroutine contention more than 3400 > > Based on the pprof graph, I w

Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-26 Thread Robert Engels
is negligible.-Original Message- From: changkun Sent: Aug 26, 2019 4:08 PM To: golang-nuts Subject: Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400 Based on the pprof graph, I would rather believe that the massive performance drop happens

Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-26 Thread changkun
probably OS and hardware >> configuration dependent - so I think I've probably reached the end of being >> able to help. >> >> And finally, it probably doesn't matter at all - if the Go routine is >> doing anything of value, 300 ns is probably an insignifica

Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-26 Thread Robert Engels
pu cache hit/miss ratio.-Original Message- From: changkun Sent: Aug 26, 2019 2:23 PM To: golang-nuts Subject: Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400 Your cache theory is very reasonable, but this was clear in the beginning post:  "

Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-26 Thread changkun
x27; and monitor the cpu cache hit/miss > ratio. > > -Original Message- > From: changkun > Sent: Aug 26, 2019 2:23 PM > To: golang-nuts > Subject: Re: [go-nuts] sync.Mutex encounter large performance drop when > goroutine contention more than 3400 > > Your

Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-26 Thread Robert Engels
hat is, do 'more work' yet constant that destroys the cache - and back into the concurrency times.-Original Message- From: changkun Sent: Aug 26, 2019 2:23 PM To: golang-nuts Subject: Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-26 Thread Robert Engels
You can run the process under 'perf' and monitor the cpu cache hit/miss ratio.-Original Message- From: changkun Sent: Aug 26, 2019 2:23 PM To: golang-nuts Subject: Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400 Your cache

Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-26 Thread changkun
slower than 3600 - so it is > increasing linearly with the number of Go routines. > > > -Original Message- > From: changkun > Sent: Aug 26, 2019 11:49 AM > To: golang-nuts > Subject: Re: [go-nuts] sync.Mutex encounter large performance drop when > goroutine

Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-26 Thread Robert Engels
: changkun Sent: Aug 26, 2019 11:49 AM To: golang-nuts Subject: Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400 According to your formula let's sample three points:2400 goroutines: 2.508s/(5000*2400) = 2.09 × 10^-11 s3600 goroutines: 12

Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-26 Thread changkun
According to your formula let's sample three points: 2400 goroutines: 2.508s/(5000*2400) = 2.09 × 10^-11 s 3600 goroutines: 12.219s/(5000*3600) = 6.7883 × 10-11 seconds 4800 goroutines: 16.020s/(5000*4800) = 6.67500 × 10^-11 s One can observe that 3600 and 4800 mostly equal to eac

Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-26 Thread changkun
And it looks like the `semacquire1` executed too many `gopark`, which means indicating that `cansemacquire` failed a lot when too much contention happens. On Monday, August 26, 2019 at 6:27:14 PM UTC+2, changkun wrote: > > Sorry for late response. Do you mean the total execution was not the same

Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-26 Thread changkun
nce the cache is exhausted - the kernel based scheduler > is more efficient - so it does suggest to me that there are some > optimizations that can be done in the Go scheduler. > > I will look at a few things this evening. > > -Original Message- > From: changkun > S

Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-22 Thread robert engels
or the worker is causing L1 evictions anyway - so you never see > the optimum performance possible of the scheduler). > > -Original Message- > From: changkun > Sent: Aug 20, 2019 3:33 AM > To: golang-nuts > Subject: Re: [go-nuts] sync.Mutex encounter large performance dro

Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-21 Thread Robert Engels
n Sent: Aug 21, 2019 4:51 PM To: golang-nuts Subject: Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400 "less than N Go routines it fits in the L1 CPU cache," I am guessing that you are thinking of local queues on each M, the scheduler

Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-21 Thread changkun
s very fair, and the >> chan/futex version is unfair - meaning many are starved. >> >> -Original Message- >> From: changkun >> Sent: Aug 19, 2019 12:50 PM >> To: golang-nuts >> Subject: [go-nuts] sync.Mutex encounter large performance drop w

Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-20 Thread Robert Engels
: changkun Sent: Aug 20, 2019 3:33 AM To: golang-nuts Subject: Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400 Hi Robert,Thanks for your explanation. But how could I "logged the number of operations done per Go routine", which partic

Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-20 Thread robert engels
nfair - meaning many are starved. > > -Original Message- > From: changkun > Sent: Aug 19, 2019 12:50 PM > To: golang-nuts > Subject: [go-nuts] sync.Mutex encounter large performance drop when goroutine > contention more than 3400 > > I am comparing the perf

Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-20 Thread changkun
Hi Ian Davis, I read the issue before I post this thread. I think the old issue is quite different than here. Here the problem discusses sudden performance drop and unexpected regression, but the issue#5183 only did experiment on a very limited number of goroutines, and Dmitry's answer is fair

Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-20 Thread Ian Davis
On Tue, 20 Aug 2019, at 9:33 AM, changkun wrote: > Hi Robert, > > Thanks for your explanation. But how could I "logged the number of operations > done per Go routine", which particular debug settings you referring to? > It is reasonable that sync.Mutex rely on runtime scheduler but channels do

Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-20 Thread changkun
o > routine, you will see that the Mutex version is very fair, and the > chan/futex version is unfair - meaning many are starved. > > -Original Message- > From: changkun > Sent: Aug 19, 2019 12:50 PM > To: golang-nuts > Subject: [go-nuts] sync.Mutex encounter

Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-19 Thread Robert Engels
bject: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400 I am comparing the performance regarding sync.Mutex and Go channels. Here is my benchmark: https://play.golang.org/p/zLjVtsSx9gdThe performance comparison visualization is as follows:What are the

Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-19 Thread changkun
Hi Ian, Thanks for the hint. I tried on a Mac mini with i5-8500B, it seems the unexpected performance drop still exists (let GOMAXPROCS(8)) the control condition is the CPU: [image: sync.Mutex performance (GOMAXPROCS == 8).png] On Monday, August 19, 2019 at 9:15:50 PM UTC+2, Ian Lance Taylor

Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-19 Thread Ian Lance Taylor
On Mon, Aug 19, 2019 at 10:50 AM changkun wrote: > > I am comparing the performance regarding sync.Mutex and Go channels. Here is > my benchmark: https://play.golang.org/p/zLjVtsSx9gd Might be interesting to try running your benchmark on a machine with different hardware. Ian -- You received

[go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-19 Thread changkun
I am comparing the performance regarding sync.Mutex and Go channels. Here is my benchmark: https://play.golang.org/p/zLjVtsSx9gd The performance comparison visualization is as follows: [image: sync.Mutex performance (1).png] What are the reasons that 1. sync.Mutex encounter a large performance