runtime: introduce Processors
Introduce notion of P (Processors), there are exactly GOMAXPROCS Processors. Each M (Machine) has an associated P when executes Go code.
Move MCache to P.
Remove goroutine handoff (M.nextg).
Remove the atomic scheduling word, use schedlock again.
Handle locked goroutines and machines out of band. Locked goroutines are not put to runqueue, locked machines are not put to mhead.
Performance become slightly worse:
GOMAXPROCS=1 go test std
old: 48.27s
new: 49.33s
GOMAXPROCS=16 go test std
old: 52.69s
new: 53.95s
Tested: linux/darwin 386/amd64.
Ultimately more resources will be moved to P (runqueue), each P will have own mutex, common operations will be able to proceed w/o global mutex.
I'm not super qualified, but had a couple of nits/questions. yours, Bobby http://codereview.appspot.com/6273049/diff/25010/src/pkg/runtime/proc.c File src/pkg/runtime/proc.c ...
11 years, 10 months ago
(2012-07-05 19:01:04 UTC)
#3
FTR, I think current version (patch set 30) has problems with fairness. Since mreadylocked is ...
11 years, 10 months ago
(2012-07-06 06:30:28 UTC)
#5
FTR, I think current version (patch set 30) has problems with fairness. Since
mreadylocked is LIFO and always have priority over normal runqueue, a yielding
locked goroutine can starve other locked and non-locked goroutines.
However, perhaps this may be fixed in a subsequent change list.
Thanks! I do not address code formatting/commenting comments, because I am still not sure about ...
11 years, 9 months ago
(2012-08-05 10:47:11 UTC)
#7
Thanks!
I do not address code formatting/commenting comments, because I am still not
sure about high-level structure.
It's difficult to get to the final destination through several stable and
consistent points. I think it will be easier to do the same thing as with GC -
implement a final version in a huge CL, then commit it in parts to the extend
possible (most changes in proc.c will have to go in a single big CL anyway).
http://codereview.appspot.com/6273049/diff/25010/src/pkg/runtime/proc.c
File src/pkg/runtime/proc.c (right):
http://codereview.appspot.com/6273049/diff/25010/src/pkg/runtime/proc.c#newco...
src/pkg/runtime/proc.c:590: schedlock();
On 2012/07/06 16:43:13, DMorsing wrote:
> Not sure how this sequence does what the comment says it does or why it is
> needed.
See schedunlock(). newm() starts new thread, but only schedunlock() supplies it
with P. So new thread must wait for the parent thread to execute schedunlock().
This sequence does that.
http://codereview.appspot.com/6273049/diff/25010/src/pkg/runtime/proc.c#newco...
src/pkg/runtime/proc.c:1372: if(!tryentergo())
On 2012/07/06 16:43:13, DMorsing wrote:
> Looks to me like this could be replaced with entergo(m).
Yes, I think you're right.
http://codereview.appspot.com/6273049/diff/25010/src/pkg/runtime/proc.c#newco...
src/pkg/runtime/proc.c:1389: entergo(M *mp)
On 2012/07/06 16:43:13, DMorsing wrote:
> entergo name seems to imply that you're trying to get a goroutine to run, when
> you're really trying to get a P in order to run Gs (if i understand this code
> correctly)
A better name?
On 2012/08/05 10:47:11, dvyukov wrote: > Thanks! > > I do not address code formatting/commenting ...
11 years, 9 months ago
(2012-08-06 13:45:38 UTC)
#8
On 2012/08/05 10:47:11, dvyukov wrote:
> Thanks!
>
> I do not address code formatting/commenting comments, because I am still not
> sure about high-level structure.
>
> It's difficult to get to the final destination through several stable and
> consistent points. I think it will be easier to do the same thing as with GC -
> implement a final version in a huge CL, then commit it in parts to the extend
> possible (most changes in proc.c will have to go in a single big CL anyway).
... and I need a proof-of-performance prototype.
Please, disregard this CL.
Issue 6273049: code review 6273049: runtime: introduce Processors
(Closed)
Created 11 years, 11 months ago by dvyukov
Modified 11 years, 9 months ago
Reviewers:
Base URL:
Comments: 15