-
Notifications
You must be signed in to change notification settings - Fork 18k
runtime: non-blocking read on an empty closed channel takes the slow path #32529
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
Comments
Change https://golang.org/cl/181543 mentions this issue: |
Change https://golang.org/cl/216158 mentions this issue: |
Change https://golang.org/cl/216099 mentions this issue: |
Reopened because fixing CL has been reverted. |
This reverts CL 181543 (git e1446d9) Reason for revert: Caused a regression in the race detector. Updates #32529 Fixes #36714 Change-Id: Ifefe6784f86ea72f414a89f131c239e9c9fd74eb Reviewed-on: https://go-review.googlesource.com/c/go/+/216158 Run-TryBot: Alexander Rakoczy <alex@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com> Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Change https://golang.org/cl/216818 mentions this issue: |
Add a test to ensure that the race detector sees that closing a channel synchronizes with a read from that channel. This test case failed when CL 181543 was in the tree. CL 181543 was reverted in CL 216158; this adds a test to make sure that we don't re-introduce the problem at a later date. For #32529 For #36714 Change-Id: I5a40f744c67c3f8191d6ad822710c180880a7375 Reviewed-on: https://go-review.googlesource.com/c/go/+/216099 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
On my workstation, nonblocking receive on an empty open channel is about 700 times faster than nonblocking receive on an empty closed channel. This is because
chanrecv()
inruntime/chan.go
has a special-case optimization that takes a lock-free path in this case. A similar lock-free path can be implemented for closed channels, and should result in similar performance.The text was updated successfully, but these errors were encountered: