New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x/talks: concurrency 2012 sequenceboring.go fails to ensure lockstep sequenced behavior #47135
Comments
I don't think the author claimed this outputs in "round-robin scheduling". The lockstep here means both Ann and Joe outputting 0, then both outputting 1, ..., i.e. no one can output 1 before both have outputted 0. In particular, this is in contrast of the example a couple of slides before, where Joe can output 3, 4, 5 before Ann outputs 3 ( https://www.youtube.com/watch?v=f6kdp27TYZs&t=1095s ). I think this works as intended. cc @robpike in case there is anything to clarify. Thanks. |
Working as intended. No claim made for lockstep. |
|
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Eliminate simulated workload represented by the randomly assigned timer from sequenceboring.go
See playground version.
What did you expect to see?
The lockstep, sequenced, round-robin scheduling as communicated by speaker during this presentation.
Ann: 0
Joe: 0
Ann: 1
Joe: 1
Ann: 2
Joe: 2
Ann: 3
Joe: 3
Ann: 4
Joe: 4
You're all boring; I'm leaving.
Or a similar alternating sequence starting instead with Joe: 0
What did you see instead?
Joe or Ann can take an out of order turn from the other.
Please note the output varies from run to run depending on the go scheduler's state. For example, the code may periodically produce the intended lockstep behavior, however, entropy dictates otherwise.
Ann: 0
Joe: 0
Joe: 1
Ann: 1
Ann: 2
Joe: 2
Joe: 3
Ann: 3
Ann: 4
Joe: 4
You're all boring; I'm leaving.
Program exited.
Why does the bug occur?
The code doesn't encode a strict happens before to order go routine messaging. The coordination mechanism using the wait channel abstraction becomes a race condition within the scheduler when the effort to process the simulated workloads conclude at nearly the same instance.
Why does the bug matter?
Due to the speaker's prominence:
The text was updated successfully, but these errors were encountered: