Skip to content
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

runtime: non-blocking read on an empty closed channel takes the slow path #32529

Open
bemasc opened this issue Jun 10, 2019 · 1 comment

Comments

Projects
None yet
4 participants
@bemasc
Copy link
Contributor

commented Jun 10, 2019

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() in runtime/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.

@gopherbot

This comment has been minimized.

Copy link

commented Jun 10, 2019

Change https://golang.org/cl/181543 mentions this issue: runtime: Faster receive on a closed channels

@ALTree ALTree changed the title runtime: Non-blocking read on an empty closed channel takes the slow path runtime: non-blocking read on an empty closed channel takes the slow path Jun 10, 2019

@ALTree ALTree added the Performance label Jun 10, 2019

@ALTree ALTree added this to the Unplanned milestone Jun 10, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.